Check more paths in attempt to satisfy test suite disk insertion

- This is mainly to accommodate disk locations on Android
This commit is contained in:
Aaron Culliney 2015-12-16 21:01:50 -08:00
parent 2c8284d41f
commit 3a20c96296

View File

@ -128,9 +128,10 @@ void test_common_init() {
}
int test_setup_boot_disk(const char *fileName, int readonly) {
char *disk = NULL;
int err = 0;
#ifdef __APPLE__
char **path = NULL;
#if defined(__APPLE__)
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFStringRef fileString = CFStringCreateWithCString(/*allocator*/NULL, fileName, CFStringGetSystemEncoding());
CFURLRef fileURL = CFBundleCopyResourceURL(mainBundle, fileString, NULL, NULL);
@ -144,15 +145,48 @@ int test_setup_boot_disk(const char *fileName, int readonly) {
FREE(disk);
}
CFRELEASE(filePath);
char *paths[] = {
disk,
NULL,
};
#else
asprintf(&disk, "%s/disks/%s", data_dir, fileName);
char *paths[] = {
NULL,
NULL,
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);
#endif
if (disk6_insert(0, disk, readonly)) {
path = &paths[0];
while (*path) {
char *disk = *path;
++path;
err = disk6_insert(0, disk, readonly) != NULL;
if (!err) {
break;
}
int len = strlen(disk);
disk[len-3] = '\0'; // try again without '.gz' extension
err = (disk6_insert(0, disk, readonly) != NULL);
err = disk6_insert(0, disk, readonly) != NULL;
if (!err) {
break;
}
}
FREE(disk);
path = &paths[0];
while (*path) {
char *disk = *path;
++path;
FREE(disk);
}
return err;
}