code wiki / (root) / nx_race_visualizer_test.nx

nx_race_visualizer_test.nx source

↩ module page · 45 lines · 1640 B

1// nx_race_visualizer_test.nx -- smoke for the visualizer. 2// 3// Constructs a small in-memory TSV buffer with rows across multiple 4// timing modes + verdicts + durations, runs the visualizer, then 5// verifies the entry returns the expected row-count. Visualizer 6// emits the chart to stdout (visual verification is by user). 7// 8// expect_exit: 0 9// 10// license_tier: ORIGINAL 11 12import "nx_syscalls_x86_64.nx" 13import "nx_race_visualizer.nx" 14 15// Length-determining emit (strlen-style; reads until NUL). 16func emit_strz(buf: *u8, off: i64, s: *u8) -> i64 { 17 var i: i64 = 0 18 while s[i] != 0 { 19 buf[off + i] = s[i] 20 i = i + 1 21 } 22 return off + i 23} 24 25func main() -> i64 { 26 let buf: *u8 = sys_mmap(8192) 27 var o: i64 = 0 28 29 // Header comment (visualizer skips lines starting with '#'). 30 o = emit_strz(buf, o, "# header\n" as *u8) 31 32 // Six data rows across four distinct timing modes + one missing 33 // timing_mode column (defaults to MANUAL). 34 o = emit_strz(buf, o, "2026-05-16\tlap\tbench_a\t1\t100\tWIN\t?\tnote\tMANUAL\n" as *u8) 35 o = emit_strz(buf, o, "2026-05-16\tlap\tbench_a\t2\t200\tWIN\t?\tnote\tMANUAL\n" as *u8) 36 o = emit_strz(buf, o, "2026-05-16\tlap\tbench_a\t3\t150\tTIE\t?\tnote\tSCHEDULED\n" as *u8) 37 o = emit_strz(buf, o, "2026-05-16\tlap\tbench_b\t1\t300\tLOSE\t?\tnote\tCONTINUOUS\n" as *u8) 38 o = emit_strz(buf, o, "2026-05-16\tlap\tbench_b\t2\t50\tRECORD_ONLY\t?\tnote\tEVENT\n" as *u8) 39 o = emit_strz(buf, o, "2026-05-16\tlap\tbench_c\t1\t75\tWIN\t?\tnote\n" as *u8) 40 41 let processed: i64 = nx_race_visualize(buf, o) 42 if processed != 6 { return 10 } 43 44 return 0 45}