]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - testdata/08-host-lib.tdir/08-host-lib.test
Vendor import of Unbound 1.6.6.
[FreeBSD/FreeBSD.git] / testdata / 08-host-lib.tdir / 08-host-lib.test
1 # #-- 08-host-lib.test --#
2 # source the master var file when it's there
3 [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
4 # use .tpkg.var.test for in test variable passing
5 [ -f .tpkg.var.test ] && source .tpkg.var.test
6
7 PRE="../.."
8 . ../common.sh
9
10 if grep FORK $PRE/config.h | grep "define" >/dev/null 2>&1; then
11         # nothing
12         :
13 else
14         echo "forking is not available; test skipped."
15         exit 0
16 fi
17
18 # test if fwder is up
19 echo "> dig @127.0.0.1 -p $FWD_PORT www.example.com | tee outfile"
20 dig @127.0.0.1 -p $FWD_PORT www.example.com | tee outfile
21 if grep "10.20.30.40" outfile; then
22         echo "fwder is up"
23 else
24         cat fwd.log
25         echo "fwder not up"
26         exit 1
27 fi
28 rm outfile
29
30 # create asynclook
31 get_make
32 echo "> (cd $PRE ; $MAKE asynclook)"
33 (cd $PRE ; $MAKE asynclook)
34 if test ! -x $PRE/asynclook; then
35         echo "cannot build asynclook test program"
36         exit 1
37 fi
38 (cd $PRE ; $MAKE lock-verify)
39
40 # check the locks.
41 function locktest() {
42         if test -x $PRE/lock-verify -a -f ublocktrace.0; then
43                 $PRE/lock-verify ublocktrace.*
44                 if test $? -ne 0; then
45                         echo "lock-verify error"
46                         exit 1
47                 fi
48         fi
49 }
50
51 # test hosts reading (directed at local auth info)
52 echo '> $PRE/asynclook -H 08-host-lib.hosts virtual.virtual.virtual.local 2>&1 | tee outfile'
53 $PRE/asynclook -H 08-host-lib.hosts virtual.virtual.virtual.local 2>&1 | tee outfile
54 if grep "virtual.virtual.virtual.local: 10.20.30.40" outfile; then
55         echo "OK"
56 else
57         echo "Not OK"
58         exit 1
59 fi
60 locktest
61 rm outfile
62
63 # test async lookups (directed at testns)
64 echo '> $PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com 2>&1 | tee outfile'
65 $PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com 2>&1 | tee outfile
66 if grep "www.example.com: 10.20.30.40" outfile; then
67         echo "OK"
68 else
69         cat fwd.log
70         echo "Not OK"
71         exit 1
72 fi
73 locktest
74 rm outfile
75
76 echo '> $PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
77 $PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
78 if grep "www.example.com: 10.20.30.40" outfile; then
79         echo "OK"
80 else
81         cat fwd.log
82         echo "Not OK"
83         exit 1
84 fi
85 if grep "www2.example.com: 10.20.30.42" outfile; then
86         echo "OK"
87 else
88         cat fwd.log
89         echo "Not OK"
90         exit 1
91 fi
92 locktest
93 rm outfile
94
95 echo '> $PRE/asynclook -t -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
96 $PRE/asynclook -t -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
97 if grep "www.example.com: 10.20.30.40" outfile; then
98         echo "OK"
99 else
100         cat fwd.log
101         echo "Not OK"
102         exit 1
103 fi
104 if grep "www2.example.com: 10.20.30.42" outfile; then
105         echo "OK"
106 else
107         cat fwd.log
108         echo "Not OK"
109         exit 1
110 fi
111 locktest
112 rm outfile
113
114 # test cancellation
115 echo '> $PRE/asynclook -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
116 $PRE/asynclook -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
117 if grep "www.example.com: cancelled" outfile; then
118         echo "OK"
119 else
120         cat fwd.log
121         echo "Not OK"
122         exit 1
123 fi
124 if grep "www2.example.com: cancelled" outfile; then
125         echo "OK"
126 else
127         cat fwd.log
128         echo "Not OK"
129         exit 1
130 fi
131 locktest
132 rm outfile
133
134 echo '> $PRE/asynclook -t -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
135 $PRE/asynclook -t -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
136 if grep "www.example.com: cancelled" outfile; then
137         echo "OK"
138 else
139         cat fwd.log
140         echo "Not OK"
141         exit 1
142 fi
143 if grep "www2.example.com: cancelled" outfile; then
144         echo "OK"
145 else
146         cat fwd.log
147         echo "Not OK"
148         exit 1
149 fi
150 locktest
151 rm outfile
152
153 # test blocking mode
154 echo '> $PRE/asynclook -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
155 $PRE/asynclook -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
156 if grep "www.example.com: 10.20.30.40" outfile; then
157         echo "OK"
158 else
159         cat fwd.log
160         echo "Not OK"
161         exit 1
162 fi
163 if grep "www2.example.com: 10.20.30.42" outfile; then
164         echo "OK"
165 else
166         cat fwd.log
167         echo "Not OK"
168         exit 1
169 fi
170 locktest
171 rm outfile
172
173 echo '> $PRE/asynclook -t -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
174 $PRE/asynclook -t -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
175 if grep "www.example.com: 10.20.30.40" outfile; then
176         echo "OK"
177 else
178         cat fwd.log
179         echo "Not OK"
180         exit 1
181 fi
182 if grep "www2.example.com: 10.20.30.42" outfile; then
183         echo "OK"
184 else
185         cat fwd.log
186         echo "Not OK"
187         exit 1
188 fi
189 locktest
190 rm outfile
191
192 echo "> cat logfiles"
193 cat fwd.log 
194 exit 0