tcpdump/tests/TESTonce

38 lines
838 B
Plaintext
Raw Normal View History

#!/usr/bin/perl
system("mkdir -p NEW DIFF");
if(@ARGV != 4) {
print "Usage: TESTonce name input output options\n";
exit 20;
}
$name=$ARGV[0];
$input=$ARGV[1];
$output=$ARGV[2];
$options=$ARGV[3];
$r = system "../tcpdump 2>/dev/null -n -r $input $options | tee NEW/$output | diff -w $output - >DIFF/$output.diff";
if($r == 0) {
printf " %-30s: passed\n", $name;
unlink "DIFF/$output.diff";
exit 0;
}
printf " %-30s: TEST FAILED", $name;
open FOUT, '>>failure-outputs.txt';
printf FOUT "Failed test: $name\n\n";
close FOUT;
system "cat DIFF/$output.diff >> failure-outputs.txt";
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;