]> granicus.if.org Git - strace/commitdiff
tests: enhance timeout checks
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 18 Jun 2013 15:28:47 +0000 (15:28 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 18 Jun 2013 17:07:37 +0000 (17:07 +0000)
Run each test using a wrapper that does all necessary timeout checks.

* tests/run.sh: New file.
* tests/Makefile.am (EXTRA_DIST, LOG_COMPILER): Add it.
* tests/init.sh (check_strace, check_timeout): Remove.
* tests/detach-stopped: Update callers.
* tests/net: Likewise.
* tests/ptrace_setoptions: Likewise.
* tests/qual_syscall: Likewise.
* tests/stat: Likewise.
* tests/strace-f: Likewise.

tests/Makefile.am
tests/init.sh
tests/net
tests/ptrace_setoptions
tests/qual_syscall
tests/run.sh [new file with mode: 0755]
tests/stat
tests/strace-f

index c72fc9dae91f5471b8f249920083660e9160e8d8..a437f4a786c6f3d51acddd983aac70bce45d8fdb 100644 (file)
@@ -6,6 +6,8 @@ check_PROGRAMS = net-accept-connect
 
 TESTS = ptrace_setoptions strace-f qual_syscall stat net
 
-EXTRA_DIST = init.sh $(TESTS)
+LOG_COMPILER = $(srcdir)/run.sh
+
+EXTRA_DIST = init.sh run.sh $(TESTS)
 
 CLEANFILES = $(TESTS:=.tmp)
index c6297c11c5da824e3370008a3ad2d78c13d07974..a3ff2f85455080380fed7ae776d44d8e14bc4096 100644 (file)
@@ -17,17 +17,5 @@ check_prog()
                framework_skip_ "$* is not available"
 }
 
-check_strace()
-{
-       STRACE=${*:-../strace}
-       $STRACE -V > /dev/null ||
-               framework_failure_ "$STRACE is not available"
-}
-
-timeout_duration=60
-check_timeout()
-{
-       TIMEOUT="timeout -s 9 $timeout_duration"
-       $TIMEOUT true > /dev/null 2>&1 ||
-               TIMEOUT=
-}
+: "${STRACE:=../strace}"
+: "${TIMEOUT_DURATION:=60}"
index 044808e875ad76e9e37250c02cdaa06caa137204..de1dae14afe0c43017228c9ed4db1bb955e59c30 100755 (executable)
--- a/tests/net
+++ b/tests/net
@@ -4,18 +4,16 @@
 
 . "${srcdir=.}/init.sh"
 
-check_strace
-check_timeout
 check_prog grep
 check_prog rm
 
 rm -f $LOG.*
 
-$TIMEOUT ./net-accept-connect ||
+./net-accept-connect ||
        fail_ 'net-accept-connect failed'
 
 args="-tt -ff -o $LOG -enetwork ./net-accept-connect"
-$TIMEOUT $STRACE $args ||
+$STRACE $args ||
        fail_ "strace $args failed"
 
 "$srcdir"/../strace-log-merge $LOG > $LOG || {
index 38a2a0235f611d38482e38c12b9388521c4b8101..e574e24ae6e4c217d1f198f16e8df47cdcc05f2f 100755 (executable)
@@ -12,17 +12,19 @@ case "$(uname -r)" in
        *) skip_ 'The kernel is not Linux 2.6.* or newer' ;;
 esac
 
-check_strace
-check_timeout
+$STRACE -df -enone / > /dev/null 2> $LOG
+grep -F -x 'ptrace_setoptions = 0xe' $LOG > /dev/null || {
+       cat $LOG
+       fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACECLONE support'
+}
 
-$TIMEOUT $STRACE -df -enone / 2>&1 |
-       grep -F -x 'ptrace_setoptions = 0xe' > /dev/null ||
-               fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACECLONE support'
+grep -F -x 'ptrace_setoptions = 0x1f' $LOG > /dev/null || {
+       cat $LOG
+       fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
+}
 
