Various test suite improvements

- Possibly breaking changes for mobile ... #willunbreaklater
This commit is contained in:
Aaron Culliney 2016-03-26 14:20:57 -07:00
parent 74a5b74ae3
commit b065da9f4b
11 changed files with 100 additions and 88 deletions

View File

@ -98,65 +98,65 @@ check_PROGRAMS = testcpu testdisplay testvm testdisk testprefs testtrace
#######################################
testcpu_SOURCES = src/test/testcpu.c $(A2_TEST_SOURCES) $(META_SRC)
testcpu_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC
testcpu_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS)
testcpu_CCASFLAGS = $(testcpu_CFLAGS)
testcpu_LDFLAGS = $(apple2ix_LDFLAGS)
testcpu_LDADD = @ASM_O@ @VIDEO_O@
testcpu_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@
testcpu_LDADD = @ASM_O@ @VIDEO_O@ @AUDIO_O@
testcpu_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testcpu_SOURCES = $(ASM_SRC_x86)
#######################################
testdisplay_SOURCES = src/test/testdisplay.c $(A2_TEST_SOURCES) $(META_SRC)
testdisplay_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC
testdisplay_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS)
testdisplay_CCASFLAGS = $(testdisplay_CFLAGS)
testdisplay_LDFLAGS = $(apple2ix_LDFLAGS)
testdisplay_LDADD = @ASM_O@ @VIDEO_O@
testdisplay_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@
testdisplay_LDADD = @ASM_O@ @VIDEO_O@ @AUDIO_O@
testdisplay_DEPENDENCIES = @ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testdisplay_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
#######################################
testvm_SOURCES = src/test/testvm.c $(A2_TEST_SOURCES) $(META_SRC)
testvm_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC
testvm_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS)
testvm_CCASFLAGS = $(testvm_CFLAGS)
testvm_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify TESTVM_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testvm_LDADD = @TESTVM_ASM_O@ @VIDEO_O@
testvm_DEPENDENCIES = @TESTVM_ASM_O@ @META_O@ @VIDEO_O@
testvm_LDADD = @TESTVM_ASM_O@ @VIDEO_O@ @AUDIO_O@
testvm_DEPENDENCIES = @TESTVM_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testvm_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
#######################################
testdisk_SOURCES = src/test/testdisk.c $(A2_TEST_SOURCES) $(META_SRC)
testdisk_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC
testdisk_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS)
testdisk_CCASFLAGS = $(testdisk_CFLAGS)
testdisk_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify testdisk_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testdisk_LDADD = @TESTDISK_ASM_O@ @VIDEO_O@
testdisk_DEPENDENCIES = @TESTDISK_ASM_O@ @META_O@ @VIDEO_O@
testdisk_LDADD = @TESTDISK_ASM_O@ @VIDEO_O@ @AUDIO_O@
testdisk_DEPENDENCIES = @TESTDISK_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testdisk_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
#######################################
testprefs_SOURCES = src/test/testprefs.c $(A2_TEST_SOURCES) $(META_SRC)
testprefs_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC
testprefs_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS)
testprefs_CCASFLAGS = $(testprefs_CFLAGS)
testprefs_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify testprefs_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testprefs_LDADD = @TESTPREFS_ASM_O@ @VIDEO_O@
testprefs_DEPENDENCIES = @TESTPREFS_ASM_O@ @META_O@ @VIDEO_O@
testprefs_LDADD = @TESTPREFS_ASM_O@ @VIDEO_O@ @AUDIO_O@
testprefs_DEPENDENCIES = @TESTPREFS_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testprefs_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)
#######################################
testtrace_SOURCES = src/test/testtrace.c $(A2_TEST_SOURCES) $(META_SRC)
testtrace_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -UAUDIO_ENABLED -UINTERFACE_CLASSIC
testtrace_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS)
testtrace_CCASFLAGS = $(testtrace_CFLAGS)
testtrace_LDFLAGS = $(apple2ix_LDFLAGS)
# HACK FIXME TODO NOTE: specify testtrace_ASM_O to force it to rebuild with proper CCASFLAGS ... automake bug?
testtrace_LDADD = @TESTTRACE_ASM_O@ @VIDEO_O@
testtrace_DEPENDENCIES = @TESTTRACE_ASM_O@ @META_O@ @VIDEO_O@
testtrace_LDADD = @TESTTRACE_ASM_O@ @VIDEO_O@ @AUDIO_O@
testtrace_DEPENDENCIES = @TESTTRACE_ASM_O@ @META_O@ @VIDEO_O@ @AUDIO_O@
EXTRA_testtrace_SOURCES = $(ASM_SRC_x86) $(VIDEO_SRC)

