diff --git a/src/test/testcommon.h b/src/test/testcommon.h index 4ae4c900..5771f90f 100644 --- a/src/test/testcommon.h +++ b/src/test/testcommon.h @@ -29,7 +29,7 @@ #define TESTOUT_ADDR 0x1f43 // PEEK(8003) -- NOTE : value is hardcoded in various places #define BLANK_SCREEN "6C8ABA272F220F00BE0E76A8659A1E30C2D3CDBE" -#define BOOT_SCREEN "6992DC41631290540E7175F06873BA559E938BF7" +#define BOOT_SCREEN "AAFB9163DD526F6E57C3BF9FCA5D5222C19E8A02" extern char mdstr[(SHA_DIGEST_LENGTH*2)+1]; diff --git a/src/test/testcpu.c b/src/test/testcpu.c index bf20f3e7..cc6d82bc 100644 --- a/src/test/testcpu.c +++ b/src/test/testcpu.c @@ -7413,8 +7413,6 @@ GREATEST_SUITE(test_suite_cpu) { GREATEST_SET_TEARDOWN_CB(testcpu_teardown, NULL); GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL); - srandom(time(NULL)); - test_common_init(); assert(cpu_thread_id == 0 && "This test is not designed to run with alternate CPU thread"); extern void reinitialize(void); diff --git a/src/test/testdisk.c b/src/test/testdisk.c index 71419af8..24d4e861 100644 --- a/src/test/testdisk.c +++ b/src/test/testdisk.c @@ -48,7 +48,6 @@ static void testdisk_teardown(void *arg) { #define EXPECTED_DISK_TRACE_SHA "FA47CC59F0CC7E5B1E938FD54A3BD8DB6C930593" #endif TEST test_boot_disk_bytes() { - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; @@ -96,7 +95,6 @@ TEST test_boot_disk_bytes() { #define EXPECTED_DISK_TRACE_NIB_SHA "CE61D709A344778AB8A8DACED5A38D0D40F1E645" TEST test_boot_disk_bytes_nib() { test_setup_boot_disk(BLANK_NIB, 0); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; @@ -150,7 +148,6 @@ TEST test_boot_disk_bytes_nib() { #endif TEST test_boot_disk_bytes_po() { test_setup_boot_disk(BLANK_PO, 0); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; @@ -261,12 +258,12 @@ TEST test_savehello_dsk() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(SAVE_SHA1); + WAIT_FOR_FB_SHA(SAVE_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -287,12 +284,12 @@ TEST test_savehello_nib() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(SAVE_SHA1); + WAIT_FOR_FB_SHA(SAVE_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -313,12 +310,12 @@ TEST test_savehello_po() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(SAVE_SHA1); + WAIT_FOR_FB_SHA(SAVE_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -341,7 +338,6 @@ TEST test_disk_bytes_savehello_dsk() { ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; ASPRINTF(&disk, "%s/a2_write_disk_test_dsk.txt", homedir); @@ -357,7 +353,7 @@ TEST test_disk_bytes_savehello_dsk() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(SAVE_SHA1); + WAIT_FOR_FB_SHA(SAVE_SHA1); disk6_traceEnd(); @@ -390,7 +386,7 @@ TEST test_disk_bytes_savehello_dsk() { REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -435,7 +431,6 @@ TEST test_disk_bytes_savehello_nib() { ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; ASPRINTF(&disk, "%s/a2_write_disk_test_nib.txt", homedir); @@ -451,7 +446,7 @@ TEST test_disk_bytes_savehello_nib() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(SAVE_SHA1); + WAIT_FOR_FB_SHA(SAVE_SHA1); disk6_traceEnd(); @@ -484,7 +479,7 @@ TEST test_disk_bytes_savehello_nib() { REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -529,7 +524,6 @@ TEST test_disk_bytes_savehello_po() { ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; ASPRINTF(&disk, "%s/a2_write_disk_test_po.txt", homedir); @@ -545,7 +539,7 @@ TEST test_disk_bytes_savehello_po() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(SAVE_SHA1); + WAIT_FOR_FB_SHA(SAVE_SHA1); disk6_traceEnd(); @@ -578,7 +572,7 @@ TEST test_disk_bytes_savehello_po() { REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -643,7 +637,6 @@ TEST test_outofspace_dsk() { ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; ASPRINTF(&disk, "%s/a2_oos_dsk_test.txt", homedir); @@ -659,7 +652,7 @@ TEST test_outofspace_dsk() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(NOSPACE_SHA1); + WAIT_FOR_FB_SHA(NOSPACE_SHA1); disk6_traceEnd(); @@ -692,7 +685,7 @@ TEST test_outofspace_dsk() { REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -742,12 +735,12 @@ TEST test_outofspace_nib() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(NOSPACE_SHA1); + WAIT_FOR_FB_SHA(NOSPACE_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -797,12 +790,12 @@ TEST test_outofspace_po() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(NOSPACE_SHA1); + WAIT_FOR_FB_SHA(NOSPACE_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -855,7 +848,6 @@ TEST test_bload_trace_dsk() { ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; ASPRINTF(&disk, "%s/a2_bload_trace_test_dsk.txt", homedir); @@ -973,7 +965,6 @@ TEST test_bload_trace_nib() { ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; ASPRINTF(&disk, "%s/a2_bload_trace_test_nib.txt", homedir); @@ -1091,7 +1082,6 @@ TEST test_bload_trace_po() { ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - srandom(0); const char *homedir = HOMEDIR; char *disk = NULL; ASPRINTF(&disk, "%s/a2_bload_trace_test_po.txt", homedir); @@ -1214,12 +1204,12 @@ TEST test_inithello_dsk() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(INIT_SHA1); + WAIT_FOR_FB_SHA(INIT_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -1239,12 +1229,12 @@ TEST test_inithello_nib() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(INIT_SHA1); + WAIT_FOR_FB_SHA(INIT_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -1264,12 +1254,12 @@ TEST test_inithello_po() { c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(INIT_SHA1); + WAIT_FOR_FB_SHA(INIT_SHA1); REBOOT_TO_DOS(); c_debugger_go(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); disk6_eject(0); @@ -1494,7 +1484,7 @@ TEST test_reinsert_edgecase() { // First verify we hit the crackscreen c_debugger_set_timeout(10); c_debugger_go(); - ASSERT_SHA(DROL_CRACK_SCREEN_SHA); + WAIT_FOR_FB_SHA(DROL_CRACK_SCREEN_SHA); // re-insert disk6_eject(0); diff --git a/src/test/testtrace.c b/src/test/testtrace.c index 59c14b60..c9454508 100644 --- a/src/test/testtrace.c +++ b/src/test/testtrace.c @@ -248,7 +248,6 @@ TEST test_boot_disk_cputrace() { cpu65_trace_begin(output); } - srandom(0); BOOT_TO_DOS(); cpu65_trace_end(); @@ -297,8 +296,6 @@ TEST test_boot_disk_cputrace2() { // Failing now due to difference in IRQ timing cpu65_trace_begin(output); } - srandom(0); - // Poll for trace file of particular size c_debugger_clear_watchpoints(); c_debugger_set_timeout(1); @@ -364,8 +361,6 @@ TEST test_boot_disk_cputrace3() { cpu65_trace_begin(output); } - srandom(0); - // Poll for trace file of particular size c_debugger_clear_watchpoints(); c_debugger_set_timeout(1); @@ -432,7 +427,6 @@ TEST test_cputrace_hello_dsk() { cpu65_trace_begin(output); } - srandom(0); apple_ii_64k[0][WATCHPOINT_ADDR] = 0x00; test_type_input_deterministically("RUN HELLO\r"); c_debugger_go(); @@ -482,7 +476,6 @@ TEST test_cputrace_hello_nib() { cpu65_trace_begin(output); } - srandom(0); apple_ii_64k[0][WATCHPOINT_ADDR] = 0x00; test_type_input_deterministically("RUN HELLO\r"); c_debugger_go(); @@ -532,7 +525,6 @@ TEST test_cputrace_hello_po() { cpu65_trace_begin(output); } - srandom(0); apple_ii_64k[0][WATCHPOINT_ADDR] = 0x00; test_type_input_deterministically("RUN HELLO\r"); c_debugger_go(); @@ -581,7 +573,6 @@ TEST test_boot_disk_vmtrace() { vm_trace_begin(disk); } - srandom(0); BOOT_TO_DOS(); vm_trace_end(); @@ -629,7 +620,6 @@ TEST test_boot_disk_vmtrace_nib() { vm_trace_begin(disk); } - srandom(0); BOOT_TO_DOS(); vm_trace_end(); @@ -677,7 +667,6 @@ TEST test_boot_disk_vmtrace_po() { vm_trace_begin(disk); } - srandom(0); BOOT_TO_DOS(); vm_trace_end(); diff --git a/src/test/testui.c b/src/test/testui.c index a0608d74..660d800e 100644 --- a/src/test/testui.c +++ b/src/test/testui.c @@ -147,7 +147,7 @@ TEST test_save_state_1() { bool ret = emulator_saveState(fd); ASSERT(ret); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); TEMP_FAILURE_RETRY(close(fd)); @@ -190,7 +190,7 @@ TEST test_load_state_1() { _assert_blank_boot(); ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); - ASSERT_SHA(BOOT_SCREEN); + WAIT_FOR_FB_SHA(BOOT_SCREEN); TEMP_FAILURE_RETRY(close(fdState)); TEMP_FAILURE_RETRY(close(fdA)); @@ -304,7 +304,7 @@ TEST test_load_A2VM_good1() { ASSERT(run_args.cpu65_sp == 0xEA); // ASSERT framebuffer matches expected - ASSERT_SHA("9C654FEF2A672E16D89ED2FB80C593CD2005A026"); + WAIT_FOR_FB_SHA("8BF579CC23A8A6D5E13F5BA3CEEE9DA7714F72B6"); TEMP_FAILURE_RETRY(close(fdState)); TEMP_FAILURE_RETRY(close(fdA)); @@ -430,7 +430,7 @@ TEST test_load_A2V2_good1() { mb_testAssertA2V2(mbData, mbSiz); // ASSERT framebuffer matches expected - ASSERT_SHA("B1CB1C5811B9C629BB077F857CC41DFA8A283E96"); + WAIT_FOR_FB_SHA("3FB6BF44F5A7A6742550B33B627FFC5F06BAEC94"); TEMP_FAILURE_RETRY(close(fdState)); TEMP_FAILURE_RETRY(close(fdA)); @@ -556,7 +556,7 @@ TEST test_load_A2V2_good2() { mb_testAssertA2V2(mbData, mbSiz); // ASSERT framebuffer matches expected - ASSERT_SHA("7A60972EF2E95956249454402A42C12E7C8FBF7A"); + WAIT_FOR_FB_SHA("FD20698466B30B5BE9DA298731B6B5AC2C94C56D"); TEMP_FAILURE_RETRY(close(fdState)); TEMP_FAILURE_RETRY(close(fdA)); @@ -678,7 +678,7 @@ TEST test_load_A2V2_good3() { mb_testAssertA2V2(mbData, mbSiz); // ASSERT framebuffer matches expected - ASSERT_SHA("D92EECDF3C7446097F3E884412D7911DDD968287"); + WAIT_FOR_FB_SHA("70BFB1572C377578EAAB31AC09C4C383366628BD"); TEMP_FAILURE_RETRY(close(fdState)); TEMP_FAILURE_RETRY(close(fdA)); @@ -749,8 +749,6 @@ void test_ui(int _argc, char **_argv) { test_argc = _argc; test_argv = _argv; - srandom(time(NULL)); - test_common_init(); pthread_t p; diff --git a/src/test/testvm.c b/src/test/testvm.c index 455fd850..a0619f6b 100644 --- a/src/test/testvm.c +++ b/src/test/testvm.c @@ -107,58 +107,6 @@ TEST test_read_random() { PASS(); } -#if 0 -#error this is an unstable test due to VBL refactoring ... -TEST test_read_random2() { -#ifdef __APPLE__ -#warning "ignoring random test on Darwin..." -#else - - srandom(0); // force a known sequence - BOOT_TO_DOS(); - - ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED); - ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 0x00); - - test_type_input("RUN TESTRND2\r"); - c_debugger_go(); - - ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 103); - - apple_ii_64k[0][WATCHPOINT_ADDR] = 0x0; - test_common_setup(); - test_type_input("RUN\r"); - c_debugger_go(); - ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 198); - - apple_ii_64k[0][WATCHPOINT_ADDR] = 0x0; - test_common_setup(); - test_type_input("RUN\r"); - c_debugger_go(); - ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 105); - - apple_ii_64k[0][WATCHPOINT_ADDR] = 0x0; - test_common_setup(); - test_type_input("RUN\r"); - c_debugger_go(); - ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 115); - - apple_ii_64k[0][WATCHPOINT_ADDR] = 0x0; - test_common_setup(); - test_type_input("RUN\r"); - c_debugger_go(); - ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED); - ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 81); -#endif - - PASS(); -} -#endif - // ---------------------------------------------------------------------------- // Softswitch tests @@ -3227,20 +3175,10 @@ GREATEST_SUITE(test_suite_vm) { // TESTS -------------------------- -#if defined(ANDROID) -#warning FIXME TODO ... why are these test broken on Android?! -#else RUN_TESTp(test_read_keyboard); - RUN_TESTp(test_clear_keyboard); RUN_TESTp(test_read_random); -#if 0 -#error this is an unstable test due to VBL refactoring ... - RUN_TESTp(test_read_random2); -#endif - -#endif RUN_TESTp(test_PAGE2_on, /*80STORE*/0, /*HIRES*/0); RUN_TESTp(test_PAGE2_on, /*80STORE*/0, /*HIRES*/1); diff --git a/src/timing.c b/src/timing.c index c211400c..bbb087e2 100644 --- a/src/timing.c +++ b/src/timing.c @@ -491,6 +491,7 @@ bool timing_isCPUThread(void) { void timing_startCPU(void) { cpu_shutting_down = false; + assert(cpu_thread_id == 0); int err = TEMP_FAILURE_RETRY(pthread_create(&cpu_thread_id, NULL, (void *)&cpu_thread, (void *)NULL)); if (err) { LOG("pthread_create failed!");