aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-04-09 06:25:03 -0400
committerMike Frysinger <vapier@gentoo.org>2009-04-09 06:25:03 -0400
commitff86b7a4f285c9f754665dfb9f342993fa7f62e6 (patch)
tree66bb8f2e1228c554e18974384b2372f6f7ef13e2
parentgitignore: ignore all a.out binaries (diff)
downloadsandbox-ff86b7a4f285c9f754665dfb9f342993fa7f62e6.tar.gz
sandbox-ff86b7a4f285c9f754665dfb9f342993fa7f62e6.tar.bz2
sandbox-ff86b7a4f285c9f754665dfb9f342993fa7f62e6.zip
tests: make sure traced programs and signals workv1.9
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/signal_static-0.c13
-rwxr-xr-xtests/signal_static-1.sh30
-rw-r--r--tests/signal_static.at1
-rw-r--r--tests/test-skel-0.c29
-rw-r--r--tests/tests.h61
-rw-r--r--tests/testsuite.at1
7 files changed, 107 insertions, 29 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index efebbb4..8677e34 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -41,6 +41,7 @@ check_PROGRAMS = \
opendir-0 \
rename-0 \
renameat-0 \
+ signal_static-0 \
symlink-0 \
symlinkat-0 \
truncate-0 \
diff --git a/tests/signal_static-0.c b/tests/signal_static-0.c
new file mode 100644
index 0000000..e50e1dc
--- /dev/null
+++ b/tests/signal_static-0.c
@@ -0,0 +1,13 @@
+/* trace code needs to handle random child signals */
+#include "tests.h"
+
+int main(int argc, char *argv[])
+{
+ if (argc == 1)
+ /* don't dump usage since testsuite will try to exec us
+ * for possible skip status
+ */
+ return 0;
+ else
+ return kill(getpid(), lookup_signal(argv[1]));
+}
diff --git a/tests/signal_static-1.sh b/tests/signal_static-1.sh
new file mode 100755
index 0000000..4b48078
--- /dev/null
+++ b/tests/signal_static-1.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# make sure we catch openat with relative path
+[ "${at_xfail}" = "yes" ] && exit 77 # see trace-0
+
+# if a traced child dies due to a signal, we should pass that
+# signal value back up
+
+# POSIX dictates the numeric value of some signals, so let's just
+# go with those. the actual number tested is the way the shell
+# works -- 128 + signal number.
+
+EXIT=-128 # hack to negate the 128 base -- we should exit with 0
+HUP=1
+INT=2
+QUIT=3
+ABRT=6
+KILL=9
+ALRM=14
+TERM=15
+for sig in EXIT HUP INT QUIT ABRT ALRM TERM ; do #KILL
+ signum=`eval echo \$sig`
+ signam="SIG${sig}"
+
+ printf "testing %s ... " "${signam}"
+ signal_static-0 ${signam}
+ test $? -eq $((128 + signum)) || exit 1
+ echo "OK"
+done
+
+exit 0
diff --git a/tests/signal_static.at b/tests/signal_static.at
new file mode 100644
index 0000000..081d7d2
--- /dev/null
+++ b/tests/signal_static.at
@@ -0,0 +1 @@
+SB_CHECK(1)
diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c
index 150893f..c4de4db 100644
--- a/tests/test-skel-0.c
+++ b/tests/test-skel-0.c
@@ -9,8 +9,6 @@ const char *color_red = "\033[31;01m";
# define CONFIG 1
#endif
-#define PAIR(x) { #x, x },
-
int at_get_fd(const char *str_dirfd)
{
if (!strcmp(str_dirfd, "AT_FDCWD"))
@@ -86,33 +84,6 @@ dev_t sscanf_dev_t(const char *str_dev)
return (dev_t)dev;
}
-int lookup_errno(const char *str_errno)
-{
- struct {
- const char *name;
- int val;
- } const tbl[] = {
- PAIR(EACCES)
- PAIR(EBADF)
- PAIR(EEXIST)
- PAIR(EFAULT)
- PAIR(EINVAL)
- PAIR(EISDIR)
- PAIR(ELOOP)
- PAIR(ENAMETOOLONG)
- PAIR(ENODEV)
- PAIR(ENOENT)
- PAIR(ENOTDIR)
- PAIR(EPERM)
- PAIR(ETXTBSY)
- };
- int i;
- for (i = 0; i < ARRAY_SIZE(tbl); ++i)
- if (!strcmp(str_errno, tbl[i].name))
- return tbl[i].val;
- return 0;
-}
-
int main(int argc, char *argv[])
{
#if CONFIG
diff --git a/tests/tests.h b/tests/tests.h
index af927d0..8c8e8e6 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -5,3 +5,64 @@
#define _stderr_pmsg(fmt, args...) _msg(stderr, fmt ": %s", ##args, strerror(errno))
#define err(fmt, args...) ({ _stderr_msg(fmt, ##args); exit(1); })
#define errp(fmt, args...) ({ _stderr_pmsg(fmt, ##args); exit(1); })
+
+typedef struct {
+ const char *name;
+ int val;
+} value_pair;
+#define PAIR(x) { #x, x },
+
+int lookup_val(const value_pair *tbl, const char *name)
+{
+ size_t i;
+ for (i = 0; tbl[i].name; ++i)
+ if (!strcmp(name, tbl[i].name))
+ return tbl[i].val;
+ err("unable to locate '%s'", name);
+}
+
+int lookup_errno(const char *str_errno)
+{
+ const value_pair tbl[] = {
+ PAIR(EACCES)
+ PAIR(EBADF)
+ PAIR(EEXIST)
+ PAIR(EFAULT)
+ PAIR(EINVAL)
+ PAIR(EISDIR)
+ PAIR(ELOOP)
+ PAIR(ENAMETOOLONG)
+ PAIR(ENODEV)
+ PAIR(ENOENT)
+ PAIR(ENOTDIR)
+ PAIR(EPERM)
+ PAIR(ETXTBSY)
+ { }
+ };
+ return lookup_val(tbl, str_errno);
+}
+
+int lookup_signal(const char *str_signal)
+{
+ const value_pair tbl[] = {
+ { "SIGEXIT", 0 },
+ PAIR(SIGABRT)
+ PAIR(SIGALRM)
+ PAIR(SIGCHLD)
+ PAIR(SIGCONT)
+ PAIR(SIGHUP)
+ PAIR(SIGILL)
+ PAIR(SIGINT)
+ PAIR(SIGKILL)
+ PAIR(SIGPIPE)
+ PAIR(SIGQUIT)
+ PAIR(SIGSEGV)
+ PAIR(SIGSTOP)
+ PAIR(SIGTRAP)
+ PAIR(SIGTERM)
+ PAIR(SIGUSR1)
+ PAIR(SIGUSR2)
+ { }
+ };
+ return lookup_val(tbl, str_signal);
+}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 3a299e0..cf1a3d2 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -28,6 +28,7 @@ sb_inc([rename])
sb_inc([renameat])
sb_inc([sb_printf])
sb_inc([script])
+sb_inc([signal_static])
sb_inc([symlink])
sb_inc([symlinkat])
sb_inc([vfork])