code wiki / (root) / nx_comparetree_lib_gate.nx

nx_comparetree_lib_gate.nx

buildroot/runtime/nx_comparetree_lib_gate.nx

52151 B1014 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_comparetree_lib_gate.nx -- the referee for the two-tree /compare resolver (nx_comparetree_lib). WHAT MAKES THIS GATE REAL RATHER THAN DECORATIVE: * IN-PROCESS. It imports the lib and calls it directly, so nx_gate_bite can mutate the lib and watch this go RED. A gate that fork/execs a deployed elf reports NOT-REACHED for every mutant and its GREEN proves nothing about the code under test. * REAL FILES, NOT A SIMULATION. The three resolution cases are exercised against actual fixture files under /tmp/<gate>/, because the defect being guarded is a FILESYSTEM LOOKUP. A gate that only tested the pure decision would pass while the resolver read the wrong path. * THE FIXTURE IS ASSERTED BEFORE THE OUTCOME. If the fixture write failed, every "resolves to secondary" tooth below would pass for the wrong reason -- an absent file resolves nowhere. * ANTI-VACUITY BY CONTENT. Each case checks the BYTES RETURNED, not just the which-tree flag. A trivial implementation that always sets the flag to PRIMARY and reads nothing cannot pass, and that implementation is kept here as cg_wrong_pick so the claim is demonstrated, not asserted. * cwd-INDEPENDENT. Fixtures are absolute and the production-order teeth compare constants, so this gate cannot pass or fail because of where a runner happened to start it. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_comparetree_lib.nx nx_comparetree_lib_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_comparetree_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gv_head gv_puts sys_write gv_ctr sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mkdir sys_mmap ↻ ct_build_path ct_cat cg_write sys_openat_wr cg_zlen sys_write ↻ sys_close gv_check gv_puts ↻ eq cg_streq cg_zlen ↻ ct_first_published ct_second_published ct_first_authored ct_second_authored ct_swap_tree gv_bite

structs

none

consts

22const CG_MODE_755: i64 = 493
23const CG_MODE_644: i64 = 420
24const CG_BUF: i64 = 4096
25const CG_PATH: i64 = 512
27const CG_ROOT: *u8 = "/tmp/nx_comparetree_lib_gate"
28const CG_MK_P: *u8 = "/tmp/nx_comparetree_lib_gate/p"
29const CG_MK_S: *u8 = "/tmp/nx_comparetree_lib_gate/s"
31const CG_DIR_P: *u8 = "/tmp/nx_comparetree_lib_gate/p/"
32const CG_DIR_S: *u8 = "/tmp/nx_comparetree_lib_gate/s/"
34const CG_DIR_NONE: *u8 = "/tmp/nx_comparetree_lib_gate/no_such_dir/"
35const CG_SUF: *u8 = ".matrix"
39const CG_BODY_P_BOTH: *u8 = "PRIMARY-TREE-BOTH\n"
40const CG_BODY_S_BOTH: *u8 = "SECONDARY-TREE-BOTH-AND-LONGER\n"
41const CG_BODY_P_ONLY: *u8 = "PRIMARY-ONLY\n"
42const CG_BODY_S_ONLY: *u8 = "SECONDARY-ONLY-LONGER\n"
118const CG_OLD_CAP: i64 = 65536
119const CG_BIG_PAD: i64 = 3000
120const CG_BIG_FILL: i64 = 46
121const CG_BIG_TAIL: *u8 = "TAIL-PAST-THE-OLD-CAP\n"
122const CG_BIG_DOM: *u8 = "big"
195const CG_ST_CODE: i64 = 0
196const CG_ST_STR: i64 = 1
197const CG_ST_COMMENT: i64 = 2
199const CG_DQ: i64 = 34
200const CG_BSL: i64 = 92
201const CG_FSL: i64 = 47
202const CG_NLB: i64 = 10
208const CG_NEEDLE: *u8 = "knowledge/compare"
209const CG_IMPORTMARK: *u8 = "nx_comparetree_lib"
215const CG_SCAN_A1: *u8 = "buildroot/runtime"
216const CG_SCAN_A2: *u8 = "runtime"
217const CG_SCAN_B1: *u8 = "buildroot/runtime/_hdl_build"
218const CG_SCAN_B2: *u8 = "runtime/_hdl_build"
219const CG_NXEXT: *u8 = ".nx"
224const CG_STATUS_1: *u8 = "knowledge/status/"
225const CG_STATUS_2: *u8 = "../knowledge/status/"
226const CG_BASE_FILE: *u8 = "comparetree_adoption.baseline"
227const CG_STAMP_FILE: *u8 = "comparetree_adoption.stamp"
231const CG_EXEMPT_1: *u8 = "nx_comparetree_lib.nx"
232const CG_EXEMPT_2: *u8 = "nx_comparetree_lib_gate.nx"
245const CG_FILE_BUDGET: i64 = 32000
246const CG_DENT_BUF: i64 = 262144
247const CG_NAME_CAP: i64 = 256
248const CG_SET_CAP: i64 = 262144
249const CG_FX_CAP: i64 = 512
251const CG_O_SCANNED: i64 = 0
252const CG_O_OFFENDERS: i64 = 1
253const CG_O_ADOPTERS: i64 = 2
254const CG_O_EXEMPTED: i64 = 3
255const CG_O_UNREAD: i64 = 4
256const CG_O_OVER: i64 = 5
257const CG_O_SETLEN: i64 = 6
258const CG_OUT_SLOTS: i64 = 8
259const CG_OUT_BYTES: i64 = 64

