]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/test/natipftest
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / test / natipftest
1 #!/bin/sh
2 mode=$1
3 name=$2
4 input=$3
5 output=$4
6 shift
7 if [ $output = hex ] ; then
8         format="-xF $input"
9 else
10         format="-F $input"
11 fi
12 shift
13 shift
14 shift
15 while [ $# -ge 1 ] ; do
16         l=`echo $1 | cut -c1`
17         if [ "$l" = "-" ] ; then
18                 format="$format $1"
19         else
20                 format="-T $1 $format"
21         fi
22         shift
23 done
24 mkdir -p results
25 if [ -f /usr/ucb/touch ] ; then
26         TOUCH=/usr/ucb/touch
27 else
28         if [ -f /usr/bin/touch ] ; then
29                 TOUCH=/usr/bin/touch
30         else
31                 if [ -f /bin/touch ] ; then
32                         TOUCH=/bin/touch
33                 fi
34         fi
35 fi
36
37 case $mode in
38 single)
39         echo "$name...";
40         /bin/cp /dev/null results/$name
41         ( while read rule; do
42                 echo "$rule" | ../ipftest -R $format -b -r regress/$name.ipf -N - -i input/$name >> \
43                         results/$name;
44                 if [ $? -ne 0 ] ; then
45                         exit 1;
46                 fi
47                 echo "-------------------------------" >> results/$name
48         done ) < regress/$name.nat
49         cmp expected/$name results/$name
50         status=$?
51         if [ $status = 0 ] ; then
52                 $TOUCH $name
53         fi
54         ;;
55 multi)
56         echo "$name...";
57         /bin/cp /dev/null results/$name
58         ../ipftest -R $format -b -r regress/$name.ipf -N regress/$name.nat \
59                 -i input/$name >> results/$name;
60         if [ $? -ne 0 ] ; then
61                 exit 2;
62         fi
63         echo "-------------------------------" >> results/$name
64         cmp expected/$name results/$name
65         status=$?
66         if [ $status = 0 ] ; then
67                 $TOUCH $name
68         fi
69         ;;
70 esac
71 exit $status