diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-12-06 19:13:54 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-12-06 19:13:54 +0100 |
commit | 9e8b57d6e6c5cee76af12bce27efb81041676314 (patch) | |
tree | 26f1cff162a0703ed9674a468f266dba20c6e04a /emu | |
parent | 655ee84ba2304b2fe85b28290580338d29a68c3c (diff) | |
download | 6502-9e8b57d6e6c5cee76af12bce27efb81041676314.tar.gz 6502-9e8b57d6e6c5cee76af12bce27efb81041676314.tar.bz2 |
added testing framework (check)
Diffstat (limited to 'emu')
-rw-r--r-- | emu/CMakeLists.txt | 3 | ||||
-rw-r--r-- | emu/emul.c | 20 | ||||
-rw-r--r-- | emu/tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | emu/tests/test_cpu_6502.c | 50 |
4 files changed, 70 insertions, 7 deletions
diff --git a/emu/CMakeLists.txt b/emu/CMakeLists.txt index 33f02f5..535802a 100644 --- a/emu/CMakeLists.txt +++ b/emu/CMakeLists.txt @@ -36,9 +36,12 @@ INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2_GFX REQUIRED SDL2_gfx) +PKG_SEARCH_MODULE(CHECK REQUIRED check) include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}) add_executable(emu ${SRC}) target_link_libraries(emu ${SDL2_LIBRARIES} ${SDL2_GFX_LIBRARIES}) +enable_testing() +add_subdirectory(tests) @@ -74,6 +74,18 @@ void emul_start( emul_t *emul ) } } +static void print_help( void ) +{ + fprintf( stderr, "CPU is paused, press\n" + "(s) for single step\n" + "(f) fini (continue to next rts)\n" + "(c) for continue running\n" + "(b) break to single stepping\n" + "(+) speed up\n" + "(-) speed down\n" + "(q) or (ESC) for shutting down\n" ); +} + void emul_run( emul_t *emul, int nof_steps ) { #ifdef WITH_GUI @@ -82,13 +94,7 @@ void emul_run( emul_t *emul, int nof_steps ) bool done = false; if( emul->paused ) { - fprintf( stderr, "CPU is paused, press\n" - "(s) for single step\n" - "(c) for continue running\n" - "(b) break to single stepping\n" - "(+) speed up\n" - "(-) speed down\n" - "(q) or (ESC) for shutting down\n" ); + print_help( ); } while( !done ) { diff --git a/emu/tests/CMakeLists.txt b/emu/tests/CMakeLists.txt new file mode 100644 index 0000000..5011371 --- /dev/null +++ b/emu/tests/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(test_cpu_6502 test_cpu_6502.c) +target_link_libraries(test_cpu_6502 ${CHECK_LIBRARIES} pthread) + +add_test(NAME test_cpu_6502 COMMAND test_cpu_6502 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests) diff --git a/emu/tests/test_cpu_6502.c b/emu/tests/test_cpu_6502.c new file mode 100644 index 0000000..0eb6a2b --- /dev/null +++ b/emu/tests/test_cpu_6502.c @@ -0,0 +1,50 @@ +#include <stdlib.h> +#include <stdint.h> +#include <check.h> + +void setup( void ) +{ +} + +void teardown( void ) +{ +} + +START_TEST( test_cpu_6502_nop ) +{ +} +END_TEST + +Suite *make_cpu_6502_testsuite( void ) +{ + Suite *suite; + TCase *tc_opcodes; + + suite = suite_create( "6502 CPU tests" ); + + tc_opcodes = tcase_create( "test opcodes" ); + + tcase_add_test( tc_opcodes, test_cpu_6502_nop ); + + suite_add_tcase( suite, tc_opcodes ); + + return suite; +} + +int main( void ) +{ + SRunner *runner; + int tests_failed = 0; + + runner = srunner_create( make_cpu_6502_testsuite( ) ); + srunner_set_fork_status( runner, CK_NOFORK ); + + srunner_set_log( runner, "test.log" ); + srunner_set_xml( runner, "test.xml" ); + srunner_run_all( runner, CK_VERBOSE ); + + tests_failed = srunner_ntests_failed( runner ); + srunner_free( runner ); + + exit( ( tests_failed == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE ); +} |