]> The Tcpdump Group git mirrors - tcpdump/commitdiff
make check needs to work in build directories
authorMichael Richardson <[email protected]>
Fri, 16 Aug 2019 19:30:31 +0000 (15:30 -0400)
committerMichael Richardson <[email protected]>
Sun, 18 Aug 2019 22:04:07 +0000 (18:04 -0400)
.gitignore
Makefile.in
tests/TESTonce
tests/TESTrun.sh

index 9c57945078444ef22157988ac2be750278901bca..6be02cdd6e959a76c12be029a2745cbc83b898af 100644 (file)
@@ -38,3 +38,5 @@ netdissect.dir/
 tcpdump.dir/
 tcpdump.sln
 .vs/
+.passed
+.failed
index 401b51412adc9007350bcef8162b4e78f29bc786..eb5faba6be63e770a17fb7df025c76134bbe363c 100644 (file)
@@ -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)
index 17717b207b8970b61bc65cb4ad79533429adf94b..72be028fba9a153ad1d79f0322ca9af40409156a 100755 (executable)
@@ -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;
index 9acdcab516b081e687be0b21c69ce26d94372768..9f66dcdac18ac30f81bc6a2396964be4adf66987 100755 (executable)
@@ -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.