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