|
@@ -1,8 +1,6 @@
|
|
|
#+build darwin, freebsd, openbsd, netbsd
|
|
|
package tests_core_posix
|
|
|
|
|
|
-import "base:runtime"
|
|
|
-
|
|
|
import "core:log"
|
|
|
import "core:path/filepath"
|
|
|
import "core:strings"
|
|
@@ -217,52 +215,6 @@ test_termios :: proc(t: ^testing.T) {
|
|
|
testing.expect_value(t, transmute(posix.COutput_Flags)posix.tcflag_t(posix._FFDLY), posix.FFDLY)
|
|
|
}
|
|
|
|
|
|
-@(test)
|
|
|
-test_signal :: proc(t: ^testing.T) {
|
|
|
- @static tt: ^testing.T
|
|
|
- tt = t
|
|
|
-
|
|
|
- @static ctx: runtime.Context
|
|
|
- ctx = context
|
|
|
-
|
|
|
- act: posix.sigaction_t
|
|
|
- act.sa_flags = {.SIGINFO, .RESETHAND}
|
|
|
- act.sa_sigaction = handler
|
|
|
- testing.expect_value(t, posix.sigaction(.SIGCHLD, &act, nil), posix.result.OK)
|
|
|
-
|
|
|
- handler :: proc "c" (sig: posix.Signal, info: ^posix.siginfo_t, address: rawptr) {
|
|
|
- context = ctx
|
|
|
- testing.expect_value(tt, sig, posix.Signal.SIGCHLD)
|
|
|
- testing.expect_value(tt, info.si_signo, posix.Signal.SIGCHLD)
|
|
|
- testing.expect_value(tt, info.si_status, 69)
|
|
|
- testing.expect_value(tt, info.si_code.chld, posix.CLD_Code.EXITED)
|
|
|
- }
|
|
|
-
|
|
|
- switch pid := posix.fork(); pid {
|
|
|
- case -1:
|
|
|
- log.errorf("fork() failure: %v", posix.strerror())
|
|
|
- case 0:
|
|
|
- posix.exit(69)
|
|
|
- case:
|
|
|
- for {
|
|
|
- status: i32
|
|
|
- res := posix.waitpid(pid, &status, {})
|
|
|
- if res == -1 {
|
|
|
- if !testing.expect_value(t, posix.errno(), posix.Errno.EINTR) {
|
|
|
- break
|
|
|
- }
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- if posix.WIFEXITED(status) || posix.WIFSIGNALED(status) {
|
|
|
- testing.expect(t, posix.WIFEXITED(status))
|
|
|
- testing.expect(t, posix.WEXITSTATUS(status) == 69)
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
@(test)
|
|
|
test_pthreads :: proc(t: ^testing.T) {
|
|
|
testing.set_fail_timeout(t, time.Second)
|