]> The Tcpdump Group git mirrors - tcpdump/commitdiff
minor changes to detect core dumps better
authorMichael Richardson <[email protected]>
Sun, 15 Feb 2015 20:20:08 +0000 (15:20 -0500)
committerMichael Richardson <[email protected]>
Wed, 18 Feb 2015 01:20:53 +0000 (20:20 -0500)
tests/TESTonce
tests/TESTrun.sh

index fc6931e81ef7c1e9a8512cbaf2f40fe8d6b3dfd0..e58377b313aacaf2e72dc5224fede7cf69b41071 100755 (executable)
@@ -16,7 +16,13 @@ if ($^O eq 'MSWin32') {
   $r = system "..\\windump -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$output | diff $output - >DIFF/$output.diff";
 }
 else {
-  $r = system "../tcpdump 2>/dev/null -n -r $input $options | tee NEW/$output | diff $output - >DIFF/$output.diff";
+    # 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";
+    if($r == 0) {
+        $r = system "cat NEW/$output | diff $output - >DIFF/$output.diff";
+    }
+    #print sprintf("END: %08x\n", $r);
 }
 
 if($r == 0) {
@@ -28,15 +34,25 @@ printf "    %-30s: TEST FAILED", $name;
 open FOUT, '>>failure-outputs.txt';
 printf FOUT "Failed test: $name\n\n";
 close FOUT;
-system "cat DIFF/$output.diff >> failure-outputs.txt";
+if(-f "DIFF/$output.diff") {
+    system "cat DIFF/$output.diff >> failure-outputs.txt";
+}
 
 if($r == -1) {
   print " (failed to execute: $!)\n";
   exit 30;
 }
-if($r & 127) {
-  printf " (terminated with signal %u, %s coredump)\n", ($r & 127), ($r & 128) ? 'with' : 'without';
-  exit ($r & 128) ? 10 : 20;
+
+# this is not working right, $r == 0x8b00 when there is a core dump.
+# clearly, we need some platform specific perl magic to take this apart, so look for "core"
+# too.
+if($r & 127 || -f "core") {
+    my $with = ($r & 128) ? 'with' : 'without';
+    if(-f "core") {
+        $with = "with";
+    }
+    printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with;
+    exit ($r & 128) ? 10 : 20;
 }
 print "\n";
 exit $r >> 8;
index 924e5f5e53b37b864f36cc015d8988a2d08f1ca6..4cd04408ddd6ee83493b0a0a95a38e432cfaf9ea 100755 (executable)
@@ -31,6 +31,7 @@ runSimpleTests()
       \#*) continue;;
       '') continue;;
     esac
+    rm -f core
     [ "$only" != "" -a "$name" != "$only" ] && continue
     if ./TESTonce $name $input $output "$options"
     then