code wiki / _hdl_build / _exec_probe.nx

_exec_probe.nx source

↩ module page · 59 lines · 2462 B

1// _exec_probe.nx -- diagnostic: spawn /tmp/nx_tictactoe_test.sov.elf the exact 2// way nx_sov_build_run's sbr_run does (sys_fork + sys_execve + sys_wait4, same 3// minimal envp) and report the RAW wait status + decoded exit code. Isolates 4// whether "child of a NishiLang fork/execve parent" changes the test verdict 5// (bash-parent exit=0 vs runner-parent exit=8 mystery, 2026-06-09). 6import "nx_syscalls.nx" 7 8func ep_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 9func ep_putn(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } 10 11func ep_spawn(path: *u8) -> i64 { 12 let argv: *i64 = sys_mmap(8*4) as *i64 13 argv[0] = path as i64; argv[1] = 0 14 let envp: *i64 = sys_mmap(8*4) as *i64 15 envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64; envp[1] = 0 16 let pid: i64 = sys_fork() 17 if pid == 0 { 18 sys_execve(path, argv, envp) 19 sys_exit(127) 20 } 21 let st: *i64 = sys_mmap(16) as *i64 22 sys_wait4(pid, st, 0) 23 ep_puts(path); ep_puts(": raw-status=" as *u8); ep_putn(st[0]) 24 ep_puts(" decoded-exit=" as *u8); ep_putn((st[0] >> 8) & 0xff) 25 ep_puts(" low-byte=" as *u8); ep_putn(st[0] & 0x7f) 26 ep_puts("\n" as *u8) 27 return 0 28} 29 30func main() -> i64 { 31 ep_spawn("/tmp/ttt_fixed.sov.elf" as *u8) 32 ep_spawn("/tmp/chk_fixed.sov.elf" as *u8) 33 ep_spawn("/tmp/rcv_fixed.sov.elf" as *u8) 34 ep_spawn("/tmp/fab_fixed.sov.elf" as *u8) 35 ep_spawn("/tmp/gec_fixed.sov.elf" as *u8) 36 ep_spawn("/tmp/grc_fixed.sov.elf" as *u8) 37 return 0 38} 39 40func _old_main() -> i64 { 41 let path: *u8 = "/tmp/nx_tictactoe_test.sov.elf" as *u8 42 let argv: *i64 = sys_mmap(8*4) as *i64 43 argv[0] = path as i64; argv[1] = 0 44 let envp: *i64 = sys_mmap(8*4) as *i64 45 envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64; envp[1] = 0 46 47 let pid: i64 = sys_fork() 48 if pid == 0 { 49 sys_execve(path, argv, envp) 50 sys_exit(127) 51 } 52 let st: *i64 = sys_mmap(16) as *i64 53 sys_wait4(pid, st, 0) 54 ep_puts("raw-status=" as *u8); ep_putn(st[0]) 55 ep_puts(" decoded-exit=" as *u8); ep_putn((st[0] >> 8) & 0xff) 56 ep_puts(" low-byte(signal-if-nonzero)=" as *u8); ep_putn(st[0] & 0x7f) 57 ep_puts("\n" as *u8) 58 return 0 59}