code wiki / (root) / nx_wflow_completion_gate_t30.nx

nx_wflow_completion_gate_t30.nx source

↩ module page · 40 lines · 1864 B

1// Private qualification of actual workflow child completion; only the fixture child terminates itself. 2import "nx_wflow_engine.nx" 3const WG_GETPID: i64 = 39 4const WG_KILL: i64 = 62 5const WG_SIGKILL: i64 = 9 6func main(argc: i64,argv: *i64) -> i64 { 7 if argc > 1 { 8 let mode: *u8=argv[1] as *u8 9 if mode[0] == (115 as u8) { 10 let selfpid: i64=__syscall(WG_GETPID,0,0,0,0,0,0) 11 p("FIXTURE self_pid=" as *u8);pn(selfpid);p("\n" as *u8) 12 if selfpid <= 0 { return 99 } 13 let sent: i64=__syscall(WG_KILL,selfpid,WG_SIGKILL,0,0,0,0) 14 p("FIXTURE signal_returned=" as *u8);pn(sent);p(" UNQUALIFIED SIGNAL\n" as *u8) 15 return 99 16 } 17 if mode[0] == (110 as u8) { return 7 } 18 return 0 19 } 20 let path: *u8=sys_mmap(256) 21 var off: i64=wf_cat(path,0,"/tmp/nx_wflow_completion_t30_" as *u8) 22 off=wf_catn(path,off,__syscall(WG_GETPID,0,0,0,0,0,0)) 23 off=wf_cat(path,off,".conf" as *u8); path[off]=0 as u8 24 let row: *u8=sys_mmap(1024) 25 var ro: i64=wf_cat(row,0,"self" as *u8) 26 row[ro]=9 as u8; ro=ro+1 27 ro=wf_cat(row,ro,argv[0] as *u8) 28 row[ro]=9 as u8; ro=ro+1 29 ro=wf_cat(row,ro,"GREEN" as *u8) 30 row[ro]=10 as u8; row[ro+1]=0 as u8 31 wf_append(path,row) 32 let cx: *i64=sys_mmap(32) as *i64 33 cx[3]=path as i64 34 let a: i64=wf_exec_organ(cx,"self" as *u8,"ok" as *u8,"fixture" as *u8) 35 let b: i64=wf_exec_organ(cx,"self" as *u8,"nonzero" as *u8,"fixture" as *u8) 36 let c: i64=wf_exec_organ(cx,"self" as *u8,"signal" as *u8,"fixture" as *u8) 37 p("COMPLETION observed normal=" as *u8);pn(a);p(" nonzero=" as *u8);pn(b);p(" signaled=" as *u8);pn(c);p("\n" as *u8) 38 if a == 1 && b == 0 && c == 0 { p("PASS actual child completion\n" as *u8); return 0 } 39 p("FAIL child completion; signaled child must not pass\n" as *u8); return 1 40}