nx_util_gate.nx source
↩ module page · 43 lines · 1962 B
1// nx_util_gate.nx -- the nx_util gate as PURE NISHILANG, orchestrated by the
2// sovereign nx_sh (no bash). Replaces bench/gate_nx_util.sh. Compiles
3// nx_util_test.nx, assembles, links, runs the KAT, checks the verdict --
4// every step via nx_sh fork/exec/redirect.
5//
6// license_tier: ORIGINAL
7
8import "nx_syscalls.nx"
9import "nx_sh.nx"
10
11func gp(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 }
12
13func main() -> i64 {
14 let C: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_compile_x86_native.elf" as *u8
15 let src: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/runtime/nx_util_test.nx" as *u8
16 let asm: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_util_test.s" as *u8
17 let obj: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_util_test.o" as *u8
18 let elf: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_util_test.elf" as *u8
19 let AS: *u8 = "/usr/bin/as" as *u8
20 let LD: *u8 = "/usr/bin/ld" as *u8
21 let dashO: *u8 = "-o" as *u8
22
23 gp("NX_UTIL GATE (sovereign nx_sh -- no bash)\n")
24
25 // 1) compile: C src > asm
26 let sfd: i64 = sys_openat_wr(asm, 420)
27 if sfd < 0 { gp("FAIL: open .s\n"); return 1 }
28 let r1: i64 = nx_sh_run_to(C, nx_sh_argv(C, src, 0 as *u8, 0 as *u8, 0 as *u8, 0 as *u8), sfd)
29 sys_close(sfd)
30 if r1 != 0 { gp("FAIL: compile\n"); return 2 }
31
32 // 2) assemble: as asm -o obj
33 if nx_sh_run_quiet(AS, nx_sh_argv(AS, asm, dashO, obj, 0 as *u8, 0 as *u8)) != 0 { gp("FAIL: as\n"); return 3 }
34
35 // 3) link: ld -o elf obj
36 if nx_sh_run_quiet(LD, nx_sh_argv(LD, dashO, elf, obj, 0 as *u8, 0 as *u8)) != 0 { gp("FAIL: ld\n"); return 4 }
37
38 // 4) run the KAT (inherit stdio -> prints its PASS line)
39 if nx_sh_run(elf, nx_sh_argv(elf, 0 as *u8, 0 as *u8, 0 as *u8, 0 as *u8, 0 as *u8)) != 0 { gp("FAIL: KAT nonzero\n"); return 5 }
40
41 gp("NX_UTIL GATE PASS -- orchestrated bits-up by nx_sh (bash retired)\n")
42 return 0
43}