]>
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";
32 # this means tcpdump failed.
33 open(OUTPUT
, ">>"."NEW/$outputbase") || die "fail to open $outputbase\n";
34 printf OUTPUT
"EXIT CODE %08x\n", $r;
39 $r = system "cat NEW/$outputbase | diff $output - >DIFF/$outputbase.diff";
41 #print sprintf("END: %08x\n", $r);
45 printf " %-35s: passed\n", $name;
46 unlink "DIFF/$outputbase.diff";
49 printf " %-35s: TEST FAILED(%s)", $name, $r == -1 ?
$! : "exit $?";
50 open FOUT
, '>>failure-outputs.txt';
51 printf FOUT
"\nFailed test: $name\n\n";
53 if(-f
"DIFF/$outputbase.diff") {
54 system "cat DIFF/$outputbase.diff >> failure-outputs.txt";
58 print " (failed to execute: $!)\n";
62 # this is not working right, $r == 0x8b00 when there is a core dump.
63 # clearly, we need some platform specific perl magic to take this apart, so look for "core"
65 # In particular, on Solaris 10 SPARC an alignment problem results in SIGILL,
66 # a core dump and $r set to 0x00008a00 ($? == 138 in the shell).
67 if($r & 127 || -f
"core") {
68 my $with = ($r & 128) ?
'with' : 'without';
72 printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with;
73 exit ($r & 128) ?
10 : 20;