Islet/tests/loadtest.m
astar76 dfecc24142 Add CLAUDE.md and tools/verify for future sessions
tools/verify runs every check that doesn't need an install. The test harness
now holds a keep-awake assertion and a longer limit, because idle phones froze
runs partway through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:55:49 -06:00

22 lines
1.3 KiB
Objective-C

// Loads a tweak dylib into a throwaway process (harmless check that the arm64e slice loads and its constructor runs).
// loadtest <dylib> [seconds]. With ISLET_SELFTEST=<dir> the dylib renders its cards there and exits by itself.
#import <Foundation/Foundation.h>
#import <dlfcn.h>
#import <mach/mach_time.h>
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;
}