xref: /netbsd/external/bsd/tcpdump/dist/tests/TESTonce (revision 6550d01e)
1#!/usr/bin/perl
2
3system("mkdir -p NEW DIFF");
4
5if(@ARGV == 1) {
6  open(TESTLIST, "TESTLIST") || die "can not open TESTLIST: $!\n";
7  $wanted = $ARGV[0];
8  #print "Searching for test case $wanted\n";
9  while(<TESTLIST>) {
10    #print "Processing $_\n";
11    next unless (/^$wanted/);
12
13    chop;
14    ($name,$input,$output,$options)=split(/\s+/,$_, 4);
15    last;
16  }
17  close(TESTLIST);
18
19  die "Can not find test $wanted\n" unless defined($input);
20
21} elsif(@ARGV == 4) {
22  $name=$ARGV[0];
23  $input=$ARGV[1];
24  $output=$ARGV[2];
25  $options=$ARGV[3];
26} else {
27  print "Usage: TESTonce name [input output options]\n";
28  exit 20;
29}
30
31print "Running $name. \n";
32print "   Input: $input, OUTPUT: $output, OPTIONS: $options\n";
33
34if (! -f $input) {
35  ($puu = $input) =~ s/\.pcap/\.puu/;
36  if( -f $puu) {
37    print "Uudecoding $puu to make $input\n";
38    system("uudecode $puu");
39  }
40}
41
42print "    ";
43exec("../tcpdump -n -r $input $options | tee NEW/$output | diff -w - $output >DIFF/$output.diff");
44@cores = glob("core*");
45exit 10 if (@cores > 0);
46exit 0;
47