[PATCH v2] tests: add signal_receive.test
Fei Jie
feij.fnst at cn.fujitsu.com
Mon May 30 07:57:51 UTC 2016
* tests/signal_receive.c: New file.
* tests/signal_receive.test: New test.
* tests/.gitignore: Add signal_receive.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add signal_receive.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/signal_receive.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++
tests/signal_receive.test | 8 +++++
4 files changed, 100 insertions(+)
create mode 100644 tests/signal_receive.c
create mode 100755 tests/signal_receive.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 8f4d6f0..f5c1af0 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -227,6 +227,7 @@ setuid32
shmxt
sigaction
sigaltstack
+signal_receive
signalfd
sigreturn
sleep
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9eba306..aabcc3c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -279,6 +279,7 @@ check_PROGRAMS = \
setuid32 \
shmxt \
sigaction \
+ signal_receive \
sigaltstack \
signalfd \
sigreturn \
@@ -643,6 +644,7 @@ MISC_TESTS = \
qual_syscall.test \
redirect.test \
restart_syscall.test \
+ signal_receive.test \
strace-S.test \
strace-T.test \
strace-V.test \
diff --git a/tests/signal_receive.c b/tests/signal_receive.c
new file mode 100644
index 0000000..5a8a154
--- /dev/null
+++ b/tests/signal_receive.c
@@ -0,0 +1,89 @@
+#include "tests.h"
+#include <assert.h>
+#include <signal.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#if defined ALPHA
+const char *const signalent[] =
+{"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGEMT",
+"SIGFPE", "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", "SIGPIPE", "SIGALRM",
+"SIGTERM", "SIGURG", "SIGSTOP", "SIGTSTP", "SIGCONT", "SIGCHLD", "SIGTTIN",
+"SIGTTOU", "SIGIO", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
+"SIGINFO", "SIGUSR1", "SIGUSR2"
+};
+#elif defined HPPA
+const char *const signalent[] =
+{"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGSTKFLT",
+"SIGFPE", "SIGKILL", "SIGBUS", "SIGSEGV", "SIGXCPU", "SIGPIPE", "SIGALRM",
+"SIGTERM", "SIGUSR1", "SIGUSR2", "SIGCHLD", "SIGPWR", "SIGVTALRM", "SIGPROF",
+"SIGIO", "SIGWINCH", "SIGSTOP", "SIGTSTP", "SIGCONT", "SIGTTIN", "SIGTTOU",
+"SIGURG", "SIGXFSZ", "SIGSYS"
+};
+#elif defined MIPS
+const char *const signalent[] =
+{"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGIOT", "SIGEMT",
+"SIGFPE", "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", "SIGPIPE", "SIGALRM",
+"SIGTERM", "SIGUSR1", "SIGUSR2", "SIGCHLD", "SIGPWR", "SIGWINCH", "SIGURG",
+"SIGIO", "SIGSTOP", "SIGTSTP", "SIGCONT", "SIGTTIN", "SIGTTOU", "SIGVTALRM",
+"SIGPROF", "SIGXCPU", "SIGXFSZ"
+};
+#elif defined SPARC || defined SPARC64
+const char *const signalent[] =
+{"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGEMT",
+"SIGFPE", "SIGKILL", "SIGBUS", "SIGSEGV", "SIGSYS", "SIGPIPE", "SIGALRM",
+"SIGTERM", "SIGURG", "SIGSTOP", "SIGTSTP", "SIGCONT", "SIGCHLD", "SIGTTIN",
+"SIGTTOU", "SIGIO", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
+"SIGLOST", "SIGUSR1", "SIGUSR2"
+};
+#else
+const char *const signalent[] =
+{"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS",
+"SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM",
+"SIGTERM", "SIGSTKFLT", "SIGCHLD", "SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN",
+"SIGTTOU", "SIGURG", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH",
+"SIGIO", "SIGPWR", "SIGSYS"
+};
+#endif
+
+static void
+handler(int sig)
+{
+}
+
+int
+main(void)
+{
+ int sig;
+ int pid = getpid();
+ const struct sigaction act = { .sa_handler = handler };
+ for (sig = 1; sig <= 31; sig++)
+ {
+ if( sig != SIGKILL && sig != SIGSTOP)
+ {
+ sigaction(sig, &act, NULL);
+ }
+ }
+
+ sigset_t mask;
+ sigemptyset(&mask);
+ for (sig = 1; sig <= 31; sig++)
+ {
+ sigaddset(&mask, sig);
+ }
+ sigprocmask(SIG_UNBLOCK, &mask, NULL);
+ for (sig = 1; sig <= 31; sig++)
+ {
+ if(sig != SIGKILL && sig != SIGSTOP)
+ {
+ assert(kill(pid, sig) == 0);
+ printf("kill\\(%d, %s\\) = 0\n"
+ "--- %s {si_signo=%s, si_code=SI_USER, si_pid=%d,"
+ " si_uid=%d} ---\n",
+ pid, signalent[sig - 1], signalent[sig - 1], signalent[sig - 1],
+ pid, getuid());
+ }
+ }
+ return 0;
+}
diff --git a/tests/signal_receive.test b/tests/signal_receive.test
new file mode 100755
index 0000000..2e3e98d
--- /dev/null
+++ b/tests/signal_receive.test
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+run_strace -a15 -esignal $args > "$EXP"
+match_grep "$LOG" "$EXP"
+rm -f "$EXP"
--
1.8.3.1
More information about the Strace-devel
mailing list