2007-08-29 10:36:04 +08:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
system("mkdir -p NEW DIFF");
|
|
|
|
|
2014-01-20 19:26:06 +08:00
|
|
|
if(@ARGV != 4) {
|
|
|
|
print "Usage: TESTonce name input output options\n";
|
|
|
|
exit 20;
|
|
|
|
}
|
2007-08-29 10:36:04 +08:00
|
|
|
|
2014-01-20 19:26:06 +08:00
|
|
|
$name=$ARGV[0];
|
|
|
|
$input=$ARGV[1];
|
|
|
|
$output=$ARGV[2];
|
|
|
|
$options=$ARGV[3];
|
2007-08-29 10:36:04 +08:00
|
|
|
|
2014-01-31 10:49:56 +08:00
|
|
|
$r = system "../tcpdump 2>/dev/null -n -r $input $options | tee NEW/$output | diff -w $output - >DIFF/$output.diff";
|
2007-08-29 10:36:04 +08:00
|
|
|
|
2014-01-20 19:26:06 +08:00
|
|
|
if($r == 0) {
|
2014-01-20 21:27:18 +08:00
|
|
|
printf " %-30s: passed\n", $name;
|
2014-01-20 19:26:06 +08:00
|
|
|
unlink "DIFF/$output.diff";
|
|
|
|
exit 0;
|
2007-08-29 10:36:04 +08:00
|
|
|
}
|
2014-01-20 21:27:18 +08:00
|
|
|
printf " %-30s: TEST FAILED", $name;
|
2014-01-20 19:26:06 +08:00
|
|
|
open FOUT, '>>failure-outputs.txt';
|
|
|
|
printf FOUT "Failed test: $name\n\n";
|
|
|
|
close FOUT;
|
|
|
|
system "cat DIFF/$output.diff >> failure-outputs.txt";
|
2007-08-29 10:36:04 +08:00
|
|
|
|
2014-01-20 19:26:06 +08:00
|
|
|
if($r == -1) {
|
|
|
|
print " (failed to execute: $!)\n";
|
|
|
|
exit 30;
|
|
|
|
}
|
|
|
|
if($r & 127) {
|
|
|
|
printf " (terminated with signal %u, %s coredump)\n", ($r & 127), ($r & 128) ? 'with' : 'without';
|
|
|
|
exit ($r & 128) ? 10 : 20;
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
exit $r >> 8;
|