// Loads a tweak dylib into a throwaway process (harmless check that the arm64e slice loads and its constructor runs). // loadtest [seconds]. With ISLET_SELFTEST= the dylib renders its cards there and exits by itself. #import #import #import int main(int argc, char **argv) { @autoreleasepool { // An idle phone sleeps with its screen off and freezes this process mid-run, so hold it awake while it works. void *iokit = dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_NOW); int (*assertion)(CFStringRef, uint32_t, CFStringRef, uint32_t *) = iokit ? dlsym(iokit, "IOPMAssertionCreateWithName") : NULL; uint32_t held = 0; CFStringRef kind = CFStringCreateWithCString(NULL, "NoIdleSleepAssertion", kCFStringEncodingUTF8), why = CFStringCreateWithCString(NULL, "Islet test", kCFStringEncodingUTF8); int rc = assertion ? assertion(kind, 255, why, &held) : -1; printf("keep awake: %s\n", rc == 0 ? "held" : "not held"); void *h = dlopen(argv[1], RTLD_NOW); printf("dlopen: %s\n", h ? "ok" : dlerror()); if (!h) return 1; [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:argc > 2 ? atof(argv[2]) : 4]]; printf("PASS\n"); } return 0; }