mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-02-21 05:29:07 +00:00
Allow loading test images from /sdcard/apple2ix on Android
This commit is contained in:
parent
3de4a181eb
commit
e1f0557b87
@ -67,11 +67,9 @@ void test_common_init(void) {
|
||||
c_debugger_set_timeout(0);
|
||||
}
|
||||
|
||||
int test_setup_boot_disk(const char *fileName, int readonly) {
|
||||
int err = 0;
|
||||
char **path = NULL;
|
||||
#define PATHS_COUNT 8
|
||||
char *paths[PATHS_COUNT + 1] = { 0 };
|
||||
#if defined(__APPLE__)
|
||||
# define PATHS_COUNT 8
|
||||
char **_copy_paths_mac(const char *fileName) {
|
||||
const char *fmts[PATHS_COUNT + 1] = {
|
||||
"%s%sdisks/%s",
|
||||
"%s%sdisks/demo/%s",
|
||||
@ -84,7 +82,9 @@ int test_setup_boot_disk(const char *fileName, int readonly) {
|
||||
NULL,
|
||||
};
|
||||
|
||||
#if defined(__APPLE__)
|
||||
char **paths = CALLOC(1, sizeof(fmts));
|
||||
assert(paths);
|
||||
|
||||
# if TARGET_OS_SIMULATOR || !TARGET_OS_EMBEDDED
|
||||
const char *prefixPath = "";
|
||||
const char *sep = "";
|
||||
@ -150,18 +150,70 @@ int test_setup_boot_disk(const char *fileName, int readonly) {
|
||||
++fmtPtr;
|
||||
}
|
||||
} while (0);
|
||||
#else // !__APPLE__
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
# define PATHS_COUNT 8
|
||||
# if defined(__ANDROID__)
|
||||
# define X_PATHS_COUNT 1
|
||||
# else
|
||||
# define X_PATHS_COUNT 0
|
||||
# endif
|
||||
char **_copy_paths_main(const char *fileName) {
|
||||
|
||||
const char *fmts[PATHS_COUNT + X_PATHS_COUNT + 1] = {
|
||||
"%s/disks/%s",
|
||||
"%s/disks/demo/%s",
|
||||
"%s/disks/blanks/%s",
|
||||
"%s/disks/3rd-party-test/%s",
|
||||
"%s/external-disks/%s",
|
||||
"%s/external-disks/demo/%s",
|
||||
"%s/external-disks/blanks/%s",
|
||||
"%s/external-disks/3rd-party-test/%s",
|
||||
# if defined(__ANDROID__)
|
||||
// extra paths ...
|
||||
"/sdcard/apple2ix/%s",
|
||||
# endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
char **paths = CALLOC(1, sizeof(fmts));
|
||||
assert(paths);
|
||||
|
||||
do {
|
||||
const char *fmt = NULL;
|
||||
const char **fmtPtr = &fmts[0];
|
||||
unsigned int idx = 0;
|
||||
while (*fmtPtr) {
|
||||
const char *fmt = *fmtPtr++;
|
||||
ASPRINTF(&paths[idx++], fmt, data_dir, "/", fileName);
|
||||
fmt = *fmtPtr++;
|
||||
if (idx < PATHS_COUNT) {
|
||||
ASPRINTF(&paths[idx++], fmt, data_dir, fileName);
|
||||
} else {
|
||||
ASPRINTF(&paths[idx++], fmt, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
} while (0);
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
path = &paths[0];
|
||||
int test_setup_boot_disk(const char *fileName, int readonly) {
|
||||
|
||||
#if defined(__APPLE__)
|
||||
char **paths = _copy_paths_mac(fileName);
|
||||
#else
|
||||
char **paths = _copy_paths_main(fileName);
|
||||
#endif
|
||||
|
||||
int err = 0;
|
||||
|
||||
char **path = &paths[0];
|
||||
while (*path) {
|
||||
char *disk = *path;
|
||||
++path;
|
||||
@ -195,6 +247,8 @@ int test_setup_boot_disk(const char *fileName, int readonly) {
|
||||
FREE(disk);
|
||||
}
|
||||
|
||||
FREE(paths);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1376,6 +1376,46 @@ TEST test_data_stability_po() {
|
||||
PASS();
|
||||
}
|
||||
|
||||
#define GZBAD_NIB "testgzheader.nib"
|
||||
#define GZBAD_NIB_LOAD_SHA1 "98EB8D2EF486E5BF888789A6FF9D4E3DEC7902B7"
|
||||
#define GZBAD_NIB_LOAD_SHA2 "764F580287564B5464BF98BC2026E110F06C9EA4"
|
||||
static int _test_disk_image_with_gzip_header(int readonly) {
|
||||
|
||||
test_setup_boot_disk(GZBAD_NIB, readonly);
|
||||
|
||||
ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] != TEST_FINISHED);
|
||||
c_debugger_go();
|
||||
ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED);
|
||||
|
||||
test_type_input("CLEAR\r");
|
||||
|
||||
c_debugger_set_timeout(2);
|
||||
c_debugger_go();
|
||||
c_debugger_set_timeout(0);
|
||||
|
||||
do {
|
||||
uint8_t md[SHA_DIGEST_LENGTH];
|
||||
const uint8_t * const fb = video_scan();
|
||||
SHA1(fb, SCANWIDTH*SCANHEIGHT, md);
|
||||
sha1_to_str(md, mdstr);
|
||||
bool matches_sha1 = (strcasecmp(mdstr, GZBAD_NIB_LOAD_SHA1) == 0);
|
||||
bool matches_sha2 = (strcasecmp(mdstr, GZBAD_NIB_LOAD_SHA2) == 0);
|
||||
ASSERT(matches_sha1 || matches_sha2);
|
||||
} while(0);
|
||||
|
||||
disk6_eject(0);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
TEST test_disk_image_with_gzip_header_ro() {
|
||||
return _test_disk_image_with_gzip_header(/*readonly:*/1);
|
||||
}
|
||||
|
||||
TEST test_disk_image_with_gzip_header_rw() {
|
||||
return _test_disk_image_with_gzip_header(/*readonly:*/0);
|
||||
}
|
||||
|
||||
#if TEST_DISK_EDGE_CASES
|
||||
#define DROL_DSK "Drol.dsk.gz"
|
||||
#define DROL_CRACK_SCREEN_SHA "FD7332529E117F14DA3880BB36FE8E23C3704799"
|
||||
@ -1463,6 +1503,9 @@ GREATEST_SUITE(test_suite_disk) {
|
||||
RUN_TESTp(test_data_stability_nib);
|
||||
RUN_TESTp(test_data_stability_po);
|
||||
|
||||
RUN_TESTp(test_disk_image_with_gzip_header_ro);
|
||||
RUN_TESTp(test_disk_image_with_gzip_header_rw);
|
||||
|
||||
// edge-case tests may require testing copyrighted images (which I have in my possession by legally owning the
|
||||
// original disk image (yep, I do ;-)
|
||||
#if TEST_DISK_EDGE_CASES
|
||||
|
Loading…
x
Reference in New Issue
Block a user