summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-sigpending.lua17
-rw-r--r--tests/test-sigsuspend.lua15
-rw-r--r--tests/test-sigtimedwait.lua37
-rw-r--r--tests/test-sigwait.lua21
-rw-r--r--tests/test-sigwaitinfo.lua21
5 files changed, 111 insertions, 0 deletions
diff --git a/tests/test-sigpending.lua b/tests/test-sigpending.lua
new file mode 100644
index 0000000..43136b1
--- /dev/null
+++ b/tests/test-sigpending.lua
@@ -0,0 +1,17 @@
+local l = require "luxio"
+
+s = l.newsigset()
+l.sigemptyset(s)
+l.sigaddset(s, l.SIGUSR1)
+l.sigprocmask(l.SIG_BLOCK, s)
+l.raise(l.SIGUSR1)
+
+pending = l.sigpending()
+
+present, errno = l.sigismember(pending, l.SIGUSR1)
+
+if present == 1 then
+ print("PASS")
+else
+ print("FAIL")
+end
diff --git a/tests/test-sigsuspend.lua b/tests/test-sigsuspend.lua
new file mode 100644
index 0000000..5c85e77
--- /dev/null
+++ b/tests/test-sigsuspend.lua
@@ -0,0 +1,15 @@
+local l = require "luxio"
+
+function handler()
+ return
+end
+
+l.sigaction(l.SIGINT, {["sa_handler"] = handler})
+
+s = l.newsigset()
+l.sigfillset(s)
+l.sigdelset(s, l.SIGINT)
+print("Press CTRL-C...")
+l.sigsuspend(s)
+
+print("PASS")
diff --git a/tests/test-sigtimedwait.lua b/tests/test-sigtimedwait.lua
new file mode 100644
index 0000000..0311a50
--- /dev/null
+++ b/tests/test-sigtimedwait.lua
@@ -0,0 +1,37 @@
+local l = require "luxio"
+
+function handler()
+ return
+end
+
+l.sigaction(l.SIGINT, {["sa_handler"] = handler})
+
+s = l.newsigset()
+l.sigemptyset(s)
+l.sigaddset(s, l.SIGINT)
+
+info, errno = l.sigtimedwait(s, 0, 0)
+
+if not (info == nil and errno == l.EAGAIN) then
+ print("FAIL")
+end
+
+print("Wait...")
+pid, errno = l.fork()
+if pid == 0 then
+ l.sleep(5)
+ print("Press CTRL-C...")
+ os.exit(0)
+elseif pid == -1 then
+ io.stderr:write(("fork: %s\n"):format(l.strerror(errno)))
+ os.exit(2)
+end
+
+seconds = 3600
+info, errno = l.sigtimedwait(s, seconds, 0)
+
+if info ~= nil and info["si_signo"] == l.SIGINT then
+ print("PASS")
+else
+ print(("FAIL (expected sig to be %d but it is %d)"):format(l.SIGINT, info["si_signo"]))
+end
diff --git a/tests/test-sigwait.lua b/tests/test-sigwait.lua
new file mode 100644
index 0000000..bbd2378
--- /dev/null
+++ b/tests/test-sigwait.lua
@@ -0,0 +1,21 @@
+local l = require "luxio"
+
+function handler()
+ return
+end
+
+l.sigaction(l.SIGINT, {["sa_handler"] = handler})
+
+s = l.newsigset()
+l.sigemptyset(s)
+l.sigaddset(s, l.SIGINT)
+print("Press CTRL-C...")
+
+
+sig, errno = l.sigwait(s, l.SIGINT)
+
+if sig == l.SIGINT then
+ print("PASS")
+else
+ print(("FAIL (expected sig to be %d but it is %d)"):format(l.SIGINT, sig))
+end
diff --git a/tests/test-sigwaitinfo.lua b/tests/test-sigwaitinfo.lua
new file mode 100644
index 0000000..242b444
--- /dev/null
+++ b/tests/test-sigwaitinfo.lua
@@ -0,0 +1,21 @@
+local l = require "luxio"
+
+function handler()
+ return
+end
+
+l.sigaction(l.SIGINT, {["sa_handler"] = handler})
+
+s = l.newsigset()
+l.sigemptyset(s)
+l.sigaddset(s, l.SIGINT)
+print("Press CTRL-C...")
+
+
+info, errno = l.sigwaitinfo(s)
+
+if info ~= nil and info["si_signo"] == l.SIGINT then
+ print("PASS")
+else
+ print(("FAIL (expected sig to be %d but it is %d)"):format(l.SIGINT, info["si_signo"]))
+end