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