diff --git a/tests/Makefile.am b/tests/Makefile.am index a7f584d3..c72fc9da 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,4 +8,4 @@ TESTS = ptrace_setoptions strace-f qual_syscall stat net EXTRA_DIST = init.sh $(TESTS) -CLEANFILES = check.log +CLEANFILES = $(TESTS:=.tmp) diff --git a/tests/init.sh b/tests/init.sh index db7f1025..c6297c11 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -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; } diff --git a/tests/net b/tests/net index 64bcc772..044808e8 100755 --- a/tests/net +++ b/tests/net @@ -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" } } diff --git a/tests/qual_syscall b/tests/qual_syscall index f382f1ab..9d75fcae 100755 --- a/tests/qual_syscall +++ b/tests/qual_syscall @@ -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 diff --git a/tests/stat b/tests/stat index e0fc3799..013243b6 100755 --- a/tests/stat +++ b/tests/stat @@ -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 diff --git a/tests/strace-f b/tests/strace-f index 0f76afc1..20fd9437 100755 --- a/tests/strace-f +++ b/tests/strace-f @@ -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'; }