nx_gpu_dxg_inventory_gate_t366.nx source
↩ module page · 33 lines · 2370 B
1import "nx_gpu_dxg_inventory_candidate_t366.nx"
2import "nx_gate_verdict.nx"
3func main()->i64{
4 let c:*i64=gv_ctr();gv_head("DXG-CAPACITY-INVENTORY")
5 let raw:*u8=sys_mmap_try(2*DXI_ABI_BYTES)
6 let out:*DxgAdapterRecord=sys_mmap_try(2*__size_of(DxgAdapterRecord)) as *DxgAdapterRecord
7 if (raw as i64)<=0||(out as i64)<=0{return 2}
8 var i:i64=0;while i<2*DXI_ABI_BYTES{raw[i]=(i+1) as u8;i=i+1}
9 out.handle=123456
10 gv_check("negative capacity refused",dxi_extent(-1)==DXI_BAD_CAPACITY,c)
11 gv_check("zero capacity refused",dxi_extent(0)==DXI_BAD_CAPACITY,c)
12 gv_check("u32 overflow capacity refused",dxi_extent(DXI_U32_MAX+1)==DXI_BAD_CAPACITY,c)
13 gv_check("maximum ABI capacity extent exact no allocation",dxi_extent(DXI_U32_MAX)==85899345900,c)
14 gv_check("returned count beyond capacity refused",dxi_decode(raw,40,3,2,out,80)==DXI_BAD_COUNT,c)
15 gv_check("negative returned count refused",dxi_decode(raw,40,-1,2,out,80)==DXI_BAD_COUNT,c)
16 gv_check("truncated backing refused",dxi_decode(raw,39,2,2,out,80)==DXI_SHORT_INPUT,c)
17 gv_check("truncated destination refused",dxi_decode(raw,40,2,2,out,79)==DXI_SHORT_OUTPUT,c)
18 gv_check("refusals leave destination unchanged",out.handle==123456,c)
19 gv_check("zero count leaves destination unchanged",dxi_decode(raw,40,0,2,out,80)==0&&out.handle==123456,c)
20 gv_check("two adapters decoded",dxi_decode(raw,40,2,2,out,80)==2,c)
21 let second:*DxgAdapterRecord=((out as i64)+__size_of(DxgAdapterRecord)) as *DxgAdapterRecord
22 gv_check("first adapter handle preserved",out.handle==67305985,c)
23 gv_check("second adapter handle preserved",second.handle==404166165,c)
24 gv_check("both LUID words preserved",out.luid_low==134678021&&out.luid_high==202050057,c)
25 gv_check("source and flags preserved",second.sources==606282273&&second.present_move_regions==673654309,c)
26 out.handle=123456
27 gv_check("missing device reports failure",dxg_enumadapters_into("/nishi-dxg-test-missing-device",2,out,80)<0,c)
28 gv_check("missing device leaves destination unchanged",out.handle==123456,c)
29 gv_check("non-device standard ioctl refused",dxg_enumadapters_into("/dev/null",2,out,80)<0,c)
30 gv_check("failed ioctl leaves destination unchanged",out.handle==123456,c)
31 sys_munmap_direct(raw,40);sys_munmap_direct(out as *u8,80)
32 return gv_verdict("DXG-CAPACITY-INVENTORY",c,"boundary and unavailable-device proof only; actual GPU-host enumeration pending")
33}