]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ipflib.sh
Import IP-Filter 5.1.2 into vendor branches using the existing license that
[FreeBSD/FreeBSD.git] / test / ipflib.sh
1 #!/bin/sh
2 #
3 # (C)opyright 2012 by Darren Reed.
4 #
5 # See the IPFILTER.LICENCE file for details on licencing.
6 #
7 test_init() {
8         mkdir -p results
9         find_touch
10         set_core $name 1
11 }
12
13 set_core() {
14         if [ -n "${FINDLEAKS}" -a -x /bin/mdb ] ; then
15                 _findleaks=1
16         else
17                 _findleaks=0
18         fi
19         if [ -x /bin/coreadm ] ; then
20                 _cn="$1.$2.core"
21                 coreadm -p "${PWD}/$_cn"
22         else
23                 _cn=
24         fi
25 }
26
27 test_end_leak() {
28         if [ $1 -ne 0 ] ; then
29                 if [ ${_findleaks} = 1 -a -f $_cn ] ; then
30                         echo "==== ${name}:${n} ====" >> leaktest
31                         echo '::findleaks' | mdb ../i86/ipftest $_cn >> leaktest
32                         rm $_cn
33                 else
34                         exit 2;
35                 fi
36         fi
37 }
38
39 check_results() {
40         cmp expected/$1 results/$1
41         status=$?
42         if [ $status = 0 ] ; then
43                 $TOUCH $1
44         fi
45 }
46
47 find_touch() {
48         if [ -f /bin/touch ] ; then
49                 TOUCH=/bin/touch
50         else
51                 if [ -f /usr/bin/touch ] ; then
52                         TOUCH=/usr/bin/touch
53                 else
54                         if [ -f /usr/ucb/touch ] ; then
55                                 TOUCH=/usr/ucb/touch
56                         fi
57                 fi
58         fi
59 }