functions

44func cg_zlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
45func eq(a: i64, b: i64) -> i64 { if a == b { return 1 } return 0 }
called by 1: main
46func ne(a: i64, b: i64) -> i64 { if a == b { return 0 } return 1 }
called by 1: main
48func cg_say(s: *u8) -> i64
called by 1: main calls 1: sys_write
54func cg_num(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
68func cg_write(path: *u8, body: *u8) -> i64
78func cg_streq(a: *u8, b: *u8) -> i64
called by 2: cg_exemptmain
89func cg_bufeq(buf: *u8, n: i64, exp: *u8) -> i64
called by 1: main calls 1: cg_zlen
102func cg_wrong_pick(n1: i64, n2: i64) -> i64 { return CT_TREE_PRIMARY }
called by 1: main
124func cg_gt(a: i64, b: i64) -> i64 { if a > b { return 1 } return 0 }
called by 1: main
129func cg_write_big(path: *u8) -> i64
157func cg_tail_is(buf: *u8, n: i64, exp: *u8) -> i64
called by 1: main calls 1: cg_zlen
261func cg_put(d: *u8, o: i64, b: i64) -> i64 { d[o] = b as u8; return o + 1 }
263func cg_at(src: *u8, n: i64, i: i64, ned: *u8, nl: i64) -> i64
278func cg_code_has(src: *u8, n: i64, ned: *u8) -> i64
314func cg_naive_has(src: *u8, n: i64, ned: *u8) -> i64
called by 1: main calls 2: cg_zlencg_at
327func cg_slashstrip_has(src: *u8, n: i64, ned: *u8) -> i64
called by 1: main calls 2: cg_zlencg_at
350func cg_exempt(name: *u8) -> i64
called by 2: cg_is_offendercg_scan_dir calls 1: cg_streq
358func cg_is_offender(name: *u8, src: *u8, n: i64) -> i64
called by 1: main calls 2: cg_code_hascg_exempt
364func cg_ends_with(name: *u8, suf: *u8) -> i64
called by 1: cg_scan_dir calls 1: cg_zlen
376func cg_eol(b: *u8, n: i64, i: i64) -> i64
called by 2: cg_haslinemain
387func cg_hasline(hay: *u8, hn: i64, name: *u8) -> i64
called by 1: main calls 2: cg_zlencg_eol
415func cg_should_write(have_base: i64, rises: i64, falls: i64, cov: i64) -> i64
called by 1: main
424func cg_launder_write(have_base: i64, rises: i64, falls: i64, cov: i64) -> i64 { return 1 }
called by 1: main
428func cg_fx_clean(d: *u8) -> i64
called by 1: main calls 1: gv_cat
433func cg_fx_code(d: *u8) -> i64
called by 1: main calls 1: gv_cat
440func cg_fx_str(d: *u8) -> i64
called by 1: main calls 2: gv_catcg_put
449func cg_fx_cmt(d: *u8) -> i64
called by 1: main calls 2: cg_putgv_cat
458func cg_fx_url(d: *u8) -> i64
called by 1: main calls 2: gv_catcg_put
477func cg_scan_dir(dir: *u8, set: *u8, setcap: i64, out: *i64) -> i64
543func main(argc: i64, argv: *i64) -> i64