[PATCH 2/3] tests: add kill.test

Fei Jie feij.fnst at cn.fujitsu.com
Wed Apr 27 08:54:20 UTC 2016


* tests/kill.c: New file.
* tests/kill.test: New test.
* tests/.gitignore: Add kill.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add kill.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/kill.c      | 39 +++++++++++++++++++++++++++++++++++++++
 tests/kill.test   |  6 ++++++
 4 files changed, 48 insertions(+)
 create mode 100644 tests/kill.c
 create mode 100755 tests/kill.test

diff --git a/tests/.gitignore b/tests/.gitignore
index f2fa908..d5f16c5 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -93,6 +93,7 @@ ipc_msg
 ipc_msgbuf
 ipc_sem
 ipc_shm
+kill
 ksysent
 ksysent.h
 lchown
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3c01e6b..c98c660 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -147,6 +147,7 @@ check_PROGRAMS = \
 	ipc_msgbuf \
 	ipc_sem \
 	ipc_shm \
+	kill \
 	ksysent \
 	lchown \
 	lchown32 \
@@ -415,6 +416,7 @@ DECODER_TESTS = \
 	ipc_msgbuf.test \
 	ipc_sem.test \
 	ipc_shm.test \
+	kill.test \
 	lchown.test \
 	lchown32.test \
 	linkat.test \
diff --git a/tests/kill.c b/tests/kill.c
new file mode 100644
index 0000000..4f52719
--- /dev/null
+++ b/tests/kill.c
@@ -0,0 +1,39 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_kill
+
+# include <signal.h>
+# include <stdio.h>
+# include <unistd.h>
+
+# define SIGINVAL 99
+void
+sig_handler(int sig)
+{
+}
+
+int
+main(void)
+{
+	signal(SIGALRM, sig_handler);
+
+	long rc = syscall(__NR_kill, getpid(), SIGALRM);
+	printf("kill(%d, SIGALRM) = %ld\n", getpid(), rc);
+
+	rc = syscall(__NR_kill, getpid(), SIGINVAL);
+	printf("kill(%d, %d) = %ld %s (%m)\n",
+	       getpid(), SIGINVAL, rc, errno2name());
+
+	rc = syscall(__NR_kill, getpid(), 0);
+	printf("kill(%d, SIG_0) = %ld\n", getpid(), rc);
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_kill")
+
+#endif
diff --git a/tests/kill.test b/tests/kill.test
new file mode 100755
index 0000000..bc50e6e
--- /dev/null
+++ b/tests/kill.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check kill syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a12 -esignal=none
-- 
1.8.3.1







More information about the Strace-devel mailing list