code wiki / (root) / nx_capture_owned_gate_t218.nx

nx_capture_owned_gate_t218.nx source

↩ module page · 26 lines · 2355 B

1import "nx_tool_run.nx" 2import "nx_gate_verdict.nx" 3func cg_owned(mode:*u8,b:*NxBufOwned,limit:i64,tmo:i64)->i64{ 4 let path:*u8="/volume1/homes/elderwesto/nishihost/buildroot/_build/nx_capture_fixture_t218.sov.elf" 5 let av:*i64=sys_mmap_try(24) as *i64;if (av as i64)<=0{return TR_ERR_ALLOC};av[0]=path as i64;av[1]=mode as i64;av[2]=0 6 let rc:i64=tr_run_capture_owned(path,av,b,tmo,limit,0 as *u8);sys_munmap_direct(av as *u8,24);return rc 7} 8func main()->i64{ 9 let c:*i64=gv_ctr();let b:*NxBufOwned=sys_mmap_try(24) as *NxBufOwned;if (b as i64)<=0{return 2} 10 b.buf=0 as *u8;b.len=0;b.cap=0 11 let rc:i64=cg_owned("large",b,0,8000);gv_check("owned producer completes once beyond former64KiB",rc==0&&b.len==196613,c) 12 var exact:i64=1;var i:i64=0;while i<b.len{if b.buf[i]!=(i%251) as u8{exact=0};i=i+1};gv_check("entire retained binary stdout matches producer pattern",exact==1&&b.len==196613,c) 13 gv_check("nonempty owner refuses another execution",cg_owned("large",b,0,8000)==TR_ERR_DRAIN,c) 14 gv_check("owned release clears all allocation state",nx_bo_release(b)==0&&(b.buf as i64)==0&&b.len==0&&b.cap==0,c) 15 gv_check("explicit caller budget refuses rather than false success",cg_owned("large",b,65536,8000)==NX_BO_CAPACITY,c) 16 gv_check("budget partial evidence stays within declared limit",b.len<=65536&&b.cap<=65536,c);nx_bo_release(b) 17 gv_check("child nonzero status retained",cg_owned("fail",b,0,8000)==7&&b.len==7,c);nx_bo_release(b) 18 gv_check("empty successful child has no allocation",cg_owned("empty",b,0,8000)==0&&b.len==0&&b.cap==0,c);nx_bo_release(b) 19 gv_check("timeout uses existing process lifecycle",cg_owned("timeout",b,0,100)==TR_ERR_TIMEOUT,c);nx_bo_release(b) 20 let path:*u8="/volume1/homes/elderwesto/nishihost/buildroot/_build/nx_capture_fixture_t218.sov.elf" 21 let av:*i64=sys_mmap_try(24) as *i64;let out:*u8=sys_mmap_try(65536);if (av as i64)<=0||(out as i64)<=0{return 3} 22 av[0]=path as i64;av[1]="large" as *u8 as i64;av[2]=0;var n:i64=0;var cut:i64=0 23 gv_check("legacy fixed capture retains truncation contract",tr_run_capture_tr(path,av,out,65536,&n,8000,&cut)==0&&n==65536&&cut==TR_CUT,c) 24 sys_munmap_direct(out,65536);sys_munmap_direct(av as *u8,24);sys_munmap_direct(b as *u8,24) 25 return gv_verdict("owned-process-capture",c,"Actual child, complete binary output, caller budget, nonzero, empty, timeout and legacy truncation") 26}