mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-10 23:29:43 +00:00
Tests running and passing again on iOS devices
This commit is contained in:
parent
59e6c4fabc
commit
4457e9e722
@ -97,7 +97,7 @@ unsupported_for_now
|
|||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
unsupported_for_now
|
unsupported_for_now
|
||||||
#include "TargetConditionals.h"
|
#include "TargetConditionals.h"
|
||||||
#if TARGET_IPHONE_SIMULATOR
|
#if TARGET_OS_SIMULATOR
|
||||||
#elif TARGET_OS_IPHONE
|
#elif TARGET_OS_IPHONE
|
||||||
#elif TARGET_OS_MAC
|
#elif TARGET_OS_MAC
|
||||||
#else
|
#else
|
||||||
|
@ -70,56 +70,80 @@ void test_common_init(void) {
|
|||||||
int test_setup_boot_disk(const char *fileName, int readonly) {
|
int test_setup_boot_disk(const char *fileName, int readonly) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
char **path = NULL;
|
char **path = NULL;
|
||||||
|
const unsigned int pathsCount = 3;
|
||||||
|
char *paths[pathsCount + 1] = {
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
const char *fmts[pathsCount + 1] = {
|
||||||
|
"%s%sdisks/%s",
|
||||||
|
"%s%sdisks/demo/%s",
|
||||||
|
"%s%sdisks/blanks/%s",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
# if TARGET_OS_SIMULATOR || !TARGET_OS_EMBEDDED
|
||||||
CFStringRef fileString = CFStringCreateWithCString(/*allocator*/NULL, fileName, CFStringGetSystemEncoding());
|
const char *prefixPath = "";
|
||||||
CFURLRef fileURL = CFBundleCopyResourceURL(mainBundle, fileString, NULL, NULL);
|
const char *sep = "";
|
||||||
|
# else // TARGET_OS_EMBEDDED
|
||||||
if (!fileURL) {
|
const char *prefixPath = data_dir;
|
||||||
CFRELEASE(fileString);
|
const char *sep = "/";
|
||||||
char *fileName2 = NULL;
|
# endif
|
||||||
ASPRINTF(&fileName2, "disks/demo/%s", fileName);
|
|
||||||
fileString = CFStringCreateWithCString(/*allocator*/NULL, fileName2, CFStringGetSystemEncoding());
|
|
||||||
FREE(fileName2);
|
|
||||||
fileURL = CFBundleCopyResourceURL(mainBundle, fileString, NULL, NULL);
|
|
||||||
if (!fileURL) {
|
|
||||||
CFRELEASE(fileString);
|
|
||||||
ASPRINTF(&fileName2, "disks/blanks/%s", fileName);
|
|
||||||
fileString = CFStringCreateWithCString(/*allocator*/NULL, fileName2, CFStringGetSystemEncoding());
|
|
||||||
FREE(fileName2);
|
|
||||||
fileURL = CFBundleCopyResourceURL(mainBundle, fileString, NULL, NULL);
|
|
||||||
}
|
|
||||||
assert(fileURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
CFStringRef filePath = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
|
|
||||||
CFRELEASE(fileString);
|
|
||||||
CFRELEASE(fileURL);
|
|
||||||
CFIndex length = CFStringGetLength(filePath);
|
|
||||||
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
|
|
||||||
char *disk0 = (char *)MALLOC(maxSize);
|
|
||||||
if (!CFStringGetCString(filePath, disk0, maxSize, kCFStringEncodingUTF8)) {
|
|
||||||
FREE(disk0);
|
|
||||||
}
|
|
||||||
CFRELEASE(filePath);
|
|
||||||
|
|
||||||
char *paths[] = {
|
do {
|
||||||
NULL,
|
|
||||||
NULL,
|
const char **fmtPtr = &fmts[0];
|
||||||
};
|
unsigned int idx = 0;
|
||||||
ASPRINTF(&paths[0], "%s", disk0);
|
while (*fmtPtr) {
|
||||||
FREE(disk0);
|
const char *fmt = *fmtPtr;
|
||||||
#else
|
|
||||||
char *paths[] = {
|
char *diskFile = NULL;
|
||||||
NULL,
|
CFStringRef fileString = NULL;
|
||||||
NULL,
|
CFURLRef fileURL = NULL;
|
||||||
NULL,
|
|
||||||
NULL,
|
ASPRINTF(&diskFile, fmt, prefixPath, sep, fileName);
|
||||||
};
|
assert(diskFile);
|
||||||
ASPRINTF(&paths[0], "%s/disks/%s", data_dir, fileName);
|
fileString = CFStringCreateWithCString(kCFAllocatorDefault, diskFile, kCFStringEncodingUTF8);
|
||||||
ASPRINTF(&paths[1], "%s/disks/demo/%s", data_dir, fileName);
|
assert(fileString);
|
||||||
ASPRINTF(&paths[2], "%s/disks/blanks/%s", data_dir, fileName);
|
|
||||||
|
# if TARGET_OS_SIMULATOR || !TARGET_OS_EMBEDDED
|
||||||
|
// Use disks directly out of bundle ... is this OKAY?
|
||||||
|
fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), fileString, NULL, NULL);
|
||||||
|
# else
|
||||||
|
// AppDelegate should have copied disks to a R/W location
|
||||||
|
fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, fileString, kCFURLPOSIXPathStyle, /*isDirectory*/false);
|
||||||
|
# endif
|
||||||
|
if (fileURL) {
|
||||||
|
CFStringRef filePath = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
|
||||||
|
assert(filePath);
|
||||||
|
CFIndex length = CFStringGetLength(filePath);
|
||||||
|
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
|
||||||
|
char *disk0 = (char *)MALLOC(maxSize);
|
||||||
|
if (CFStringGetCString(filePath, disk0, maxSize, kCFStringEncodingUTF8)) {
|
||||||
|
paths[idx++] = disk0;
|
||||||
|
}
|
||||||
|
CFRELEASE(filePath);
|
||||||
|
CFRELEASE(fileURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
FREE(diskFile);
|
||||||
|
CFRELEASE(fileString);
|
||||||
|
|
||||||
|
++fmtPtr;
|
||||||
|
}
|
||||||
|
} while (0);
|
||||||
|
#else // !__APPLE__
|
||||||
|
do {
|
||||||
|
const char **fmtPtr = &fmts[0];
|
||||||
|
unsigned int idx = 0;
|
||||||
|
while (*fmtPtr) {
|
||||||
|
const char *fmt = *fmtPtr;
|
||||||
|
ASPRINTF(&paths[idx++], fmt, data_dir, "/", fileName);
|
||||||
|
}
|
||||||
|
} while (0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
path = &paths[0];
|
path = &paths[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user