tests: prepare for parallel-tests support

* tests/Makefile.am (CLEANFILES): Calculate dynamically from TESTS.
* tests/init.sh (LOG): New variable.
* tests/detach-stopped: Use it.
* tests/net: Likewise.
* tests/qual_syscall: Likewise.
* tests/stat: Likewise.
* tests/strace-f: Likewise.
This commit is contained in:
Дмитрий Левин 2013-06-18 13:35:29 +00:00
parent f1669e7975
commit 107ceb935f
6 changed files with 36 additions and 33 deletions

View File

@ -8,4 +8,4 @@ TESTS = ptrace_setoptions strace-f qual_syscall stat net
EXTRA_DIST = init.sh $(TESTS)
CLEANFILES = check.log
CLEANFILES = $(TESTS:=.tmp)

View File

@ -2,6 +2,9 @@
ME_="${0##*/}"
LOG="$ME_.tmp"
rm -f "$LOG"
warn_() { printf >&2 '%s\n' "$*"; }
fail_() { warn_ "$ME_: failed test: $*"; exit 1; }
skip_() { warn_ "$ME_: skipped test: $*"; exit 77; }

View File

@ -9,29 +9,29 @@ check_timeout
check_prog grep
check_prog rm
rm -f check.log.*
rm -f $LOG.*
$TIMEOUT ./net-accept-connect ||
fail_ 'net-accept-connect failed'
args='-tt -ff -o check.log -enetwork ./net-accept-connect'
args="-tt -ff -o $LOG -enetwork ./net-accept-connect"
$TIMEOUT $STRACE $args ||
fail_ "strace $args failed"
"$srcdir"/../strace-log-merge check.log > check.log || {
cat check.log
"$srcdir"/../strace-log-merge $LOG > $LOG || {
cat $LOG
fail_ 'strace-log-merge failed'
}
rm -f check.log.*
rm -f $LOG.*
grep_log()
{
local syscall="$1"; shift
local prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +'
LC_ALL=C grep -E -x "$prefix$syscall$@" check.log > /dev/null || {
cat check.log
LC_ALL=C grep -E -x "$prefix$syscall$@" $LOG > /dev/null || {
cat $LOG
fail_ "strace -enetwork failed to trace \"$syscall\" properly"
}
}

View File

@ -9,19 +9,19 @@ check_timeout
check_prog ls
check_prog grep
$TIMEOUT $STRACE -e execve ls > /dev/null 2> check.log &&
grep '^execve(' check.log > /dev/null ||
{ cat check.log; fail_ 'strace -e execve does not work'; }
$TIMEOUT $STRACE -e execve ls > /dev/null 2> $LOG &&
grep '^execve(' $LOG > /dev/null ||
{ cat $LOG; fail_ 'strace -e execve does not work'; }
grep -v '^execve(' check.log |
grep -v '^execve(' $LOG |
LC_ALL=C grep '^[[:alnum:]_]*(' > /dev/null &&
{ cat check.log; fail_ 'strace -e execve does not work properly'; }
{ cat $LOG; fail_ 'strace -e execve does not work properly'; }
$TIMEOUT $STRACE -e trace=process ls > /dev/null 2> check.log &&
grep '^execve(' check.log > /dev/null ||
{ cat check.log; fail_ 'strace -e trace=process does not work'; }
$TIMEOUT $STRACE -e trace=process ls > /dev/null 2> $LOG &&
grep '^execve(' $LOG > /dev/null ||
{ cat $LOG; fail_ 'strace -e trace=process does not work'; }
grep '^open' check.log > /dev/null &&
{ cat check.log; fail_ 'strace -e trace=process does not work properly'; }
grep '^open' $LOG > /dev/null &&
{ cat $LOG; fail_ 'strace -e trace=process does not work properly'; }
exit 0

View File

@ -13,24 +13,24 @@ check_prog rm
umask 022
truncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample'
$truncate_cmd > check.log 2>&1 ||
{ cat check.log; framework_skip_ 'failed to create a large sparse file'; }
$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> check.log &&
LC_ALL=C grep -E -x 'ftruncate(64)?\(1, 46118400000\) += 0' check.log > /dev/null ||
{ cat check.log; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; }
$TIMEOUT $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' check.log > /dev/null ||
{ cat check.log; fail_ 'strace -edesc failed to trace lseek/_llseek 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> check.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' check.log > /dev/null ||
{ cat check.log; fail_ 'strace -efile failed to trace stat/stat64 properly'; }
$TIMEOUT $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> check.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' check.log > /dev/null ||
{ cat check.log; fail_ 'strace -efile failed to trace fstatat/fstatat64 properly'; }
$TIMEOUT $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'; }
rm -f sample

View File

@ -9,5 +9,5 @@ check_timeout
time=/usr/bin/time
check_prog $time
$TIMEOUT $STRACE -f $time /bin/ls > check.log 2>&1 ||
{ cat check.log; fail_ 'strace -f does not work'; }
$TIMEOUT $STRACE -f $time /bin/ls > $LOG 2>&1 ||
{ cat $LOG; fail_ 'strace -f does not work'; }