code wiki / _hdl_build / nx_estate_census_run.nx

nx_estate_census_run.nx source

↩ module page · 86 lines · 3920 B

1// nx_estate_census_run.nx -- THE ESTATE-WIDE CENSUS ROSTER, ONE COMMAND, ON THE HOST THAT SHIPS. 2// 3// WHY THIS EXISTS 4// --------------- 5// The estate's reachability instruments were laptop-only organs: absent from buildroot entirely, so 6// they could never run on the tree that actually compiles and deploys. Shipping them fixed presence. 7// Presence is not invocation. A deployed binary nobody calls is the estate's own named failure class 8// -- "a gate nobody runs does not degrade to neutral, it degrades to a false sense of coverage, 9// because its existence is counted and its verdict is not." 10// ★★★★★★ AN INSTRUMENT THAT MUST BE REMEMBERED IS AN INSTRUMENT THAT WILL BE FORGOTTEN; PUT IT BEHIND 11// ONE COMMAND AND THE COMMAND ON A BEAT. 12// 13// Each row prints its own verdict and the roster exits non-zero if ANY row failed, so the exit code 14// carries the verdict rather than the reader having to parse prose. 15// 16// usage: nx_estate_census_run 17// exit: 0 all green, 1 one or more red (named above) 18// license_tier: ORIGINAL 19import "nx_gatekit_lib.nx" 20const ECR_MAGIC_1048576: i64 = 1048576 21const ECR_MAGIC_4096: i64 = 4096 22 23const ECR_OFFC: *u8 = "/volume1/homes/elderwesto/nishihost/buildroot/_offc/" 24 25// Run one organ, print PASS/FAIL with its name, accumulate failures. 26func ecr_row(msg: *u8, label: *u8, elf: *u8, a1: *u8, fails: *i64) -> i64 { 27 let out: *u8 = sys_mmap(ECR_MAGIC_1048576) 28 let outlen: *i64 = sys_mmap(16) as *i64 29 let rc: i64 = gk_run_capture(elf, a1, 0 as *u8, 0 as *u8, 0 as *u8, out, ECR_MAGIC_1048576, outlen) 30 var o: i64 = 0 31 if rc == 0 { o = gk_cat(msg, 0, " GREEN " as *u8) } 32 if rc != 0 { o = gk_cat(msg, 0, " RED " as *u8); fails[0] = fails[0] + 1 } 33 o = gk_cat(msg, o, label) 34 o = gk_cat(msg, o, "\n" as *u8) 35 gk_say(msg, o) 36 // echo the organ's own last line -- the summary it chose to end on 37 if outlen[0] > 0 { 38 var s: i64 = outlen[0] - 1 39 if out[s] == (10 as u8) { s = s - 1 } 40 var b: i64 = s 41 var fin: i64 = 0 42 while fin == 0 { 43 if b <= 0 { fin = 1 } 44 if fin == 0 { if out[b] == (10 as u8) { b = b + 1; fin = 1 } else { b = b - 1 } } 45 } 46 var o2: i64 = gk_cat(msg, 0, " " as *u8) 47 var k: i64 = b 48 while k <= s { msg[o2] = out[k]; o2 = o2 + 1; k = k + 1 } 49 msg[o2] = 10 as u8 50 o2 = o2 + 1 51 gk_say(msg, o2) 52 } 53 return rc 54} 55 56func main(argc: i64, argv: *i64) -> i64 { 57 let msg: *u8 = sys_mmap(ECR_MAGIC_1048576) 58 let fails: *i64 = sys_mmap(16) as *i64 59 fails[0] = 0 60 61 var o: i64 = gk_cat(msg, 0, "nx_estate_census_run: the estate-wide census, on the tree that ships\n" as *u8) 62 gk_say(msg, o) 63 64 let p: *u8 = sys_mmap(ECR_MAGIC_4096) 65 var po: i64 = 0 66 67 po = gk_cat(p, 0, ECR_OFFC); po = gk_cat(p, po, "nx_corpus_scan_gate.elf" as *u8); p[po] = 0 as u8 68 ecr_row(msg, "nx_corpus_scan_gate (the DENOMINATOR every census below depends on)" as *u8, p, 0 as *u8, fails) 69 70 po = gk_cat(p, 0, ECR_OFFC); po = gk_cat(p, po, "nx_unwired.elf" as *u8); p[po] = 0 as u8 71 ecr_row(msg, "nx_unwired (defined-and-never-called, whole corpus)" as *u8, p, "--quiet" as *u8, fails) 72 73 po = gk_cat(p, 0, ECR_OFFC); po = gk_cat(p, po, "nx_srclint.elf" as *u8); p[po] = 0 as u8 74 ecr_row(msg, "nx_srclint (cursor-sentinel idiom, whole corpus)" as *u8, p, "--quiet" as *u8, fails) 75 76 po = gk_cat(p, 0, ECR_OFFC); po = gk_cat(p, po, "nx_gatesubj.elf" as *u8); p[po] = 0 as u8 77 ecr_row(msg, "nx_gatesubj (every gate's subject, from the gate's own source)" as *u8, p, 0 as *u8, fails) 78 79 var f: i64 = 0 80 if fails[0] > 0 { f = 1 } 81 var ov: i64 = 0 82 if f == 0 { ov = gk_cat(msg, 0, "\nROSTER: all green\nverdict=GREEN\n" as *u8) } 83 if f == 1 { ov = gk_cat(msg, 0, "\nROSTER: FAILURES ABOVE\nverdict=RED\n" as *u8) } 84 gk_say(msg, ov) 85 return f 86}