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~692 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/a9363a57cb1e6b52be56dcf69303d4fc8b684673 make check needs to work in build directories --- diff --git a/Makefile.in b/Makefile.in index 35137173..401b5141 100644 --- a/Makefile.in +++ b/Makefile.in @@ -443,7 +443,7 @@ distclean: rm -rf autom4te.cache tests/DIFF tests/NEW check: tcpdump - (cd tests && ./TESTrun.sh) + (mkdir -p tests && cd tests && SRCDIR=${srcdir} ${srcdir}/tests/TESTrun.sh ) extags: $(TAGFILES) ctags $(TAGFILES) diff --git a/tests/TESTonce b/tests/TESTonce index 1e2fd68e..17717b20 100755 --- a/tests/TESTonce +++ b/tests/TESTonce @@ -2,6 +2,8 @@ $TCPDUMP = "../tcpdump" if (!($TCPDUMP = $ENV{TCPDUMP_BIN})); +use File::Basename; + system("mkdir -p NEW DIFF"); if(@ARGV != 4) { @@ -16,38 +18,40 @@ $options=$ARGV[3]; my $r; +$outputbase = basename($output); + if ($^O eq 'MSWin32') { - $r = system "..\\windump -# -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$output | diff $output - >DIFF/$output.diff"; + $r = system "..\\windump -# -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$outputbase | diff $output - >DIFF/$outputbase.diff"; # need to do same as below for Cygwin. } else { # we used to do this as a nice pipeline, but the problem is that $r fails to # to be set properly if the tcpdump core dumps. - $r = system "$TCPDUMP 2>/dev/null -# -n -r $input $options >NEW/$output"; + $r = system "$TCPDUMP 2>/dev/null -# -n -r $input $options >NEW/$outputbase"; if($r != 0) { # this means tcpdump failed. - open(OUTPUT, ">>"."NEW/$output") || die "fail to open $output\n"; + open(OUTPUT, ">>"."NEW/$outputbase") || die "fail to open $outputbase\n"; printf OUTPUT "EXIT CODE %08x\n", $r; close(OUTPUT); $r = 0; } if($r == 0) { - $r = system "cat NEW/$output | diff $output - >DIFF/$output.diff"; + $r = system "cat NEW/$outputbase | diff $output - >DIFF/$outputbase.diff"; } #print sprintf("END: %08x\n", $r); } if($r == 0) { printf " %-35s: passed\n", $name; - unlink "DIFF/$output.diff"; + unlink "DIFF/$outputbase.diff"; exit 0; } printf " %-35s: TEST FAILED(%s)", $name, $r == -1 ? $! : "exit $?"; open FOUT, '>>failure-outputs.txt'; printf FOUT "\nFailed test: $name\n\n"; close FOUT; -if(-f "DIFF/$output.diff") { - system "cat DIFF/$output.diff >> failure-outputs.txt"; +if(-f "DIFF/$outputbase.diff") { + system "cat DIFF/$outputbase.diff >> failure-outputs.txt"; } if($r == -1) { diff --git a/tests/TESTrun.sh b/tests/TESTrun.sh index 35daa95c..9acdcab5 100755 --- a/tests/TESTrun.sh +++ b/tests/TESTrun.sh @@ -1,6 +1,9 @@ #!/bin/sh TZ=GMT0; export TZ +srcdir=${SRCDIR-..} + +echo RUNNING from ${srcdir} mkdir -p NEW mkdir -p DIFF @@ -8,10 +11,10 @@ cat /dev/null > failure-outputs.txt runComplexTests() { - for i in *.sh + for i in ${srcdir}/*.sh do - case $i in TEST*.sh) continue;; esac - sh ./$i + case $i in ${srcdir}/TEST*.sh) continue;; esac + sh ./$i ${srcdir} done passed=`cat .passed` failed=`cat .failed` @@ -20,7 +23,7 @@ runComplexTests() runSimpleTests() { only=$1 - cat TESTLIST | while read name input output options + cat ${srcdir}/tests/TESTLIST | while read name input output options do case $name in \#*) continue;; @@ -28,7 +31,8 @@ runSimpleTests() esac rm -f core [ "$only" != "" -a "$name" != "$only" ] && continue - if ./TESTonce $name $input $output "$options" + export SRCDIR=${srcdir} + if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options" then passed=`expr $passed + 1` echo $passed >.passed