mirror of
https://github.com/mauiaaron/apple2.git
synced 2026-04-20 10:16:58 +00:00
Streamline and fix test codepaths on Desktop Linux and Android
This commit is contained in:
@@ -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
|
||||
|
||||
+19
-33
@@ -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 ...
|
||||
|
||||
@@ -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 ...
|
||||
|
||||
Reference in New Issue
Block a user