]> The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTonce
CHANGES file for 4.7.2/4.7.3
[tcpdump] / tests / TESTonce
1 #!/usr/bin/env perl
2
3 system("mkdir -p NEW DIFF");
4
5 if(@ARGV != 4) {
6 print "Usage: TESTonce name input output options\n";
7 exit 20;
8 }
9
10 $name=$ARGV[0];
11 $input=$ARGV[1];
12 $output=$ARGV[2];
13 $options=$ARGV[3];
14
15 if ($^O eq 'MSWin32') {
16 $r = system "..\\windump -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$output | diff $output - >DIFF/$output.diff";
17 }
18 else {
19 # we used to do this as a nice pipeline, but the problem is that $r fails to
20 # to be set properly if the tcpdump core dumps.
21 $r = system "../tcpdump 2>/dev/null -n -r $input $options >NEW/$output";
22 if($r == 0) {
23 $r = system "cat NEW/$output | diff $output - >DIFF/$output.diff";
24 }
25 #print sprintf("END: %08x\n", $r);
26 }
27
28 if($r == 0) {
29 printf " %-30s: passed\n", $name;
30 unlink "DIFF/$output.diff";
31 exit 0;
32 }
33 printf " %-30s: TEST FAILED", $name;
34 open FOUT, '>>failure-outputs.txt';
35 printf FOUT "Failed test: $name\n\n";
36 close FOUT;
37 if(-f "DIFF/$output.diff") {
38 system "cat DIFF/$output.diff >> failure-outputs.txt";
39 }
40
41 if($r == -1) {
42 print " (failed to execute: $!)\n";
43 exit 30;
44 }
45
46 # this is not working right, $r == 0x8b00 when there is a core dump.
47 # clearly, we need some platform specific perl magic to take this apart, so look for "core"
48 # too.
49 if($r & 127 || -f "core") {
50 my $with = ($r & 128) ? 'with' : 'without';
51 if(-f "core") {
52 $with = "with";
53 }
54 printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with;
55 exit ($r & 128) ? 10 : 20;
56 }
57 print "\n";
58 exit $r >> 8;