]>
The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTonce
3 $TCPDUMP = "../tcpdump" if (!($TCPDUMP = $ENV{TCPDUMP_BIN
}));
5 system("mkdir -p NEW DIFF");
8 print "Usage: TESTonce name input output options\n";
19 if ($^O
eq 'MSWin32') {
20 $r = system "..\\windump -# -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$output | diff $output - >DIFF/$output.diff";
21 # need to do same as below for Cygwin.
24 # we used to do this as a nice pipeline, but the problem is that $r fails to
25 # to be set properly if the tcpdump core dumps.
26 $r = system "$TCPDUMP 2>/dev/null -# -n -r $input $options >NEW/$output";
28 # this means tcpdump failed.
29 open(OUTPUT
, ">>"."NEW/$output") || die "fail to open $output\n";
30 printf OUTPUT
"EXIT CODE %08x\n", $r;
35 $r = system "cat NEW/$output | diff $output - >DIFF/$output.diff";
37 #print sprintf("END: %08x\n", $r);
41 printf " %-35s: passed\n", $name;
42 unlink "DIFF/$output.diff";
45 printf " %-35s: TEST FAILED(%s)", $name, $r == -1 ?
$! : "exit $?";
46 open FOUT
, '>>failure-outputs.txt';
47 printf FOUT
"\nFailed test: $name\n\n";
49 if(-f
"DIFF/$output.diff") {
50 system "cat DIFF/$output.diff >> failure-outputs.txt";
54 print " (failed to execute: $!)\n";
58 # this is not working right, $r == 0x8b00 when there is a core dump.
59 # clearly, we need some platform specific perl magic to take this apart, so look for "core"
61 # In particular, on Solaris 10 SPARC an alignment problem results in SIGILL,
62 # a core dump and $r set to 0x00008a00 ($? == 138 in the shell).
63 if($r & 127 || -f
"core") {
64 my $with = ($r & 128) ?
'with' : 'without';
68 printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with;
69 exit ($r & 128) ?
10 : 20;