]>
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 if ($^O
eq 'MSWin32') {
27 $r = system "..\\windump -# -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$outputbase | diff $output - >DIFF/$outputbase.diff";
28 # need to do same as below for Cygwin.
31 # we used to do this as a nice pipeline, but the problem is that $r fails to
32 # to be set properly if the tcpdump core dumps.
33 $r = system "$TCPDUMP 2>NEW/$outputbase.stderr -# -n -r $input $options >NEW/$outputbase";
37 # this means tcpdump failed.
38 open(OUTPUT
, ">>"."NEW/$outputbase") || die "fail to open $outputbase\n";
43 $status = WEXITSTATUS
($r);
46 printf OUTPUT
"EXIT CODE %08x: dump:%d code: %d\n", $r, $coredump, $status;
51 $r = system "cat NEW/$outputbase | diff $output - >DIFF/$outputbase.diff";
53 #print sprintf("END: %08x\n", $r);
57 printf " %-35s: passed\n", $name;
58 unlink "DIFF/$outputbase.diff";
61 printf " %-35s: TEST FAILED(%s)", $name, $r == -1 ?
$! : "exit core=$coredump/stat=$status";
62 open FOUT
, '>>failure-outputs.txt';
63 printf FOUT
"\nFailed test: $name\n\n";
65 if(-f
"DIFF/$outputbase.diff") {
66 system "cat DIFF/$outputbase.diff >> failure-outputs.txt";
70 print " (failed to execute: $!)\n";
74 # this is not working right, $r == 0x8b00 when there is a core dump.
75 # clearly, we need some platform specific perl magic to take this apart, so look for "core"
77 # In particular, on Solaris 10 SPARC an alignment problem results in SIGILL,
78 # a core dump and $r set to 0x00008a00 ($? == 138 in the shell).
79 if($r & 127 || -f
"core") {
80 my $with = ($r & 128) ?
'with' : 'without';
84 printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with;
85 exit ($r & 128) ?
10 : 20;