From: Michael Richardson Date: Fri, 16 Aug 2019 19:30:31 +0000 (-0400) Subject: make check needs to work in build directories X-Git-Tag: tcpdump-4.99-bp~690 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/1832cc80da12f8f5d43586524f5850c7918a8d06 make check needs to work in build directories --- diff --git a/.gitignore b/.gitignore index 9c579450..6be02cdd 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ netdissect.dir/ tcpdump.dir/ tcpdump.sln .vs/ +.passed +.failed diff --git a/Makefile.in b/Makefile.in index 401b5141..eb5faba6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -443,7 +443,7 @@ distclean: rm -rf autom4te.cache tests/DIFF tests/NEW check: tcpdump - (mkdir -p tests && cd tests && SRCDIR=${srcdir} ${srcdir}/tests/TESTrun.sh ) + (mkdir -p tests && export SRCDIR=$$(cd ${srcdir}; pwd) && $${SRCDIR}/tests/TESTrun.sh ) extags: $(TAGFILES) ctags $(TAGFILES) diff --git a/tests/TESTonce b/tests/TESTonce index 17717b20..72be028f 100755 --- a/tests/TESTonce +++ b/tests/TESTonce @@ -3,6 +3,7 @@ $TCPDUMP = "../tcpdump" if (!($TCPDUMP = $ENV{TCPDUMP_BIN})); use File::Basename; +use POSIX qw( WEXITSTATUS WIFEXITED); system("mkdir -p NEW DIFF"); @@ -19,6 +20,8 @@ $options=$ARGV[3]; my $r; $outputbase = basename($output); +my $coredump = false; +my $status = 0; if ($^O eq 'MSWin32') { $r = system "..\\windump -# -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$outputbase | diff $output - >DIFF/$outputbase.diff"; @@ -31,7 +34,14 @@ else { if($r != 0) { # this means tcpdump failed. open(OUTPUT, ">>"."NEW/$outputbase") || die "fail to open $outputbase\n"; - printf OUTPUT "EXIT CODE %08x\n", $r; + if( $r & 128 ) { + $coredump = $r & 127; + } + if( WIFEXITED($r)) { + $status = WEXITSTATUS($r); + } + + printf OUTPUT "EXIT CODE %08x: dump:%d code: %d\n", $r, $coredump, $status; close(OUTPUT); $r = 0; } @@ -46,7 +56,7 @@ if($r == 0) { unlink "DIFF/$outputbase.diff"; exit 0; } -printf " %-35s: TEST FAILED(%s)", $name, $r == -1 ? $! : "exit $?"; +printf " %-35s: TEST FAILED(%s)", $name, $r == -1 ? $! : "exit core=$coredump/stat=$status"; open FOUT, '>>failure-outputs.txt'; printf FOUT "\nFailed test: $name\n\n"; close FOUT; diff --git a/tests/TESTrun.sh b/tests/TESTrun.sh index 9acdcab5..9f66dcda 100755 --- a/tests/TESTrun.sh +++ b/tests/TESTrun.sh @@ -5,16 +5,28 @@ srcdir=${SRCDIR-..} echo RUNNING from ${srcdir} -mkdir -p NEW -mkdir -p DIFF +# make it absolute +srcdir=$(cd $srcdir && pwd) + +# this should be run from the compiled build directory, +# with srcdir= set to wherever the source code is. +# not from the tests directory. +echo RUNNING from ${srcdir} + +mkdir -p tests/NEW +mkdir -p tests/DIFF cat /dev/null > failure-outputs.txt runComplexTests() { - for i in ${srcdir}/*.sh + for i in ${srcdir}/tests/*.sh do - case $i in ${srcdir}/TEST*.sh) continue;; esac - sh ./$i ${srcdir} + case $i in + ${srcdir}/tests/TEST*.sh) continue;; + ${srcdir}/tests/\*.sh) continue;; + esac + echo Running $i + (cd tests && sh $i ${srcdir}) done passed=`cat .passed` failed=`cat .failed` @@ -32,6 +44,7 @@ runSimpleTests() rm -f core [ "$only" != "" -a "$name" != "$only" ] && continue export SRCDIR=${srcdir} + (cd tests # run TESTonce in tests directory if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options" then passed=`expr $passed + 1` @@ -39,7 +52,7 @@ runSimpleTests() else failed=`expr $failed + 1` echo $failed >.failed - fi + fi) [ "$only" != "" -a "$name" = "$only" ] && break done # I hate shells with their stupid, useless subshells.