summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2011-02-27 00:28:50 +0000
committerDmitry V. Levin <ldv@altlinux.org>2011-02-27 00:28:50 +0000
commit4e4b5adfab00af3969e4352da85c1f5553d280bc (patch)
tree16b73deb77847f61d1eaccb1013b5de8174e8bd2
parent6ae37bf0eb4c7911141cb25f3501e460ae4edadc (diff)
downloadstrace-4e4b5adfab00af3969e4352da85c1f5553d280bc.tar.gz
Implement two basic "strace -f" tests
* Makefile.am (SUBDIRS): Add tests. * configure.ac (AC_CONFIG_FILES): Add tests/Makefile. * tests/.gitignore: New file. * tests/Makefile.am: Likewise. * tests/init.sh: Likewise. * tests/ptrace_setoptions: Likewise. * tests/strace-f: Likewise.
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac2
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/init.sh21
-rwxr-xr-xtests/ptrace_setoptions18
-rwxr-xr-xtests/strace-f14
7 files changed, 64 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 4082cb348..f623b9d9f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,7 @@
# Automake input for strace.
+SUBDIRS = tests
+
bin_PROGRAMS = strace
man_MANS = strace.1
bin_SCRIPTS = strace-graph
diff --git a/configure.ac b/configure.ac
index 5d56dabcd..ca1694bdc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -309,5 +309,5 @@ AC_CHECK_DECLS([sys_siglist, _sys_siglist],,, [#include <signal.h>])
AC_PATH_PROG([PERL], [perl])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile tests/Makefile])
AC_OUTPUT
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 000000000..cf5bbd7d2
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+check.log
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 000000000..93636ca8f
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,7 @@
+# Automake input for strace tests.
+
+TESTS = ptrace_setoptions strace-f
+
+EXTRA_DIST = init.sh $(TESTS)
+
+CLEANFILES = check.log
diff --git a/tests/init.sh b/tests/init.sh
new file mode 100644
index 000000000..a016b1c8e
--- /dev/null
+++ b/tests/init.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+ME_="${0##*/}"
+
+warn_() { printf >&2 '%s\n' "$*"; }
+fail_() { warn_ "$ME_: failed test: $*"; exit 1; }
+skip_() { warn_ "$ME_: skipped test: $*"; exit 77; }
+framework_failure_() { warn_ "$ME_: framework failure: $*"; exit 99; }
+
+check_prog()
+{
+ "$@" --version > /dev/null 2>&1 ||
+ framework_failure_ "$* is not available"
+}
+
+check_strace()
+{
+ STRACE=${*-../strace}
+ $STRACE -V > /dev/null ||
+ framework_failure_ "$STRACE is not available"
+}
diff --git a/tests/ptrace_setoptions b/tests/ptrace_setoptions
new file mode 100755
index 000000000..b0a1c8795
--- /dev/null
+++ b/tests/ptrace_setoptions
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Ensure that strace tests kernel PTRACE_O_TRACECLONE support properly.
+
+. "${srcdir=.}/init.sh"
+
+case "$(uname -rs)" in
+ Linux\ 2.6.*) ;;
+ *) skip_ 'The kernel is not Linux 2.6.*' ;;
+esac
+
+check_strace
+check_prog timeout
+
+timeout -s 9 9 \
+$STRACE -df -enone /bin/true 2>&1 |
+ fgrep -qx 'ptrace_setoptions = 0xe' ||
+ fail_ 'strace failed to recognize proper kernel PTRACE_O_TRACECLONE support'
diff --git a/tests/strace-f b/tests/strace-f
new file mode 100755
index 000000000..869f331df
--- /dev/null
+++ b/tests/strace-f
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Ensure that strace -f works.
+
+. "${srcdir=.}/init.sh"
+
+check_strace
+check_prog timeout
+time=/usr/bin/time
+check_prog $time
+
+timeout -s 9 9 \
+$STRACE -f $time /bin/ls > check.log 2>&1 ||
+ { cat check.log; fail_ 'strace -f does not work'; }