View File

@ -486,9 +486,6 @@ static void video_prefsChanged(const char *domain) {
val = NUM_COLOROPTS-1;
}
color_mode = (color_mode_t)val;
#if TESTING
color_mode = COLOR;
#endif
video_reset();
}
@ -1225,7 +1222,10 @@ void video_shutdown(bool emulatorShuttingDown) {
video_backend->shutdown(emulatorShuttingDown);
render_thread_id = 0;
FREE(video__fb);
if (pthread_self() == render_thread_id) {
FREE(video__fb);
}
}
void video_reshape(int w, int h, bool landscape) {

View File

@ -1146,7 +1146,9 @@ void c_interface_parameters()
video_reset();
vm_reinitializeAudio();
c_joystick_reset();
#if !TESTING
prefs_save();
#endif
c_interface_exit(ch);
break;
}
@ -1271,7 +1273,9 @@ void c_interface_parameters()
ch = toupper(ch);
if (ch == 'Y')
{
#if !TESTING
prefs_save();
#endif
disk6_eject(0);
c_interface_print_screen( screen );
disk6_eject(1);

View File

@ -200,8 +200,7 @@ bool emulator_loadState(const char * const path) {
}
static void _shutdown_threads(void) {
#if !TESTING
# if defined(__linux__) && !defined(ANDROID)
#if defined(__linux__) && !defined(ANDROID)
LOG("Emulator waiting for other threads to clean up...");
do {
DIR *dir = opendir("/proc/self/task");
@ -232,7 +231,6 @@ static void _shutdown_threads(void) {
static struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
nanosleep(&ts, NULL); // 30Hz framerate
} while (1);
# endif
#endif
}
@ -277,14 +275,19 @@ void emulator_start(void) {
#ifdef INTERFACE_CLASSIC
prefs_load(); // user prefs
#if !TESTING
c_keys_set_key(kF8); // show credits before emulation start
#endif
#endif
#if !defined(__APPLE__) && !defined(ANDROID)
video_init();
#endif
timing_startCPU();
#if !TESTING
video_main_loop();
#endif
}
void emulator_shutdown(void) {

View File

@ -20,34 +20,6 @@ static char input_str[TESTBUF_SZ]; // ASCII
static unsigned int input_length = 0;
static unsigned int input_counter = 0;
#if defined(ANDROID)
// We basically compile everything including audio into the Android build, even for testing =)
#else
// ----------------------------------------------------------------------------
// Stub functions because I've reached diminishing returns with the build system ...
//
// NOTE: You'd think the commandline CFLAGS set specifically for this test program would pass down to the sources in
// subdirectories, but it apparently isn't. GNU buildsystem bug? Also see HACK FIXME TODO NOTE in Makefile.am
//
uint8_t c_MB_Read(uint16_t addr) {
return 0x0;
}
void c_MB_Write(uint16_t addr, uint8_t byte) {
}
uint8_t c_PhasorIO(uint16_t addr) {
return 0x0;
}
void c_speaker_toggle(void) {
}
void c_interface_print(int x, int y, const int cs, const char *s) {
}
#endif
// ----------------------------------------------------------------------------
void test_common_setup() {
@ -106,11 +78,13 @@ void test_common_init() {
GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL);
//do_logging = false;// silence regular emulator logging
caps_lock = true;
// kludgey set max CPU speed...
cpu_scale_factor = CPU_SCALE_FASTEST;
cpu_altscale_factor = CPU_SCALE_FASTEST;
prefs_load();
prefs_setBoolValue(PREF_DOMAIN_KEYBOARD, PREF_KEYBOARD_CAPS, true);
prefs_setFloatValue(PREF_DOMAIN_VM, PREF_CPU_SCALE, CPU_SCALE_FASTEST);
prefs_setFloatValue(PREF_DOMAIN_VM, PREF_CPU_SCALE_ALT, CPU_SCALE_FASTEST);
prefs_sync(NULL);
timing_initialize();
c_debugger_set_watchpoint(WATCHPOINT_ADDR);
@ -146,7 +120,7 @@ int test_setup_boot_disk(const char *fileName, int readonly) {
NULL,
NULL,
};
asprintf(&paths[0], "%s", disk0);
ASPRINTF(&paths[0], "%s", disk0);
FREE(disk0);
#else
char *paths[] = {
@ -155,9 +129,9 @@ int test_setup_boot_disk(const char *fileName, int readonly) {
NULL,
NULL,
};
asprintf(&paths[0], "%s/disks/%s", data_dir, fileName);
asprintf(&paths[1], "%s/disks/demo/%s", data_dir, fileName);
asprintf(&paths[2], "%s/disks/blanks/%s", data_dir, fileName);
ASPRINTF(&paths[0], "%s/disks/%s", data_dir, fileName);
ASPRINTF(&paths[1], "%s/disks/demo/%s", data_dir, fileName);
ASPRINTF(&paths[2], "%s/disks/blanks/%s", data_dir, fileName);
#endif
path = &paths[0];

View File

@ -52,7 +52,7 @@ static inline int ASSERT_SHA(const char *SHA_STR) {
const uint8_t * const fb = video_scan();
SHA1(fb, SCANWIDTH*SCANHEIGHT, md);
sha1_to_str(md, mdstr);
ASSERT(strcmp(mdstr, SHA_STR) == 0);
ASSERT(strcasecmp(mdstr, SHA_STR) == 0);
return 0;
}
@ -61,7 +61,7 @@ static inline int ASSERT_SHA_MEM(const char *SHA_STR, uint16_t ea, uint16_t len)
const uint8_t * const mem = &apple_ii_64k[0][ea];
SHA1(mem, len, md);
sha1_to_str(md, mdstr);
ASSERT(strcmp(mdstr, SHA_STR) == 0);
ASSERT(strcasecmp(mdstr, SHA_STR) == 0);
return 0;
}

View File

@ -51,7 +51,7 @@ TEST test_boot_disk_bytes() {
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_read_disk_test.txt", homedir);
ASPRINTF(&disk, "%s/a2_read_disk_test.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(disk, NULL);
@ -99,7 +99,7 @@ TEST test_boot_disk_bytes_nib() {
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_read_disk_test_nib.txt", homedir);
ASPRINTF(&disk, "%s/a2_read_disk_test_nib.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(disk, NULL);
@ -152,7 +152,7 @@ TEST test_boot_disk_bytes_po() {
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_read_disk_test_po.txt", homedir);
ASPRINTF(&disk, "%s/a2_read_disk_test_po.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(disk, NULL);
@ -341,7 +341,7 @@ TEST test_disk_bytes_savehello_dsk() {
srandom(0);
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_write_disk_test_dsk.txt", homedir);
ASPRINTF(&disk, "%s/a2_write_disk_test_dsk.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(NULL, disk);
@ -435,7 +435,7 @@ TEST test_disk_bytes_savehello_nib() {
srandom(0);
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_write_disk_test_nib.txt", homedir);
ASPRINTF(&disk, "%s/a2_write_disk_test_nib.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(NULL, disk);
@ -529,7 +529,7 @@ TEST test_disk_bytes_savehello_po() {
srandom(0);
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_write_disk_test_po.txt", homedir);
ASPRINTF(&disk, "%s/a2_write_disk_test_po.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(NULL, disk);
@ -642,7 +642,7 @@ TEST test_outofspace_dsk() {
srandom(0);
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_oos_dsk_test.txt", homedir);
ASPRINTF(&disk, "%s/a2_oos_dsk_test.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(NULL, disk);
@ -853,7 +853,7 @@ TEST test_bload_trace_dsk() {
srandom(0);
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_bload_trace_test_dsk.txt", homedir);
ASPRINTF(&disk, "%s/a2_bload_trace_test_dsk.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(disk, NULL);
@ -971,7 +971,7 @@ TEST test_bload_trace_nib() {
srandom(0);
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_bload_trace_test_nib.txt", homedir);
ASPRINTF(&disk, "%s/a2_bload_trace_test_nib.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(disk, NULL);
@ -1089,7 +1089,7 @@ TEST test_bload_trace_po() {
srandom(0);
const char *homedir = HOMEDIR;
char *disk = NULL;
asprintf(&disk, "%s/a2_bload_trace_test_po.txt", homedir);
ASPRINTF(&disk, "%s/a2_bload_trace_test_po.txt", homedir);
if (disk) {
unlink(disk);
c_begin_disk_trace_6(disk, NULL);
@ -1496,17 +1496,23 @@ void test_disk(int argc, char **argv) {
pthread_mutex_lock(&interface_mutex);
emulator_start();
test_common_init();
pthread_t p;
pthread_create(&p, NULL, (void *)&test_thread, (void *)NULL);
while (!test_thread_running) {
struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
nanosleep(&ts, NULL);
}
emulator_start();
//pthread_join(p, NULL);
pthread_detach(p);
video_main_loop();
#if !defined(__APPLE__) && !defined(ANDROID)
emulator_shutdown();
#endif
}
#if !defined(__APPLE__) && !defined(ANDROID)

View File

@ -462,17 +462,24 @@ void test_display(int argc, char **argv) {
srandom(time(NULL));
emulator_start();
prefs_setLongValue(PREF_DOMAIN_VIDEO, PREF_COLOR_MODE, COLOR);
test_common_init();
pthread_t p;
pthread_create(&p, NULL, (void *)&test_thread, (void *)NULL);
while (!test_thread_running) {
struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
nanosleep(&ts, NULL);
}
emulator_start();
//pthread_join(p, NULL);
pthread_detach(p);
video_main_loop();
#if !defined(__APPLE__) && !defined(ANDROID)
emulator_shutdown();
#endif
}
#if !defined(__APPLE__) && !defined(ANDROID)

View File

@ -1551,17 +1551,23 @@ void test_prefs(int argc, char **argv) {
pthread_mutex_lock(&interface_mutex);
emulator_start();
test_common_init();
pthread_t p;
pthread_create(&p, NULL, (void *)&test_thread, (void *)NULL);
while (!test_thread_running) {
struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
nanosleep(&ts, NULL);
}
emulator_start();
//pthread_join(p, NULL);
pthread_detach(p);
video_main_loop();
#if !defined(__APPLE__) && !defined(ANDROID)
emulator_shutdown();
#endif
}
#if !defined(__APPLE__) && !defined(ANDROID)

View File

@ -431,17 +431,23 @@ void test_trace(int argc, char **argv) {
test_argc = argc;
test_argv = argv;
emulator_start();
test_common_init();
pthread_t p;
pthread_create(&p, NULL, (void *)&test_thread, (void *)NULL);
while (!test_thread_running) {
struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
nanosleep(&ts, NULL);
}
emulator_start();
//pthread_join(p, NULL);
pthread_detach(p);
video_main_loop();
#if !defined(__APPLE__) && !defined(ANDROID)
emulator_shutdown();
#endif
}
#if !defined(__APPLE__) && !defined(ANDROID)

View File

@ -3439,17 +3439,23 @@ void test_vm(int argc, char **argv) {
test_argc = argc;
test_argv = argv;
emulator_start();
test_common_init();
pthread_t p;
pthread_create(&p, NULL, (void *)&test_thread, (void *)NULL);
while (!test_thread_running) {
struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 };
nanosleep(&ts, NULL);
}
emulator_start();
//pthread_join(p, NULL);
pthread_detach(p);
video_main_loop();
#if !defined(__APPLE__) && !defined(ANDROID)
emulator_shutdown();
#endif
}
#if !defined(__APPLE__) && !defined(ANDROID)