Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/ui/tests/allen_exit_test.c # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / ui / tests / allen_exit_test.c` 78 lines ยท 3110 bytes Raw Blame History 1 /* Host-only production renderer replay. Reuses the delayed-strip test from 2 * imac/shutdown-timeline; no display, power, network or model access. */ 3 #include 4 #include 5 #include 6 #include 7 #include "../allen_ui.c" 8 9 int main(void) 10 { 11 enum { W = 1280, H = 800, P = 1296 }; 12 size_t bytes = ck_allen_ui_mem_bytes(W, H); 13 uint32_t *fb = calloc((size_t)P * H, 4); 14 uint32_t *copy = calloc((size_t)P * H, 4); 15 void *mem = malloc(bytes); 16 assert(mem && fb && copy); 17 assert(!ck_allen_ui_start(fb, W, H, P, 1, mem, bytes, `1000000`, 0, 0)); 18 ck_allen_ui_tick(`16000000`); 19 ck_allen_ui_sleep(1, `17000000`); 20 ck_allen_ui_tick(`17000000`); 21 22 /* Hold a real strip incomplete: no helper may expose half an exit frame. */ 23 ui.t = 17600; 24 advance(ui.t); 25 unsigned n = strips(); 26 assert(n > 1); 27 memcpy(copy, fb, (size_t)P * H * 4); 28 ui.done = 0; 29 __atomic_store_n(&ui.ticket, (uint64_t)n << 16, __ATOMIC_RELEASE); 30 assert(ck_allen_ui_help()); 31 assert(ui.done == 1 && !ck_allen_ui_asleep()); 32 assert(!memcmp(copy, fb, (size_t)P * H * 4)); 33 while (ck_allen_ui_help()) 34 ; 35 assert(ui.done == n); 36 present_exit(n); 37 assert(memcmp(copy, fb, (size_t)P * H * 4)); 38 39 /* Irregular clocks must finish on elapsed time, not on frame count. */ 40 const unsigned at[] = {616, 632, 1000, 1600, 1616, 2400, 2700, 2800}; 41 for (unsigned i = 0; i < sizeof at / sizeof *at; i++) { 42 ck_allen_ui_tick((17000ull + at[i]) * 1000); 43 assert(ck_allen_ui_asleep() == (at[i] >= DUSK_MS)); 44 if (at[i] == 1616) { 45 unsigned pixels = 0; 46 /* ticket carries the actual job count, not stale entries. */ 47 unsigned jobs = (unsigned)(__atomic_load_n(&ui.ticket, __ATOMIC_ACQUIRE) >> 16); 48 pixels = 0; 49 for (unsigned j = 0; j < jobs; j++) 50 pixels += (unsigned)(ui.jobs[j].w * ui.jobs[j].h); 51 assert(pixels < W * H / 10); 52 } 53 } 54 for (unsigned y = 0; y < H; y++) 55 for (unsigned x = 0; x < P; x++) 56 assert(!fb[y * P + x]); 57 unsigned black_frames = ui.frames; 58 assert(!ck_allen_ui_tick(`19816000`) && ui.frames == black_frames && ck_allen_ui_asleep()); 59 fb[0] = 1; 60 ck_allen_ui_refresh(); 61 assert(ck_allen_ui_tick(`19832000`) && !fb[0] && ck_allen_ui_asleep()); 62 ck_allen_ui_sleep(0, `19900000`); 63 assert(!ck_allen_ui_asleep()); 64 assert(ck_allen_ui_tick(`19900000`)); 65 66 /* The UI epoch is a valid exit start, not an inactive sentinel. */ 67 assert(!ck_allen_ui_start(fb, W, H, P, 1, mem, bytes, `1000000`, `1000000`, 0)); 68 ck_allen_ui_sleep(1, `1000000`); 69 assert(ck_allen_ui_tick(`1000000`)); 70 assert(ui.dusk_active && ui.dusk_t == 0 && ui.dim == 0 && !ck_allen_ui_asleep()); 71 assert(ck_allen_ui_tick(`1016000`)); 72 assert(ui.dusk_active && ui.dusk_t == 0 && ui.dim < DIM_FULL && !ck_allen_ui_asleep()); 73 free(mem); 74 free(copy); 75 free(fb); 76 puts("ALLEN_EXIT_TEST: PASS (delayed strip, elapsed timeline, small late redraw, padded black, idle, wake, zero epoch)"); 77 return 0; 78 }