code wiki / _hdl_build / nx_team_build.nx
nx_team_build.nx source
↩ module page · 60 lines · 3282 B
1// nx_team_build.nx -- the TEAM builds and verifies its OWN suite, with the Engineer's
2// recompile-retry discipline, so nobody runs compile/retry by hand. For each capability
3// test it calls eng_build_gate (compile -> link -> run, and on failure RECOMPILE-RETRY
4// because the known-good compiler is non-deterministic), captures the test's own output,
5// and classifies PASS / COMPILE-FAIL / LINK-FAIL / CRASH / FAIL. This is the team's CI:
6// it stands up its whole self-sufficiency ladder itself and reports green. license_tier: ORIGINAL
7
8import "nx_engineer_build_gate.nx"
9
10func tb_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func tb_num(v: i64) -> i64 {
12 let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m }
13 let t: *u8 = sys_mmap(28); var k: i64 = 0
14 if m == 0 { t[0] = 48; k = 1 }
15 while m > 0 { t[k] = 48 + (m % 10); m = m / 10; k = k + 1 }
16 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 }
17 sys_write(1, bb, k); return 0
18}
19func tally(r: *i64, n: i64) -> i64 { var ec: i64 = 0; var i: i64 = 0; while i < n { if r[i] != 1 { if ec == 0 { ec = i + 1 } } i = i + 1 } return ec }
20
21func tb_one(path: *u8, label: *u8, r: *i64, slot: i64) -> i64 {
22 let kg: *u8 = "_offc/nx_cc_known_good.elf" as *u8
23 let out: *i64 = sys_mmap(8 * 4) as *i64
24 let v: i64 = eng_build_gate(kg, path, "/tmp/tb.s" as *u8, "/tmp/tb_h.s" as *u8, "/tmp/tb.elf" as *u8, "/tmp/tb_out.txt" as *u8, out)
25 tb_puts(" build " as *u8); tb_puts(label); tb_puts(" -> " as *u8); tb_puts(ebg_verdict_name(v))
26 if out[2] > 0 { tb_puts(" (recompile-retried " as *u8); tb_num(out[2]); tb_puts("x -- intermittent miscompile recovered)" as *u8) }
27 tb_puts("\n" as *u8)
28 r[slot] = 0; if v == EBG_PASS { r[slot] = 1 }
29 return 0
30}
31
32func tb_run(r: *i64) -> i64 {
33 tb_one("runtime/_hdl_build/nx_ecosystem_test.nx" as *u8, "ecosystem self-model " as *u8, r, 0)
34 tb_one("runtime/_hdl_build/nx_mulchain_test.nx" as *u8, "mulchain escalation " as *u8, r, 1)
35 tb_one("runtime/_hdl_build/nx_autoopt_library_test.nx" as *u8, "autonomous self-close lib" as *u8, r, 2)
36 tb_one("runtime/_hdl_build/nx_selfix_test.nx" as *u8, "self-fix toolkit " as *u8, r, 3)
37 tb_one("runtime/_hdl_build/nx_author_test.nx" as *u8, "author-by-experiment " as *u8, r, 4)
38 tb_one("runtime/_hdl_build/nx_engineer_build_gate_test.nx" as *u8, "engineer managed gate " as *u8, r, 5)
39 return 6
40}
41
42func tb_main(r: *i64) -> i64 {
43 tb_puts("=== TEAM BUILD: the team stands up its OWN suite via the Engineer's recompile-retry discipline ===\n" as *u8)
44 let n: i64 = tb_run(r)
45 var pass: i64 = 0
46 var i: i64 = 0
47 while i < n { if r[i] == 1 { pass = pass + 1 } i = i + 1 }
48 tb_puts("----------------------------------------------------------------\n" as *u8)
49 tb_puts(" team suite: " as *u8); tb_num(pass); tb_puts("/" as *u8); tb_num(n)
50 tb_puts(" green -- built + verified by the team, recompile-retry over the non-deterministic compiler. no me.\n" as *u8)
51 return n
52}
53
54func main() -> i64 {
55 let r: *i64 = sys_mmap(8 * 16) as *i64
56 let n: i64 = tb_main(r)
57 let ec: i64 = tally(r, n)
58 sys_exit(ec)
59 return ec
60}