[PATCH v2] tests: add signal_receive.test

Dmitry V. Levin ldv at altlinux.org
Mon May 30 17:06:41 UTC 2016


On Mon, May 30, 2016 at 03:57:51PM +0800, Fei Jie wrote:
> * 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

Could you write this without arch specific ifdefs at all?
See e.g. tests/errno2name.c.

Some constants are not common, they need ifdefs:

$ sed -n 's/^[[:space:]]*"\(SIG[^"]\+\)".*/\1/p' linux/{*/,}signalent*.h |sort |uniq -c |awk '$1<5{print $2}'
SIGABRT
SIGEMT
SIGINFO
SIGIOT
SIGLOST
SIGPWR
SIGSTKFLT


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160530/8e53c887/attachment.bin>


More information about the Strace-devel mailing list