code wiki / (root) / nx_mvault_reclaim_gate.nx

nx_mvault_reclaim_gate.nx source

↩ module page · 31 lines · 1267 B

1// nx_mvault_reclaim_gate.nx -- proves the dedup + large-file reclamation math. 2// run-exit == 0 means GREEN. 3 4import "nx_syscalls.nx" 5import "nx_mvault_reclaim.nx" 6 7func main(argc: i64, argv: *i64) -> i64 { 8 var fails: i64 = 0 9 let thresh: i64 = 1073741824 // 1 GiB "large" threshold 10 let st: *i64 = mv_reclaim_new() 11 12 mv_reclaim_add(st, 100, 0, thresh) // unique small 13 mv_reclaim_add(st, 200, 0, thresh) // unique small 14 mv_reclaim_add(st, 100, 1, thresh) // DUP of #1 -> reclaim 100 15 mv_reclaim_add(st, 5368709120, 0, thresh) // unique 5 GiB (large) 16 mv_reclaim_add(st, 200, 1, thresh) // DUP of #2 -> reclaim 200 17 18 if mv_reclaim_total(st) != 5 { fails = fails + 1 } 19 if mv_reclaim_unique(st) != 3 { fails = fails + 1 } 20 if mv_reclaim_dupcount(st) != 2 { fails = fails + 1 } 21 if mv_reclaim_reclaimable(st) != 300 { fails = fails + 1 } // 100 + 200 22 if mv_reclaim_large(st) != 1 { fails = fails + 1 } 23 if mv_reclaim_largebytes(st) != 5368709120 { fails = fails + 1 } 24 25 if fails == 0 { 26 sys_write(1, "MVAULT-RECLAIM-GATE GREEN dedup+large\n" as *u8, 38) 27 return 0 28 } 29 sys_write(1, "MVAULT-RECLAIM-GATE RED\n" as *u8, 24) 30 return 1 31}