]> The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTonce
Update TESTonce
[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 | tee NEW/$output | diff -w $output - >DIFF/$output.diff";
17 }
18 else {
19 $r = system "../tcpdump 2>/dev/null -n -r $input $options | tee NEW/$output | diff -w $output - >DIFF/$output.diff";
20 }
21
22 if($r == 0) {
23 printf " %-30s: passed\n", $name;
24 unlink "DIFF/$output.diff";
25 exit 0;
26 }
27 printf " %-30s: TEST FAILED", $name;
28 open FOUT, '>>failure-outputs.txt';
29 printf FOUT "Failed test: $name\n\n";
30 close FOUT;
31 system "cat DIFF/$output.diff >> failure-outputs.txt";
32
33 if($r == -1) {
34 print " (failed to execute: $!)\n";
35 exit 30;
36 }
37 if($r & 127) {
38 printf " (terminated with signal %u, %s coredump)\n", ($r & 127), ($r & 128) ? 'with' : 'without';
39 exit ($r & 128) ? 10 : 20;
40 }
41 print "\n";
42 exit $r >> 8;