aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/builtin/linux_bare/old/.checks/forkedtest
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/builtin/linux_bare/old/.checks/forkedtest
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/builtin/linux_bare/old/.checks/forkedtest')
-rw-r--r--v_windows/v/vlib/builtin/linux_bare/old/.checks/forkedtest/forkedtest.v49
1 files changed, 49 insertions, 0 deletions
diff --git a/v_windows/v/vlib/builtin/linux_bare/old/.checks/forkedtest/forkedtest.v b/v_windows/v/vlib/builtin/linux_bare/old/.checks/forkedtest/forkedtest.v
new file mode 100644
index 0000000..6d9272c
--- /dev/null
+++ b/v_windows/v/vlib/builtin/linux_bare/old/.checks/forkedtest/forkedtest.v
@@ -0,0 +1,49 @@
+module forkedtest
+
+pub fn run (op fn(), label string, code Wi_si_code, status int) int {
+ child := sys_fork()
+ if child == 0 {
+ op()
+ sys_exit(0)
+ }
+
+ siginfo := []int{len:int(Sig_index.si_size)}
+
+ e := sys_waitid(.p_pid, child, intptr(&siginfo[0]), .wexited, 0)
+
+ assert e == .enoerror
+ assert siginfo[int(Sig_index.si_pid)] == child
+ assert siginfo[int(Sig_index.si_signo)] == int(Signo.sigchld)
+ assert siginfo[int(Sig_index.si_uid)] == sys_getuid()
+
+ r_code := siginfo[Sig_index.si_code]
+ r_status := siginfo[Sig_index.si_status]
+
+ print("+++ ")
+ print(label)
+ if (int(code) == r_code) && (status == r_status) {
+ println(" PASSED")
+ return 0
+ }
+ println(" FAILED")
+
+ if int(code) != r_code {
+ print(">> Expecting si_code 0x")
+ println(i64_str(int(code),16))
+ print(">> Got 0x")
+ println(i64_str(r_code,16))
+ }
+
+ if status != r_status {
+ print(">> Expecting status 0x")
+ println(i64_str(status,16))
+ print(">> Got 0x")
+ println(i64_str(r_status,16))
+ }
+
+ return 1
+}
+
+pub fn normal_run (op fn(), label string) int {
+ return run (op, label, .cld_exited, 0)
+}