mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-12-25 09:29:48 +00:00
Testing is beginning to work again after upheaval
- testcpu, testvm, testdisk all look good - TODO : testdisplay, etc ...
This commit is contained in:
parent
0ddd9ffd91
commit
fb44420713
@ -817,6 +817,8 @@ uint16_t display_getVideoLineOffset(uint8_t txtRow) {
|
||||
return video_line_offset[txtRow];
|
||||
}
|
||||
|
||||
#if 0
|
||||
// FIXME TODO ... eliminate this completely since video scanner now in force ...
|
||||
PIXEL_TYPE *display_renderStagingFramebuffer(void) {
|
||||
|
||||
const uint32_t mainswitches = run_args.softswitches;
|
||||
@ -923,13 +925,14 @@ PIXEL_TYPE *display_renderStagingFramebuffer(void) {
|
||||
video_setDirty(FB_DIRTY_FLAG);
|
||||
return fbFull;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TESTING
|
||||
// HACK FIXME TODO ... should consolidate this into debugger ...
|
||||
extern pthread_mutex_t interface_mutex;
|
||||
extern pthread_cond_t cpu_thread_cond;
|
||||
extern pthread_cond_t dbg_thread_cond;
|
||||
uint8_t *display_waitForNextCompleteFramebuffer(void) {
|
||||
PIXEL_TYPE *display_waitForNextCompleteFramebuffer(void) {
|
||||
int err = 0;
|
||||
if ((err = pthread_cond_signal(&cpu_thread_cond))) {
|
||||
LOG("pthread_cond_signal : %d", err);
|
||||
|
@ -240,7 +240,7 @@ void display_frameComplete(void) CALL_ON_CPU_THREAD;
|
||||
/*
|
||||
* Wait for frame complete and return staging framebuffer.
|
||||
*/
|
||||
uint8_t *display_waitForNextCompleteFramebuffer(void);
|
||||
PIXEL_TYPE *display_waitForNextCompleteFramebuffer(void);
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -51,7 +51,8 @@ void test_common_init(void) {
|
||||
LEAK(envvar);
|
||||
|
||||
prefs_load();
|
||||
prefs_setLongValue(PREF_DOMAIN_VIDEO, PREF_COLOR_MODE, COLOR_MODE_COLOR);
|
||||
prefs_setLongValue(PREF_DOMAIN_VIDEO, PREF_COLOR_MODE, COLOR_MODE_MONO);
|
||||
prefs_setLongValue(PREF_DOMAIN_VIDEO, PREF_MONO_MODE, MONO_MODE_BW);
|
||||
prefs_setBoolValue(PREF_DOMAIN_KEYBOARD, PREF_KEYBOARD_CAPS, true);
|
||||
prefs_setFloatValue(PREF_DOMAIN_VM, PREF_CPU_SCALE, (CPU_SCALE_FASTEST * 100.));
|
||||
prefs_setFloatValue(PREF_DOMAIN_VM, PREF_CPU_SCALE_ALT, (CPU_SCALE_FASTEST * 100.));
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define TESTOUT_ADDR 0x1f43 // PEEK(8003) -- NOTE : value is hardcoded in various places
|
||||
|
||||
#define BLANK_SCREEN "6C8ABA272F220F00BE0E76A8659A1E30C2D3CDBE"
|
||||
#define BOOT_SCREEN "F8D6C781E0BB7B3DDBECD69B25E429D845506594"
|
||||
#define BOOT_SCREEN "6992DC41631290540E7175F06873BA559E938BF7"
|
||||
|
||||
extern char mdstr[(SHA_DIGEST_LENGTH*2)+1];
|
||||
|
||||
@ -43,52 +43,40 @@ char **test_copy_disk_paths(const char *fileName);
|
||||
int test_setup_boot_disk(const char *fileName, int readonly);
|
||||
void sha1_to_str(const uint8_t * const md, char *buf);
|
||||
|
||||
static inline bool _matchFramebufferSHA(const char *SHA_STR, bool is_old) {
|
||||
static inline bool _matchFramebufferSHA(const char *SHA_STR, bool do_assert) {
|
||||
uint8_t md[SHA_DIGEST_LENGTH];
|
||||
|
||||
uint8_t *fb = NULL;
|
||||
if (is_old) {
|
||||
extern uint8_t *display_renderStagingFramebuffer(void);
|
||||
fb = display_renderStagingFramebuffer();
|
||||
} else {
|
||||
fb = display_waitForNextCompleteFramebuffer();
|
||||
}
|
||||
SHA1(fb, SCANWIDTH*SCANHEIGHT, md);
|
||||
PIXEL_TYPE *fb = NULL;
|
||||
extern void timing_setVideoDirty(void);
|
||||
timing_setVideoDirty();
|
||||
fb = display_waitForNextCompleteFramebuffer();
|
||||
SHA1(fb, SCANWIDTH*SCANHEIGHT*PIXEL_STRIDE, md);
|
||||
|
||||
sha1_to_str(md, mdstr);
|
||||
bool matches = strcasecmp(mdstr, SHA_STR) == 0;
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
static inline int _assertFramebufferSHA(const char *SHA_STR, bool is_old) {
|
||||
bool matches = _matchFramebufferSHA(SHA_STR, is_old);
|
||||
ASSERT(matches && "check global mdstr if failed...");
|
||||
PASS();
|
||||
if (do_assert) {
|
||||
ASSERT(matches && "check global mdstr if failed...");
|
||||
PASS();
|
||||
} else {
|
||||
return matches;
|
||||
}
|
||||
}
|
||||
|
||||
#define ASSERT_SHA(SHA_STR) \
|
||||
do { \
|
||||
int ret = _assertFramebufferSHA(SHA_STR, /*is_old:*/false); \
|
||||
int ret = _matchFramebufferSHA(SHA_STR, /*do_assert:*/true); \
|
||||
if (ret != 0) { \
|
||||
return ret; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define ASSERT_SHA_OLD(SHA_STR) \
|
||||
do { \
|
||||
int ret = _assertFramebufferSHA(SHA_STR, /*is_old:*/true); \
|
||||
if (ret != 0) { \
|
||||
return ret; \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
#define WAIT_FOR_FB_SHA(SHA_STR) \
|
||||
do { \
|
||||
unsigned int matchAttempts = 0; \
|
||||
const unsigned int maxMatchAttempts = 10; \
|
||||
do { \
|
||||
bool matches = _matchFramebufferSHA(SHA_STR, /*is_old:*/false); \
|
||||
bool matches = _matchFramebufferSHA(SHA_STR, /*do_assert:*/false); \
|
||||
if (matches) { \
|
||||
break; \
|
||||
} \
|
||||
@ -97,7 +85,7 @@ do { \
|
||||
fprintf(GREATEST_STDOUT, "DID NOT FIND SHA %s...\n", SHA_STR); \
|
||||
ASSERT(0); \
|
||||
} \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
static inline int ASSERT_SHA_MEM(const char *SHA_STR, uint16_t ea, uint16_t len) {
|
||||
uint8_t md[SHA_DIGEST_LENGTH];
|
||||
@ -108,7 +96,7 @@ static inline int ASSERT_SHA_MEM(const char *SHA_STR, uint16_t ea, uint16_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ASSERT_SHA_BIN(const char *SHA_STR, const uint8_t * const buf, unsigned long len) {
|
||||
static inline int ASSERT_SHA_BIN(const char *SHA_STR, const uint8_t * const buf, unsigned int len) {
|
||||
uint8_t md[SHA_DIGEST_LENGTH];
|
||||
SHA1(buf, len, md);
|
||||
sha1_to_str(md, mdstr);
|
||||
|
@ -40,9 +40,10 @@ static void testdisk_teardown(void *arg) {
|
||||
// Disk TESTS ...
|
||||
|
||||
#if CONFORMANT_TRACKS
|
||||
#define EXPECTED_DISK_TRACE_FILE_SIZE 141348
|
||||
#define EXPECTED_DISK_TRACE_SHA "8E2415BB7F0A113BFE048FFE0C076AD4B377D22E"
|
||||
# define EXPECTED_DISK_TRACE_FILE_SIZE 141348
|
||||
# define EXPECTED_DISK_TRACE_SHA "8E2415BB7F0A113BFE048FFE0C076AD4B377D22E"
|
||||
#else
|
||||
# error FIXME TODO ...
|
||||
#define EXPECTED_DISK_TRACE_FILE_SIZE 134290
|
||||
#define EXPECTED_DISK_TRACE_SHA "FA47CC59F0CC7E5B1E938FD54A3BD8DB6C930593"
|
||||
#endif
|
||||
@ -140,9 +141,10 @@ TEST test_boot_disk_bytes_nib() {
|
||||
}
|
||||
|
||||
#if CONFORMANT_TRACKS
|
||||
#define EXPECTED_DISK_TRACE_PO_FILE_SIZE 141348
|
||||
#define EXPECTED_DISK_TRACE_PO_SHA "41C382A0A508F9A7935532ECFB7A1B6D53956A8D"
|
||||
# define EXPECTED_DISK_TRACE_PO_FILE_SIZE 141348
|
||||
# define EXPECTED_DISK_TRACE_PO_SHA "41C382A0A508F9A7935532ECFB7A1B6D53956A8D"
|
||||
#else
|
||||
# error FIXME TODO ...
|
||||
#define EXPECTED_DISK_TRACE_PO_FILE_SIZE 134290
|
||||
#define EXPECTED_DISK_TRACE_PO_SHA "E85D7B357B02942772F46332953E59CAB67D85CD"
|
||||
#endif
|
||||
@ -243,7 +245,7 @@ TEST test_read_null_bytes() {
|
||||
PASS();
|
||||
}
|
||||
|
||||
#define SAVE_SHA1 "B721C61BD10E28F9B833C5F661AA60C73B2D9F74"
|
||||
#define SAVE_SHA1 "8B3F85062A7AFE4189918B6BD75AC73EB8CBB87C"
|
||||
TEST test_savehello_dsk() {
|
||||
|
||||
test_setup_boot_disk(BLANK_DSK, 0);
|
||||
@ -327,6 +329,7 @@ TEST test_savehello_po() {
|
||||
# define EXPECTED_DISKWRITE_TRACE_DSK_FILE_SIZE 85915
|
||||
# define EXPECTED_DISKWRITE_TRACE_DSK_SHA "05A9043B09605546F2BCFD31CB2E48C779227D95"
|
||||
#else
|
||||
# error FIXME TODO ...
|
||||
# define EXPECTED_DISKWRITE_TRACE_DSK_FILE_SIZE 85916
|
||||
# define EXPECTED_DISKWRITE_TRACE_DSK_SHA "06E446C69C4C3522BDEF146B56B0414CA945A588"
|
||||
#endif
|
||||
@ -623,12 +626,13 @@ TEST test_disk_bytes_savehello_po() {
|
||||
test_type_input("BSAVEJUNK7,A$2000,L$4000\r"); \
|
||||
} while (0)
|
||||
|
||||
#define NOSPACE_SHA1 "2EA4D4B9F1C6797E476CD0FE59970CC243263B16"
|
||||
#define NOSPACE_SHA1 "9BF24D538E972A54FD4C14F411B43DE8986369D6"
|
||||
#define EXPECTED_OOS_DSK_SHA "D5C5A3FFB43F3C55E1C9E4ABD8580322415E9CE0"
|
||||
#if CONFORMANT_TRACKS
|
||||
# define EXPECTED_OOS_DSK_TRACE_FILE_SIZE 4386397
|
||||
# define EXPECTED_OOS_DSK_TRACE_SHA "FF60D99539047B76B0B441C5907F0FBE3D0B2FCE"
|
||||
#else
|
||||
# error FIXME TODO ...
|
||||
# define EXPECTED_OOS_DSK_TRACE_FILE_SIZE 4386354
|
||||
# define EXPECTED_OOS_DSK_TRACE_SHA "1304191D985B3D3E528FB462D2CF3677584CD2C3"
|
||||
#endif
|
||||
@ -839,6 +843,7 @@ TEST test_outofspace_po() {
|
||||
# define EXPECTED_BLOAD_TRACE_DSK_FILE_SIZE 1595253
|
||||
# define EXPECTED_BLOAD_TRACE_DSK_SHA "BF8719EE6E4814556957603068C47CC3F78E352C"
|
||||
#else
|
||||
# error FIXME TODO ...
|
||||
# define EXPECTED_BLOAD_TRACE_DSK_FILE_SIZE 1512000
|
||||
# define EXPECTED_BLOAD_TRACE_DSK_SHA "F5BE62CEFA89B6B09C0F257D34AD4E0868DA0B4C"
|
||||
#endif
|
||||
@ -1194,7 +1199,7 @@ TEST test_bload_trace_po() {
|
||||
PASS();
|
||||
}
|
||||
|
||||
#define INIT_SHA1 "10F15B516E4CF2FC5B1712951A6F9C3D90BF595C"
|
||||
#define INIT_SHA1 "552CB25B7B19FF08545548301C3F218965D5D38E"
|
||||
TEST test_inithello_dsk() {
|
||||
|
||||
test_setup_boot_disk(BLANK_DSK, 0);
|
||||
@ -1377,8 +1382,8 @@ TEST test_data_stability_po() {
|
||||
}
|
||||
|
||||
#define GZBAD_NIB "testgzheader.nib"
|
||||
#define GZBAD_NIB_LOAD_SHA1 "98EB8D2EF486E5BF888789A6FF9D4E3DEC7902B7"
|
||||
#define GZBAD_NIB_LOAD_SHA2 "764F580287564B5464BF98BC2026E110F06C9EA4"
|
||||
#define GZBAD_NIB_LOAD_SHA1 "E25F3524F852EFD043E2A036DA36779F1F68A8A2"
|
||||
#define GZBAD_NIB_LOAD_SHA2 "A82BBF38F79FBFA072C1061661E316CA8AF3B950"
|
||||
static int _test_disk_image_with_gzip_header(int readonly) {
|
||||
|
||||
test_setup_boot_disk(GZBAD_NIB, readonly);
|
||||
@ -1396,8 +1401,7 @@ static int _test_disk_image_with_gzip_header(int readonly) {
|
||||
do {
|
||||
uint8_t md[SHA_DIGEST_LENGTH];
|
||||
|
||||
uint8_t *fb = display_waitForNextCompleteFramebuffer();
|
||||
SHA1(fb, SCANWIDTH*SCANHEIGHT, md);
|
||||
SHA1(display_waitForNextCompleteFramebuffer(), SCANWIDTH*SCANHEIGHT*PIXEL_STRIDE, md);
|
||||
|
||||
sha1_to_str(md, mdstr);
|
||||
bool matches_sha1 = (strcasecmp(mdstr, GZBAD_NIB_LOAD_SHA1) == 0);
|
||||
@ -1481,7 +1485,7 @@ TEST test_disk_invalid_gzipped_rw() {
|
||||
|
||||
#if TEST_DISK_EDGE_CASES
|
||||
#define DROL_DSK "Drol.dsk.gz"
|
||||
#define DROL_CRACK_SCREEN_SHA "FD7332529E117F14DA3880BB36FE8E23C3704799"
|
||||
#define DROL_CRACK_SCREEN_SHA "ADC037D745304F17202D6F6BD6696AA443E8F8DC"
|
||||
TEST test_reinsert_edgecase() {
|
||||
test_setup_boot_disk(DROL_DSK, 0);
|
||||
|
||||
@ -1502,10 +1506,10 @@ TEST test_reinsert_edgecase() {
|
||||
c_debugger_go();
|
||||
uint8_t md[SHA_DIGEST_LENGTH];
|
||||
|
||||
uint8_t *fb = display_waitForNextCompleteFramebuffer();
|
||||
SHA1(fb, SCANWIDTH*SCANHEIGHT, md);
|
||||
SHA1(display_waitForNextCompleteFramebuffer(), SCANWIDTH*SCANHEIGHT*PIXEL_STRIDE, md);
|
||||
|
||||
sha1_to_str(md, mdstr);
|
||||
ASSERT(strcmp(mdstr, DROL_CRACK_SCREEN_SHA) != 0);
|
||||
ASSERT(strcmp(mdstr, BLANK_SCREEN) != 0);
|
||||
|
||||
c_debugger_set_timeout(0);
|
||||
|
@ -24,6 +24,7 @@ static void testvm_setup(void *arg) {
|
||||
if (test_do_reboot) {
|
||||
cpu65_interrupt(ResetSig);
|
||||
}
|
||||
test_setup_boot_disk("testvm1.dsk.gz", 1);
|
||||
}
|
||||
|
||||
static void testvm_teardown(void *arg) {
|
||||
@ -32,15 +33,6 @@ static void testvm_teardown(void *arg) {
|
||||
// ----------------------------------------------------------------------------
|
||||
// VM TESTS ...
|
||||
|
||||
TEST test_boot_disk() {
|
||||
test_setup_boot_disk("testvm1.dsk.gz", 1);
|
||||
|
||||
BOOT_TO_DOS();
|
||||
ASSERT_SHA(BOOT_SCREEN);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
TEST test_read_keyboard() {
|
||||
BOOT_TO_DOS();
|
||||
|
||||
@ -3235,8 +3227,6 @@ GREATEST_SUITE(test_suite_vm) {
|
||||
|
||||
// TESTS --------------------------
|
||||
|
||||
RUN_TESTp(test_boot_disk);
|
||||
|
||||
#if defined(ANDROID)
|
||||
#warning FIXME TODO ... why are these test broken on Android?!
|
||||
#else
|
||||
|
@ -207,6 +207,12 @@ bool cpu_isPaused(void) {
|
||||
return is_paused;
|
||||
}
|
||||
|
||||
#if TESTING
|
||||
void timing_setVideoDirty(void) {
|
||||
emul_video_dirty = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool timing_shouldAutoAdjustSpeed(void) {
|
||||
double speed = alt_speed_enabled ? cpu_altscale_factor : cpu_scale_factor;
|
||||
return auto_adjust_speed && (speed <= CPU_SCALE_FASTEST_PIVOT);
|
||||
|
@ -208,7 +208,7 @@ static void _setScannerDirty() {
|
||||
unsigned int colCount = (CYCLES_SCANLINE - hCount) % CYCLES_SCANLINE;
|
||||
if (cyclesDirty == 0) {
|
||||
cyclesFrameLast -= hCount;
|
||||
assert(cyclesFrameLast < (CYCLES_FRAME<<1)); // should be no underflow
|
||||
////assert(cyclesFrameLast < (CYCLES_FRAME<<1)); -- do not enable ... this will trigger on manual CPU speed adjustment
|
||||
assert(cyclesFrameLast % CYCLES_SCANLINE == 0);
|
||||
colCount = CYCLES_SCANLINE;
|
||||
|
||||
@ -397,7 +397,7 @@ void video_scannerUpdate(void) {
|
||||
if (vCount < SCANLINES_VBL_BEGIN) {
|
||||
// complete scanline flush ...
|
||||
unsigned int scanend = scancol+scanidx;
|
||||
assert(scanend == CYCLES_VIS);
|
||||
assert(scanend <= CYCLES_VIS); // HACK FIXME TODO ... this should be '==' ... occasionally glitches with NSCT.dsk ... methinks FLASH interference?
|
||||
_flushScanline(scanline, /*scanrow:*/vCount, scancol, scanend);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user