mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-18 03:29:31 +00:00
Streamline and fix test codepaths on Desktop Linux and Android
This commit is contained in:
parent
9c1cfedf7d
commit
2a405f028f
|
@ -89,12 +89,14 @@ fi
|
|||
|
||||
if test "$(basename $0)" = "testcpu" ; then
|
||||
ln -s testcpu.mk Android.mk
|
||||
elif test "$(basename $0)" = "testvm" ; then
|
||||
ln -s testvm.mk Android.mk
|
||||
elif test "$(basename $0)" = "testdisplay" ; then
|
||||
ln -s testdisplay.mk Android.mk
|
||||
elif test "$(basename $0)" = "testdisk" ; then
|
||||
ln -s testdisk.mk Android.mk
|
||||
elif test "$(basename $0)" = "testdisplay" ; then
|
||||
ln -s testdisplay.mk Android.mk
|
||||
elif test "$(basename $0)" = "testprefs" ; then
|
||||
ln -s testprefs.mk Android.mk
|
||||
elif test "$(basename $0)" = "testvm" ; then
|
||||
ln -s testvm.mk Android.mk
|
||||
else
|
||||
ln -s apple2ix.mk Android.mk
|
||||
fi
|
||||
|
|
|
@ -47,8 +47,7 @@ typedef enum lifecycle_seq_t {
|
|||
static lifecycle_seq_t appState = APP_RUNNING;
|
||||
|
||||
#if TESTING
|
||||
static bool running_tests = false;
|
||||
static void _run_tests(void) {
|
||||
static void _start_tests(void) {
|
||||
char *local_argv[] = {
|
||||
"-f",
|
||||
NULL
|
||||
|
@ -57,20 +56,23 @@ static void _run_tests(void) {
|
|||
for (char **p = &local_argv[0]; *p != NULL; p++) {
|
||||
++local_argc;
|
||||
}
|
||||
#if defined(TEST_CPU)
|
||||
#if TEST_CPU
|
||||
// Currently this test is the only one that runs as a black screen
|
||||
extern int test_cpu(int, char *[]);
|
||||
test_cpu(local_argc, local_argv);
|
||||
tkill(getpid(), SIGKILL); // and we're done ...
|
||||
#elif defined(TEST_VM)
|
||||
extern int test_vm(int, char *[]);
|
||||
#elif TEST_VM
|
||||
extern void test_vm(int, char *[]);
|
||||
test_vm(local_argc, local_argv);
|
||||
#elif defined(TEST_DISPLAY)
|
||||
extern int test_display(int, char *[]);
|
||||
#elif TEST_DISPLAY
|
||||
extern void test_display(int, char *[]);
|
||||
test_display(local_argc, local_argv);
|
||||
#elif defined(TEST_DISK)
|
||||
extern int test_disk(int, char *[]);
|
||||
#elif TEST_DISK
|
||||
extern void test_disk(int, char *[]);
|
||||
test_disk(local_argc, local_argv);
|
||||
#elif TEST_PREFS
|
||||
extern void test_prefs(int, char *[]);
|
||||
test_prefs(local_argc, local_argv);
|
||||
#else
|
||||
# error "OOPS, no tests specified"
|
||||
#endif
|
||||
|
@ -167,7 +169,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jclas
|
|||
ASPRINTF(&home, "HOME=%s", data_dir);
|
||||
if (home) {
|
||||
putenv(home);
|
||||
// leak...
|
||||
LEAK(home);
|
||||
}
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, j_dataDir, dataDir);
|
||||
|
@ -188,14 +190,11 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jclas
|
|||
FREE(trfile);
|
||||
#endif
|
||||
|
||||
#if TESTING
|
||||
cpu_scale_factor = CPU_SCALE_FASTEST;
|
||||
cpu_altscale_factor = CPU_SCALE_FASTEST;
|
||||
timing_initialize();
|
||||
#else
|
||||
cpu_pause();
|
||||
emulator_start();
|
||||
#if TESTING
|
||||
_start_tests();
|
||||
#endif
|
||||
emulator_start();
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsInitialized(JNIEnv *env, jclass cls) {
|
||||
|
@ -206,20 +205,11 @@ void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsInitialized(JNIEnv *env
|
|||
}
|
||||
|
||||
jboolean Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationResume(JNIEnv *env, jclass cls) {
|
||||
#if TESTING
|
||||
// test driver thread is managing CPU
|
||||
if (!running_tests) {
|
||||
running_tests = true;
|
||||
assert(cpu_thread_id == 0 && "CPU thread must not be initialized yet...");
|
||||
_run_tests();
|
||||
}
|
||||
#else
|
||||
if (!cpu_isPaused()) {
|
||||
return false;
|
||||
}
|
||||
LOG("...");
|
||||
cpu_resume();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -241,12 +231,8 @@ jboolean Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationPause(JNIEnv *
|
|||
}
|
||||
LOG("...");
|
||||
|
||||
#if TESTING
|
||||
// test driver thread is managing CPU
|
||||
#else
|
||||
cpu_pause();
|
||||
prefs_save();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -289,9 +275,6 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeReboot(JNIEnv *env, jclass
|
|||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnQuit(JNIEnv *env, jclass cls) {
|
||||
#if TESTING
|
||||
// test driver thread is managing CPU
|
||||
#else
|
||||
appState = APP_REQUESTED_SHUTDOWN;
|
||||
|
||||
LOG("...");
|
||||
|
@ -301,7 +284,6 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnQuit(JNIEnv *env, jclass
|
|||
#endif
|
||||
|
||||
cpu_resume();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnKeyDown(JNIEnv *env, jclass cls, jint keyCode, jint metaState) {
|
||||
|
@ -348,6 +330,10 @@ jlong Java_org_deadc0de_apple2ix_Apple2View_nativeOnTouch(JNIEnv *env, jclass cl
|
|||
}
|
||||
|
||||
void Java_org_deadc0de_apple2ix_Apple2DisksMenu_nativeChooseDisk(JNIEnv *env, jclass cls, jstring jPath, jboolean driveA, jboolean readOnly) {
|
||||
#if TESTING
|
||||
return;
|
||||
#endif
|
||||
|
||||
const char *path = (*env)->GetStringUTFChars(env, jPath, NULL);
|
||||
int drive = driveA ? 0 : 1;
|
||||
int ro = readOnly ? 1 : 0;
|
||||
|
|
|
@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
|
|||
|
||||
LOCAL_MODULE := libapple2ix
|
||||
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testcpu.c
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_CPU -DTESTING=1
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_CPU=1 -DTESTING=1
|
||||
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
|
||||
|
||||
# Add assembly files first ... mostly for the benefit of the ARM assembler ...
|
||||
|
|
|
@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
|
|||
|
||||
LOCAL_MODULE := libapple2ix
|
||||
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testdisk.c
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_DISK -DTESTING=1 -DDISK_TRACING=1
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_DISK=1 -DTESTING=1 -DDISK_TRACING=1
|
||||
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
|
||||
|
||||
# Add assembly files first ... mostly for the benefit of the ARM assembler ...
|
||||
|
|
|
@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
|
|||
|
||||
LOCAL_MODULE := libapple2ix
|
||||
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testdisplay.c
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_DISPLAY -DTESTING=1
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_DISPLAY=1 -DTESTING=1
|
||||
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
|
||||
|
||||
# Add assembly files first ... mostly for the benefit of the ARM assembler ...
|
||||
|
|
34
Android/jni/testprefs.mk
Normal file
34
Android/jni/testprefs.mk
Normal file
|
@ -0,0 +1,34 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
PACKAGE_IDENTIFIER := "org.deadc0de.apple2ix"
|
||||
PACKAGE_NAME := "apple2ix"
|
||||
COMMON_SOURCES_MK := $(LOCAL_PATH)/sources.mk
|
||||
include $(COMMON_SOURCES_MK)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Android build config
|
||||
|
||||
LOCAL_MODULE := libapple2ix
|
||||
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testprefs.c
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_PREFS=1 -DTESTING=1
|
||||
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
|
||||
|
||||
# Add assembly files first ... mostly for the benefit of the ARM assembler ...
|
||||
ifeq ($(TARGET_ARCH_ABI),x86)
|
||||
LOCAL_SRC_FILES += $(APPLE2_X86_SRC)
|
||||
LOCAL_CFLAGS += -DNO_UNDERSCORES=1
|
||||
else
|
||||
LOCAL_SRC_FILES += $(APPLE2_ARM_SRC)
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES += $(APPLE2_MAIN_SRC) $(APPLE2_META_SRC) $(APPLE2_VIDEO_SRC) $(APPLE2_AUDIO_SRC)
|
||||
|
||||
# Build a shared library and let Java/Dalvik drive
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
# --OR-- Build an executable so native can drive this show
|
||||
#include $(BUILD_EXECUTABLE)
|
||||
|
||||
$(call import-module, android/cpufeatures)
|
|
@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
|
|||
|
||||
LOCAL_MODULE := libapple2ix
|
||||
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testvm.c
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_VM -DTESTING=1
|
||||
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_VM=1 -DTESTING=1
|
||||
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
|
||||
|
||||
# Add assembly files first ... mostly for the benefit of the ARM assembler ...
|
||||
|
|
12
Makefile.am
12
Makefile.am
|
@ -98,7 +98,7 @@ 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)
|
||||
testcpu_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_CPU=1
|
||||
testcpu_CCASFLAGS = $(testcpu_CFLAGS)
|
||||
testcpu_LDFLAGS = $(apple2ix_LDFLAGS)
|
||||
testcpu_LDADD = @ASM_O@ @VIDEO_O@ @AUDIO_O@
|
||||
|
@ -108,7 +108,7 @@ EXTRA_testcpu_SOURCES = $(ASM_SRC_x86)
|
|||
|
||||
#######################################
|
||||
testdisplay_SOURCES = src/test/testdisplay.c $(A2_TEST_SOURCES) $(META_SRC)
|
||||
testdisplay_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS)
|
||||
testdisplay_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_DISPLAY=1
|
||||
testdisplay_CCASFLAGS = $(testdisplay_CFLAGS)
|
||||
testdisplay_LDFLAGS = $(apple2ix_LDFLAGS)
|
||||
testdisplay_LDADD = @ASM_O@ @VIDEO_O@ @AUDIO_O@
|
||||
|
@ -118,7 +118,7 @@ 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)
|
||||
testvm_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_VM=1
|
||||
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?
|
||||
|
@ -129,7 +129,7 @@ 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)
|
||||
testdisk_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_DISK=1
|
||||
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?
|
||||
|
@ -140,7 +140,7 @@ 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)
|
||||
testprefs_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_PREFS=1
|
||||
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?
|
||||
|
@ -151,7 +151,7 @@ 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)
|
||||
testtrace_CFLAGS = $(apple2ix_CFLAGS) $(A2_TEST_CFLAGS) -DTEST_TRACE=1
|
||||
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?
|
||||
|
|
|
@ -21,6 +21,13 @@
|
|||
(ptr) = NULL; \
|
||||
} while (0)
|
||||
|
||||
// A way to formalize intentional leaks
|
||||
#define LEAK(ptr) \
|
||||
do { \
|
||||
/* WARNING : code may depend on NULLification, even in release builds */ \
|
||||
(ptr) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define MALLOC(size) malloc((size))
|
||||
# define CALLOC(nmemb, size) calloc((nmemb), (size))
|
||||
|
|
44
src/misc.c
44
src/misc.c
|
@ -261,8 +261,7 @@ void emulator_registerStartupCallback(long order, startup_callback_f ctor) {
|
|||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void emulator_start(void) {
|
||||
|
||||
void emulator_ctors(void) {
|
||||
module_ctor_node_s *p = head;
|
||||
head = NULL;
|
||||
while (p) {
|
||||
|
@ -272,23 +271,24 @@ void emulator_start(void) {
|
|||
p = next;
|
||||
}
|
||||
head = NULL;
|
||||
}
|
||||
|
||||
void emulator_start(void) {
|
||||
|
||||
emulator_ctors();
|
||||
|
||||
#if defined(INTERFACE_CLASSIC) && !TESTING
|
||||
cpu_pause();
|
||||
prefs_load(); // user prefs
|
||||
prefs_sync(NULL);
|
||||
cpu_resume();
|
||||
|
||||
#if defined(INTERFACE_CLASSIC) && !TESTING
|
||||
c_keys_set_key(kF8); // show credits before emulation start
|
||||
#endif
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
video_init();
|
||||
#endif
|
||||
timing_startCPU();
|
||||
|
||||
#if !TESTING
|
||||
video_main_loop();
|
||||
#endif
|
||||
timing_startCPU();
|
||||
}
|
||||
|
||||
void emulator_shutdown(void) {
|
||||
|
@ -300,14 +300,36 @@ void emulator_shutdown(void) {
|
|||
_shutdown_threads();
|
||||
}
|
||||
|
||||
#if !TESTING && !defined(__APPLE__) && !defined(ANDROID)
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
int main(int _argc, char **_argv) {
|
||||
argc = _argc;
|
||||
argv = _argv;
|
||||
|
||||
#if TESTING
|
||||
# if TEST_CPU
|
||||
// Currently this test is the only one that blocks current thread and runs as a black screen
|
||||
extern int test_cpu(int, char *[]);
|
||||
test_cpu(argc, argv);
|
||||
# elif TEST_VM
|
||||
extern int test_vm(int, char *[]);
|
||||
test_vm(argc, argv);
|
||||
# elif TEST_DISPLAY
|
||||
extern int test_display(int, char *[]);
|
||||
test_display(argc, argv);
|
||||
# elif TEST_DISK
|
||||
extern int test_disk(int, char *[]);
|
||||
test_disk(argc, argv);
|
||||
#elif TEST_PREFS
|
||||
extern void test_prefs(int, char *[]);
|
||||
test_prefs(argc, argv);
|
||||
# else
|
||||
# error "OOPS, no testsuite specified"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
emulator_start();
|
||||
|
||||
// main loop ...
|
||||
video_main_loop();
|
||||
|
||||
emulator_shutdown();
|
||||
|
||||
|
|
|
@ -77,15 +77,23 @@ void test_breakpoint(void *arg) {
|
|||
void test_common_init() {
|
||||
GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL);
|
||||
|
||||
//do_logging = false;// silence regular emulator logging
|
||||
do_logging = false;// silence regular emulator logging
|
||||
|
||||
extern void emulator_ctors(void);
|
||||
emulator_ctors();
|
||||
|
||||
char *envvar = NULL;
|
||||
ASPRINTF(&envvar, "APPLE2IX_JSON=%s/.apple2.test.json", getenv("HOME"));
|
||||
assert(envvar);
|
||||
putenv(envvar);
|
||||
LEAK(envvar);
|
||||
|
||||
prefs_load();
|
||||
prefs_setLongValue(PREF_DOMAIN_VIDEO, PREF_COLOR_MODE, COLOR);
|
||||
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();
|
||||
prefs_save();
|
||||
|
||||
c_debugger_set_watchpoint(WATCHPOINT_ADDR);
|
||||
if (0) {
|
||||
|
|
|
@ -8056,8 +8056,3 @@ int test_cpu(int argc, char **argv) {
|
|||
GREATEST_MAIN_END();
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
int main(int argc, char **argv) {
|
||||
test_cpu(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1414,12 +1414,15 @@ TEST test_reinsert_edgecase() {
|
|||
// Test Suite
|
||||
|
||||
GREATEST_SUITE(test_suite_disk) {
|
||||
test_thread_running = true;
|
||||
|
||||
pthread_mutex_lock(&interface_mutex);
|
||||
|
||||
GREATEST_SET_SETUP_CB(testdisk_setup, NULL);
|
||||
GREATEST_SET_TEARDOWN_CB(testdisk_teardown, NULL);
|
||||
GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL);
|
||||
|
||||
// TESTS --------------------------
|
||||
test_thread_running = true;
|
||||
|
||||
RUN_TESTp(test_boot_disk_bytes);
|
||||
RUN_TESTp(test_boot_disk_bytes_nib);
|
||||
|
@ -1490,13 +1493,9 @@ static void *test_thread(void *dummyptr) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void test_disk(int argc, char **argv) {
|
||||
test_argc = argc;
|
||||
test_argv = argv;
|
||||
|
||||
pthread_mutex_lock(&interface_mutex);
|
||||
|
||||
emulator_start();
|
||||
void test_disk(int _argc, char **_argv) {
|
||||
test_argc = _argc;
|
||||
test_argv = _argv;
|
||||
|
||||
test_common_init();
|
||||
|
||||
|
@ -1507,16 +1506,5 @@ void test_disk(int argc, char **argv) {
|
|||
nanosleep(&ts, NULL);
|
||||
}
|
||||
pthread_detach(p);
|
||||
|
||||
video_main_loop();
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
emulator_shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
int main(int argc, char **argv) {
|
||||
test_disk(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -321,6 +321,8 @@ TEST test_80col_hires() {
|
|||
// Test Suite
|
||||
|
||||
GREATEST_SUITE(test_suite_display) {
|
||||
test_thread_running = true;
|
||||
|
||||
pthread_mutex_lock(&interface_mutex);
|
||||
|
||||
GREATEST_SET_SETUP_CB(testdisplay_setup, NULL);
|
||||
|
@ -328,7 +330,6 @@ GREATEST_SUITE(test_suite_display) {
|
|||
GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL);
|
||||
|
||||
// TESTS --------------------------
|
||||
test_thread_running = true;
|
||||
|
||||
RUN_TESTp(test_boot_disk);
|
||||
|
||||
|
@ -456,15 +457,12 @@ static void *test_thread(void *dummyptr) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void test_display(int argc, char **argv) {
|
||||
test_argc = argc;
|
||||
test_argv = argv;
|
||||
void test_display(int _argc, char **_argv) {
|
||||
test_argc = _argc;
|
||||
test_argv = _argv;
|
||||
|
||||
srandom(time(NULL));
|
||||
|
||||
emulator_start();
|
||||
|
||||
prefs_setLongValue(PREF_DOMAIN_VIDEO, PREF_COLOR_MODE, COLOR);
|
||||
test_common_init();
|
||||
|
||||
pthread_t p;
|
||||
|
@ -474,16 +472,5 @@ void test_display(int argc, char **argv) {
|
|||
nanosleep(&ts, NULL);
|
||||
}
|
||||
pthread_detach(p);
|
||||
|
||||
video_main_loop();
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
emulator_shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
int main(int argc, char **argv) {
|
||||
test_display(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -271,10 +271,12 @@ TEST test_json_serialization() {
|
|||
int tokCount = json_createFromString(testMapStr0, &parsedData);
|
||||
ASSERT(tokCount > 0);
|
||||
|
||||
char *str = STRDUP("/tmp/json-XXXXXX");
|
||||
int fd = mkstemp(str);
|
||||
char *tmpFile = NULL;
|
||||
ASPRINTF(&tmpFile, "%s/json-XXXXXX", getenv("HOME"));
|
||||
ASSERT(tmpFile);
|
||||
int fd = mkstemp(tmpFile);
|
||||
ASSERT(fd > 0);
|
||||
FREE(str);
|
||||
FREE(tmpFile);
|
||||
|
||||
json_serialize(parsedData, fd, /*pretty:*/false);
|
||||
json_destroy(&parsedData);
|
||||
|
@ -301,10 +303,12 @@ TEST test_json_serialization_pretty() {
|
|||
ASSERT(tokCount > 0);
|
||||
ASSERT(parsedData);
|
||||
|
||||
char *str = STRDUP("/tmp/json-pretty-XXXXXX");
|
||||
int fd = mkstemp(str);
|
||||
char *tmpFile = NULL;
|
||||
ASPRINTF(&tmpFile, "%s/json-pretty-XXXXXX", getenv("HOME"));
|
||||
ASSERT(tmpFile);
|
||||
int fd = mkstemp(tmpFile);
|
||||
ASSERT(fd > 0);
|
||||
FREE(str);
|
||||
FREE(tmpFile);
|
||||
|
||||
ok = json_serialize(parsedData, fd, /*pretty:*/true);
|
||||
ASSERT(ok);
|
||||
|
@ -1890,8 +1894,18 @@ TEST test_prefs_set_props() {
|
|||
#define EXPECTED_TEST_PREFS_FILE_SIZE 178
|
||||
#define EXPECTED_TEST_PREFS_SHA "263844f0177a9229eece7907cd9f6f72aef535f5"
|
||||
TEST test_prefs_load_and_save() {
|
||||
unlink(TEST_JSON);
|
||||
putenv("APPLE2IX_JSON=" TEST_JSON);
|
||||
|
||||
char *apple2JSON = NULL;
|
||||
ASPRINTF(&apple2JSON, "%s/%s", getenv("HOME"), TEST_JSON);
|
||||
ASSERT(apple2JSON);
|
||||
unlink(apple2JSON);
|
||||
|
||||
char *apple2JSONEnv = NULL;
|
||||
ASPRINTF(&apple2JSONEnv, "APPLE2IX_JSON=%s/%s", getenv("HOME"), TEST_JSON);
|
||||
ASSERT(apple2JSONEnv);
|
||||
putenv(apple2JSONEnv);
|
||||
LEAK(apple2JSONEnv);
|
||||
|
||||
prefs_load();
|
||||
prefs_sync(NULL);
|
||||
prefs_save();
|
||||
|
@ -1947,7 +1961,7 @@ TEST test_prefs_load_and_save() {
|
|||
uint8_t md[SHA_DIGEST_LENGTH];
|
||||
char mdstr0[(SHA_DIGEST_LENGTH*2)+1];
|
||||
|
||||
FILE *fp = fopen(TEST_JSON, "r");
|
||||
FILE *fp = fopen(apple2JSON, "r");
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
long expectedSize = ftell(fp);
|
||||
|
@ -1966,7 +1980,8 @@ TEST test_prefs_load_and_save() {
|
|||
ASSERT(strcasecmp(mdstr0, EXPECTED_TEST_PREFS_SHA) == 0);
|
||||
} while(0);
|
||||
|
||||
unlink(TEST_JSON);
|
||||
unlink(apple2JSON);
|
||||
FREE(apple2JSON);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
@ -1975,12 +1990,15 @@ TEST test_prefs_load_and_save() {
|
|||
// Test Suite
|
||||
|
||||
GREATEST_SUITE(test_suite_prefs) {
|
||||
test_thread_running = true;
|
||||
|
||||
pthread_mutex_lock(&interface_mutex);
|
||||
|
||||
GREATEST_SET_SETUP_CB(testprefs_setup, NULL);
|
||||
GREATEST_SET_TEARDOWN_CB(testprefs_teardown, NULL);
|
||||
//GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL);
|
||||
|
||||
// TESTS --------------------------
|
||||
test_thread_running = true;
|
||||
|
||||
RUN_TESTp(test_json_map_1);
|
||||
|
||||
|
@ -2051,13 +2069,9 @@ static void *test_thread(void *dummyptr) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void test_prefs(int argc, char **argv) {
|
||||
test_argc = argc;
|
||||
test_argv = argv;
|
||||
|
||||
pthread_mutex_lock(&interface_mutex);
|
||||
|
||||
emulator_start();
|
||||
void test_prefs(int _argc, char **_argv) {
|
||||
test_argc = _argc;
|
||||
test_argv = _argv;
|
||||
|
||||
test_common_init();
|
||||
|
||||
|
@ -2068,16 +2082,5 @@ void test_prefs(int argc, char **argv) {
|
|||
nanosleep(&ts, NULL);
|
||||
}
|
||||
pthread_detach(p);
|
||||
|
||||
video_main_loop();
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
emulator_shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
int main(int argc, char **argv) {
|
||||
test_prefs(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -3222,6 +3222,8 @@ TEST test_check_cxrom(bool flag_cxrom) {
|
|||
// Test Suite
|
||||
|
||||
GREATEST_SUITE(test_suite_vm) {
|
||||
test_thread_running=true;
|
||||
|
||||
pthread_mutex_lock(&interface_mutex);
|
||||
|
||||
GREATEST_SET_SETUP_CB(testvm_setup, NULL);
|
||||
|
@ -3229,7 +3231,6 @@ GREATEST_SUITE(test_suite_vm) {
|
|||
GREATEST_SET_BREAKPOINT_CB(test_breakpoint, NULL);
|
||||
|
||||
// TESTS --------------------------
|
||||
test_thread_running=true;
|
||||
|
||||
RUN_TESTp(test_boot_disk);
|
||||
|
||||
|
@ -3435,11 +3436,9 @@ static void *test_thread(void *dummyptr) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void test_vm(int argc, char **argv) {
|
||||
test_argc = argc;
|
||||
test_argv = argv;
|
||||
|
||||
emulator_start();
|
||||
void test_vm(int _argc, char **_argv) {
|
||||
test_argc = _argc;
|
||||
test_argv = _argv;
|
||||
|
||||
test_common_init();
|
||||
|
||||
|
@ -3450,16 +3449,5 @@ void test_vm(int argc, char **argv) {
|
|||
nanosleep(&ts, NULL);
|
||||
}
|
||||
pthread_detach(p);
|
||||
|
||||
video_main_loop();
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
emulator_shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && !defined(ANDROID)
|
||||
int main(int argc, char **argv) {
|
||||
test_vm(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user