code wiki / _hdl_build / nx_tool_run_timeout_gate.nx
nx_tool_run_timeout_gate.nx
buildroot/runtime/_hdl_build/nx_tool_run_timeout_gate.nx
about
nx_tool_run_timeout_gate.nx -- proves tr_run_capture_to actually BOUNDS a hanging child (seq1412).
The claim under test is not "the function returns a timeout constant" -- that is trivial to fake. It is
"a child that would run for 10 seconds is KILLED at the deadline, its output is still captured, it is
REAPED rather than orphaned, and a fast child is NOT falsely timed out". So every tooth measures
something an empty implementation would fail:
T1 the deadline FIRES -- 10s sleeper, 500ms budget -> TR_ERR_TIMEOUT
T2 the deadline is REAL TIME -- that call returns in well under the sleeper's 10s (the load-bearing
tooth: returning -5 after waiting the full 10s would be a lie)
T3 NEG-CONTROL fast child -- a 50ms sleeper with a 5s budget exits 0, NOT timed out
T4 output survives -- the fast child's stdout is captured intact
T5 REPEATABLE -- a second timeout run behaves identically (no fd/pid/zombie leak
wedging the caller after the first kill)
T6 opt-out is explicit -- timeout_ms<=0 delegates to the unbounded path and still succeeds
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_tool_run.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 21 | const TG_STDOUT: i64 = 1 |
| 22 | const TG_SLEEPER: *u8 = "_build/nx_tr_sleeper.sov.elf" |
| 23 | const TG_OUTCAP: i64 = 65536 |
| 26 | const TG_HANG_MS: i64 = 10000 |
| 27 | const TG_BUDGET_MS: i64 = 500 |
| 30 | const TG_MAX_ELAPSED_S: i64 = 5 |
| 31 | const TG_FAST_MS: i64 = 50 |
| 32 | const TG_FAST_BUDGET_MS: i64 = 5000 |
functions
| 34 | func tg_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(TG_STDOUT, s, n); return 0 } |
| 35 | func tg_num(v: i64) -> i64 |
| 48 | func tg_check(ok: i64, label: *u8, got: i64, want: i64) -> i64 |
| 59 | func tg_run(ms: *u8, budget: i64, out: *u8, ol: *i64) -> i64 |
| 67 | func main() -> i64 |