* 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.
# Automake input for strace.
+SUBDIRS = tests
+
bin_PROGRAMS = strace
man_MANS = strace.1
bin_SCRIPTS = strace-graph
AC_PATH_PROG([PERL], [perl])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile tests/Makefile])
AC_OUTPUT
--- /dev/null
+# Automake input for strace tests.
+
+TESTS = ptrace_setoptions strace-f
+
+EXTRA_DIST = init.sh $(TESTS)
+
+CLEANFILES = check.log
--- /dev/null
+#!/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"
+}
--- /dev/null
+#!/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'
--- /dev/null
+#!/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'; }