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

5155 B110 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/prooftopic tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tool_run.nx nx_tool_run_timeout_gate.nx

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

main tg_puts sys_write sys_mmap sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real tg_run sys_mmap ↻ tr_run_capture_to tr_run_capture sys_mmap ↻ sys_pipe2 sys_fork sys_close sys_dup3 sys_execve_clean sys_close ↻ sys_execve sys_exit sys_read sys_wait4 wait_exit_code sys_mmap ↻ sys_pipe2 ↻ sys_fork ↻ sys_close ↻ sys_default_signal sys_mmap ↻ sys_dup3 ↻ sys_execve_clean ↻ sys_exit ↻ sys_sleep_ms sys_mmap ↻ sys_munmap nx_kill sys_read ↻ sys_wait4 ↻ wait_exit_code ↻ tg_check

structs

none

consts

21const TG_STDOUT: i64 = 1
22const TG_SLEEPER: *u8 = "_build/nx_tr_sleeper.sov.elf"
23const TG_OUTCAP: i64 = 65536
26const TG_HANG_MS: i64 = 10000
27const TG_BUDGET_MS: i64 = 500
30const TG_MAX_ELAPSED_S: i64 = 5
31const TG_FAST_MS: i64 = 50
32const TG_FAST_BUDGET_MS: i64 = 5000

functions

34func 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 }
called by 2: tg_checkmain calls 1: sys_write
35func tg_num(v: i64) -> i64
called by 2: tg_checkmain calls 2: sys_writesys_mmap
48func tg_check(ok: i64, label: *u8, got: i64, want: i64) -> i64
called by 1: main calls 2: tg_putstg_num
59func tg_run(ms: *u8, budget: i64, out: *u8, ol: *i64) -> i64
called by 1: main calls 2: sys_mmaptr_run_capture_to
67func main() -> i64