code wiki / _hdl_build / nx_sim_suite_gate.nx
nx_sim_suite_gate.nx source
↩ module page · 89 lines · 4879 B
1import "nx_gate_gn.nx"
2import "nx_gate_base.nx"
3// nx_sim_suite_gate.nx -- SOVEREIGN regression suite for the whole S-class simulation-credibility program: it
4// re-runs every member gate (credibility census + the 6 climbed axes + the browser sim native + wasm-VM run)
5// via sys_fork/sys_execve/sys_wait4 through the sovereign runner -- NO shell (same idiom as nx_gate_sweep). The
6// per-gate verdict rides the EXIT CODE (0=GREEN), so no text to grep. It then APPENDS a run record to
7// knowledge/status/sim_suite.log (sovereign sys_openat_append) -- the re-runnable verification suite + accruing
8// run history that NASA-STD-7009 (M&S Management / Use History) and IEC 62304 expect. GREEN iff every member GREEN.
9// CWD must be nxc2. license_tier: ORIGINAL expect_exit: 0
10import "nx_syscalls.nx"
11
12const RUNNER: *u8 = "_offc/nx_sov_build_run.elf"
13
14func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
15" as *u8); return ok }
16
17func run_gate(name: *u8) -> i64 {
18 let pid: i64 = sys_fork()
19 if pid == 0 {
20 let dn: i64 = sys_openat_wr("/dev/null\x00" as *u8, 420)
21 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
22 let argv: *i64 = sys_mmap(64) as *i64
23 argv[0] = RUNNER as i64; argv[1] = name as i64; argv[2] = 0
24 let envp: *i64 = sys_mmap(16) as *i64
25 envp[0] = "PATH=/usr/bin:/bin\x00" as *u8 as i64; envp[1] = 0
26 sys_execve(RUNNER, argv, envp)
27 sys_exit(127)
28 }
29 let st: *i64 = sys_mmap(16) as *i64
30 sys_wait4(pid, st, 0)
31 return (st[0] >> 8) & 0xff
32}
33func report(name: *u8, tally: *i64) -> i64 {
34 let code: i64 = run_gate(name)
35 gw(" "); gw(name); gw(": ")
36 if code == 0 { gw("GREEN\n"); tally[0] = tally[0] + 1 } else { gw("RED (exit "); gn(code); gw(")\n"); tally[1] = tally[1] + 1 }
37 return code
38}
39
40func main() -> i64 {
41 gw("=== nx_sim_suite: SOVEREIGN S-class simulation-credibility regression suite (fork/exec, no shell) ===\n")
42 let tally: *i64 = sys_mmap(16) as *i64; tally[0]=0; tally[1]=0
43 report("nx_sim_credibility_gate\x00" as *u8, tally)
44 report("nx_sim_verification_gate\x00" as *u8, tally)
45 report("nx_sim_mms_gci_gate\x00" as *u8, tally)
46 report("nx_sim_uq_gate\x00" as *u8, tally)
47 report("nx_sim_sensitivity_gate\x00" as *u8, tally)
48 report("nx_sim_traceability_gate\x00" as *u8, tally)
49 report("nx_sim_risk_cou_gate\x00" as *u8, tally)
50 report("nx_sim_validation_gate\x00" as *u8, tally)
51 report("nx_sim_validation_real_gate\x00" as *u8, tally)
52 report("nx_sim_repro_h2h_gate\x00" as *u8, tally)
53 report("nx_sim_lifecycle_gate\x00" as *u8, tally)
54 report("nx_simlab_gate\x00" as *u8, tally)
55 report("nx_simlab_wasm_vm_gate\x00" as *u8, tally)
56 report("nx_solarsim_gate\x00" as *u8, tally)
57 report("nx_solarsim_wasm_vm_gate\x00" as *u8, tally)
58 report("nx_gassim_gate\x00" as *u8, tally)
59 report("nx_gassim_wasm_vm_gate\x00" as *u8, tally)
60 report("nx_pendulum_gate\x00" as *u8, tally)
61 report("nx_pendulum_wasm_vm_gate\x00" as *u8, tally)
62 report("nx_ballistics_gate\x00" as *u8, tally)
63 report("nx_ballistics_wasm_vm_gate\x00" as *u8, tally)
64 report("nx_kinetics_gate\x00" as *u8, tally)
65 report("nx_kinetics_wasm_vm_gate\x00" as *u8, tally)
66 report("nx_sim_film_gate\x00" as *u8, tally)
67 report("nx_chaos_logistic_gate\x00" as *u8, tally)
68 report("nx_dpendulum_gate\x00" as *u8, tally)
69
70 let total: i64 = tally[0] + tally[1]
71 gw("SIM-SUITE GREEN="); gn(tally[0]); gw("/"); gn(total); gw("\n")
72
73 // append a sovereign run record (the accruing use-history / regression log) -- no shell.
74 let fd: i64 = sys_openat_append("knowledge/status/sim_suite.log\x00" as *u8, 420)
75 if fd >= 0 {
76 let line: *u8 = sys_mmap(64) as *u8
77 line[0]=83 as u8; line[1]=73 as u8; line[2]=77 as u8; line[3]=45 as u8; line[4]=83 as u8; line[5]=85 as u8; line[6]=73 as u8; line[7]=84 as u8; line[8]=69 as u8; line[9]=32 as u8 // "SIM-SUITE "
78 var p: i64=10; var g: i64=tally[0]
79 if g==0 { line[p]=48 as u8; p=p+1 } else { let tmp: *u8=sys_mmap(16); var k: i64=0; while g>0 { tmp[k]=(48+(g%10)) as u8; g=g/10; k=k+1 } var j: i64=0; while j<k { line[p]=tmp[k-1-j]; p=p+1; j=j+1 } }
80 line[p]=47 as u8; p=p+1; var t: i64=total
81 if t==0 { line[p]=48 as u8; p=p+1 } else { let tmp2: *u8=sys_mmap(16); var k2: i64=0; while t>0 { tmp2[k2]=(48+(t%10)) as u8; t=t/10; k2=k2+1 } var j2: i64=0; while j2<k2 { line[p]=tmp2[k2-1-j2]; p=p+1; j2=j2+1 } }
82 line[p]=10 as u8; p=p+1
83 sys_write(fd, line, p); sys_close(fd)
84 gw(" (appended run record to knowledge/status/sim_suite.log)\n")
85 }
86
87 if tally[1] == 0 { gw("SIM-SUITE ALL-GREEN (whole S-class sim program verified together, sovereignly)\n"); sys_exit(0); return 0 }
88 gw("SIM-SUITE RED\n"); sys_exit(1); return 1
89}