etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / bin / tests / system / logfileconfig / tests.sh
blob073997bd45ad2f92c5e5022628cba297abc168bb
1 #!/bin/sh
3 # Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 # Id: tests.sh,v 1.4 2011/03/22 16:51:50 smann Exp
19 SYSTEMTESTTOP=..
20 . $SYSTEMTESTTOP/conf.sh
21 THISDIR=`pwd`
22 CONFDIR="ns1"
23 PLAINCONF="${THISDIR}/${CONFDIR}/named.plain"
24 DIRCONF="${THISDIR}/${CONFDIR}/named.dirconf"
25 PIPECONF="${THISDIR}/${CONFDIR}/named.pipeconf"
26 SYMCONF="${THISDIR}/${CONFDIR}/named.symconf"
27 PLAINFILE="named_log"
28 DIRFILE="named_dir"
29 PIPEFILE="named_pipe"
30 SYMFILE="named_sym"
31 PIDFILE="${THISDIR}/${CONFDIR}/named.pid"
32 myRNDC="$RNDC -c ${THISDIR}/${CONFDIR}/rndc.conf"
33 myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -T clienttest -T nosyslog -d 99 -U 4"
35 status=0
37 cd $CONFDIR
39 echo "I:testing log file validity (named -g + only plain files allowed)"
41 # First run with a known good config.
42 echo > $PLAINFILE
43 cp $PLAINCONF named.conf
44 $myRNDC reconfig
45 grep "reloading configuration failed" named.run > /dev/null 2>&1
46 if [ $? -ne 0 ]
47 then
48 echo "I: testing plain file succeeded"
49 else
50 echo "I: testing plain file failed (unexpected)"
51 echo "I:exit status: 1"
52 exit 1
55 # Now try directory, expect failure
56 echo "I: testing directory as log file (named -g)"
57 echo > named.run
58 rm -rf $DIRFILE
59 mkdir -p $DIRFILE >/dev/null 2>&1
60 if [ $? -eq 0 ]
61 then
62 cp $DIRCONF named.conf
63 echo > named.run
64 $myRNDC reconfig
65 grep "checking logging configuration failed: invalid file" named.run > /dev/null 2>&1
66 if [ $? -ne 0 ]
67 then
68 echo "I: testing directory as file succeeded (UNEXPECTED)"
69 echo "I:exit status: 1"
70 exit 1
71 else
72 echo "I: testing directory as log file failed (expected)"
74 else
75 echo "I: skipping directory test (unable to create directory)"
78 # Now try pipe file, expect failure
79 echo "I: testing pipe file as log file (named -g)"
80 echo > named.run
81 rm -f $PIPEFILE
82 mkfifo $PIPEFILE >/dev/null 2>&1
83 if [ $? -eq 0 ]
84 then
85 cp $PIPECONF named.conf
86 echo > named.run
87 $myRNDC reconfig
88 grep "checking logging configuration failed: invalid file" named.run > /dev/null 2>&1
89 if [ $? -ne 0 ]
90 then
91 echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
92 echo "I:exit status: 1"
93 exit 1
94 else
95 echo "I: testing pipe file as log file failed (expected)"
97 else
98 echo "I: skipping pipe test (unable to create pipe)"
101 # Now try symlink file to plain file, expect success
102 echo "I: testing symlink to plain file as log file (named -g)"
103 # Assume success
104 echo > named.run
105 echo > $PLAINFILE
106 rm -f $SYMFILE $SYMFILE
107 ln -s $PLAINFILE $SYMFILE >/dev/null 2>&1
108 if [ $? -eq 0 ]
109 then
110 cp $SYMCONF named.conf
111 $myRNDC reconfig
112 echo > named.run
113 grep "reloading configuration failed" named.run > /dev/null 2>&1
114 if [ $? -ne 0 ]
115 then
116 echo "I: testing symlink to plain file succeeded"
117 else
118 echo "I: testing symlink to plain file failed (unexpected)"
119 echo "I:exit status: 1"
120 exit 1
122 else
123 echo "I: skipping symlink test (unable to create symlink)"
125 # Stop the server and run through a series of tests with various config
126 # files while controlling the stop/start of the server.
127 # Have to stop the stock server because it uses "-g"
129 $PERL ../../stop.pl .. ns1
131 $myNAMED > /dev/null 2>&1
133 if [ $? -ne 0 ]
134 then
135 echo "I:failed to start $myNAMED"
136 echo "I:exit status: $status"
137 exit $status
140 status=0
142 echo "I:testing log file validity (only plain files allowed)"
144 # First run with a known good config.
145 echo > $PLAINFILE
146 cp $PLAINCONF named.conf
147 $myRNDC reconfig
148 grep "reloading configuration failed" named.run > /dev/null 2>&1
149 if [ $? -ne 0 ]
150 then
151 echo "I: testing plain file succeeded"
152 else
153 echo "I: testing plain file failed (unexpected)"
154 echo "I:exit status: 1"
155 exit 1
158 # Now try directory, expect failure
159 echo "I: testing directory as log file"
160 echo > named.run
161 rm -rf $DIRFILE
162 mkdir -p $DIRFILE >/dev/null 2>&1
163 if [ $? -eq 0 ]
164 then
165 cp $DIRCONF named.conf
166 echo > named.run
167 $myRNDC reconfig
168 grep "configuring logging: invalid file" named.run > /dev/null 2>&1
169 if [ $? -ne 0 ]
170 then
171 echo "I: testing directory as file succeeded (UNEXPECTED)"
172 echo "I:exit status: 1"
173 exit 1
174 else
175 echo "I: testing directory as log file failed (expected)"
177 else
178 echo "I: skipping directory test (unable to create directory)"
181 # Now try pipe file, expect failure
182 echo "I: testing pipe file as log file"
183 echo > named.run
184 rm -f $PIPEFILE
185 mkfifo $PIPEFILE >/dev/null 2>&1
186 if [ $? -eq 0 ]
187 then
188 cp $PIPECONF named.conf
189 echo > named.run
190 $myRNDC reconfig
191 grep "configuring logging: invalid file" named.run > /dev/null 2>&1
192 if [ $? -ne 0 ]
193 then
194 echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
195 echo "I:exit status: 1"
196 exit 1
197 else
198 echo "I: testing pipe file as log file failed (expected)"
200 else
201 echo "I: skipping pipe test (unable to create pipe)"
204 # Now try symlink file to plain file, expect success
205 echo "I: testing symlink to plain file as log file"
206 # Assume success
207 status=0
208 echo > named.run
209 echo > $PLAINFILE
210 rm -f $SYMFILE
211 ln -s $PLAINFILE $SYMFILE >/dev/null 2>&1
212 if [ $? -eq 0 ]
213 then
214 cp $SYMCONF named.conf
215 $myRNDC reconfig
216 echo > named.run
217 grep "reloading configuration failed" named.run > /dev/null 2>&1
218 if [ $? -ne 0 ]
219 then
220 echo "I: testing symlink to plain file succeeded"
221 else
222 echo "I: testing symlink to plain file failed (unexpected)"
223 echo "I:exit status: 1"
224 exit 1
226 else
227 echo "I: skipping symlink test (unable to create symlink)"
230 echo "I:exit status: $status"
231 exit $status