]>
The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTonce
3 $TCPDUMP = "../tcpdump" if (!($TCPDUMP = $ENV{TCPDUMP_BIN
}));
6 use POSIX
qw( WEXITSTATUS WIFEXITED);
8 system("mkdir -p NEW DIFF");
11 print "Usage: TESTonce name input output options\n";
22 $outputbase = basename
($output);
26 my $stderrlog = "NEW/${outputbase}.stderr";
29 if ($^O
eq 'MSWin32') {
30 $r = system "..\\windump -# -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$outputbase | diff $output - >DIFF/$outputbase.diff";
31 # need to do same as below for Cygwin.
34 # we used to do this as a nice pipeline, but the problem is that $r fails to
35 # to be set properly if the tcpdump core dumps.
36 $r = system "$TCPDUMP 2>${stderrlog} -# -n -r $input $options >NEW/${outputbase}";
38 # failed to start due to error.
44 # this means tcpdump failed.
45 open(OUTPUT
, ">>"."NEW/$outputbase") || die "fail to open $outputbase\n";
50 $status = WEXITSTATUS
($r);
53 printf OUTPUT
"EXIT CODE %08x: dump:%d code: %d\n", $r, $coredump, $status;
58 $r = system "cat NEW/$outputbase | diff $output - >DIFF/$outputbase.diff";
59 $diffstat = WEXITSTATUS
($r);
63 open(ERROROUT
, "<" . $stderrlog);
65 next if /^$/; # blank lines are boring
66 next if /^reading from file/; # stock output boring too
74 #print sprintf("END: %08x\n", $r);
80 $stderrlog=sprintf("%d lines in stderr", $linecount);
82 printf " %-35s: passed%s\n", $name, $stderrlog;
83 unlink "DIFF/$outputbase.diff";
87 printf " %-35s: TEST FAILED(exit core=%d/diffstat=%d/r=%d)", $name, $coredump, $diffstat, $r;
88 open FOUT
, '>>failure-outputs.txt';
89 printf FOUT
"\nFailed test: $name\n\n";
91 if(-f
"DIFF/$outputbase.diff") {
92 system "cat DIFF/$outputbase.diff >> failure-outputs.txt";
96 print " (failed to execute: $!)\n";
100 # this is not working right, $r == 0x8b00 when there is a core dump.
101 # clearly, we need some platform specific perl magic to take this apart, so look for "core"
103 # In particular, on Solaris 10 SPARC an alignment problem results in SIGILL,
104 # a core dump and $r set to 0x00008a00 ($? == 138 in the shell).
105 if($r & 127 || -f
"core") {
106 my $with = ($r & 128) ?
'with' : 'without';
110 printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with;
111 exit ($r & 128) ?
10 : 20;