-$TIMEOUT $STRACE -df -enone / 2>&1 |
-       grep -F -x 'ptrace_setoptions = 0x1f' > /dev/null ||
-               fail_ 'strace -f failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
-
-$TIMEOUT $STRACE -d -enone / 2>&1 |
-       grep -F -x 'ptrace_setoptions = 0x11' > /dev/null ||
-               fail_ 'strace failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
+$STRACE -d -enone / > /dev/null 2> $LOG
+grep -F -x 'ptrace_setoptions = 0x11' $LOG > /dev/null || {
+       cat $LOG
+       fail_ 'strace failed to recognize proper kernel PTRACE_O_TRACESYSGOOD support'
+}
index 9d75fcae2ef80e2535303c5f4ffbe60b3eac5638..652fcdb30deadb17067ffa96319e2b5fec252e97 100755 (executable)
@@ -4,12 +4,10 @@
 
 . "${srcdir=.}/init.sh"
 
-check_strace
-check_timeout
 check_prog ls
 check_prog grep
 
-$TIMEOUT $STRACE -e execve ls > /dev/null 2> $LOG &&
+$STRACE -e execve ls > /dev/null 2> $LOG &&
 grep '^execve(' $LOG > /dev/null ||
        { cat $LOG; fail_ 'strace -e execve does not work'; }
 
@@ -17,7 +15,7 @@ grep -v '^execve(' $LOG |
 LC_ALL=C grep '^[[:alnum:]_]*(' > /dev/null &&
        { cat $LOG; fail_ 'strace -e execve does not work properly'; }
 
-$TIMEOUT $STRACE -e trace=process ls > /dev/null 2> $LOG &&
+$STRACE -e trace=process ls > /dev/null 2> $LOG &&
 grep '^execve(' $LOG > /dev/null ||
        { cat $LOG; fail_ 'strace -e trace=process does not work'; }
 
diff --git a/tests/run.sh b/tests/run.sh
new file mode 100755 (executable)
index 0000000..02d9912
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+. "${srcdir=.}/init.sh"
+
+$STRACE -V > /dev/null ||
+       framework_failure_ "$STRACE is not available"
+
+TIMEOUT="timeout -s 9 $TIMEOUT_DURATION"
+$TIMEOUT true > /dev/null 2>&1 ||
+       TIMEOUT=
+
+exec $TIMEOUT "$@"
index 013243b656795340a5fe75dd8d497c5b3c4353e4..4176df0edb6f2cb69473161264fea5a86d6ace5c 100755 (executable)
@@ -4,8 +4,6 @@
 
 . "${srcdir=.}/init.sh"
 
-check_strace
-check_timeout
 check_prog dd
 check_prog find
 check_prog grep
@@ -17,18 +15,18 @@ $truncate_cmd > $LOG 2>&1 ||
        { cat $LOG; framework_skip_ 'failed to create a large sparse file'; }
 rm -f sample
 
-$TIMEOUT $STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> $LOG &&
+$STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> $LOG &&
 LC_ALL=C grep -E -x 'ftruncate(64)?\(1, 46118400000\) += 0' $LOG > /dev/null ||
        { cat $LOG; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; }
 
 LC_ALL=C grep -E -x 'lseek\(1, 46118400000, SEEK_CUR\) += 46118400000|_llseek\(1, 46118400000, \[46118400000\], SEEK_CUR\) += 0' $LOG > /dev/null ||
        { cat $LOG; fail_ 'strace -edesc failed to trace lseek/_llseek properly'; }
 
-$TIMEOUT $STRACE -efile find -L sample > /dev/null 2> $LOG &&
+$STRACE -efile find -L sample > /dev/null 2> $LOG &&
 LC_ALL=C grep -E -x 'stat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, 0\) += 0' $LOG > /dev/null ||
        { cat $LOG; fail_ 'strace -efile failed to trace stat/stat64 properly'; }
 
-$TIMEOUT $STRACE -efile find sample > /dev/null 2> $LOG &&
+$STRACE -efile find sample > /dev/null 2> $LOG &&
 LC_ALL=C grep -E -x 'lstat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, AT_SYMLINK_NOFOLLOW\) += 0' $LOG > /dev/null ||
        { cat $LOG; fail_ 'strace -efile failed to trace fstatat/fstatat64 properly'; }
 
index 20fd943748c092eea151803d2446fb63dc2ad3e8..0c4622c5e0a851a04ea4ff2ab0c7607a34a40c13 100755 (executable)
@@ -4,10 +4,8 @@
 
 . "${srcdir=.}/init.sh"
 
-check_strace
-check_timeout
 time=/usr/bin/time
 check_prog $time
 
-$TIMEOUT $STRACE -f $time /bin/ls > $LOG 2>&1 ||
+$STRACE -f $time /bin/ls > $LOG 2>&1 ||
        { cat $LOG; fail_ 'strace -f does not work'; }