myRNDC="$RNDC -c ${THISDIR}/${CONFDIR}/rndc.conf"
myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -T clienttest -T nosyslog -d 99 -X named.lock -U 4"
+# Test given condition. If true, test again after a second. Used for testing
+# filesystem-dependent conditions in order to prevent false negatives caused by
+# directory contents not being synchronized immediately after rename() returns.
+test_with_retry() {
+ if test "$@"; then
+ sleep 1
+ if test "$@"; then
+ return 0
+ fi
+ fi
+ return 1
+}
+
waitforpidfile() {
for _w in 1 2 3 4 5 6 7 8 9 10
do
cd $CONFDIR
-n=`expr $n + 1`
-echo "I:testing log file validity (named -g + only plain files allowed) ($n)"
+echo "I:testing log file validity (named -g + only plain files allowed)"
+n=`expr $n + 1`
+echo "I: testing plain file (named -g) ($n)"
# First run with a known good config.
echo > $PLAINFILE
cp $PLAINCONF named.conf
grep "reloading configuration failed" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing plain file succeeded"
+ echo "I: testing plain file succeeded"
else
- echo "I: testing plain file failed (unexpected)"
+ echo "I: testing plain file failed (unexpected)"
echo "I:exit status: 1"
exit 1
fi
grep "checking logging configuration failed: invalid file" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing directory as file succeeded (UNEXPECTED)"
+ echo "I: testing directory as file succeeded (UNEXPECTED)"
echo "I:exit status: 1"
exit 1
else
- echo "I: testing directory as log file failed (expected)"
+ echo "I: testing directory as log file failed (expected)"
fi
else
- echo "I: skipping directory test (unable to create directory)"
+ echo "I: skipping directory test (unable to create directory)"
fi
# Now try pipe file, expect failure
grep "checking logging configuration failed: invalid file" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
+ echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
echo "I:exit status: 1"
exit 1
else
- echo "I: testing pipe file as log file failed (expected)"
+ echo "I: testing pipe file as log file failed (expected)"
fi
else
- echo "I: skipping pipe test (unable to create pipe)"
+ echo "I: skipping pipe test (unable to create pipe)"
fi
# Now try symlink file to plain file, expect success
grep "reloading configuration failed" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing symlink to plain file succeeded"
+ echo "I: testing symlink to plain file succeeded"
else
- echo "I: testing symlink to plain file failed (unexpected)"
+ echo "I: testing symlink to plain file failed (unexpected)"
echo "I:exit status: 1"
exit 1
fi
else
- echo "I: skipping symlink test (unable to create symlink)"
+ echo "I: skipping symlink test (unable to create symlink)"
fi
# Stop the server and run through a series of tests with various config
# files while controlling the stop/start of the server.
status=0
-n=`expr $n + 1`
-echo "I:testing log file validity (only plain files allowed) ($n)"
+echo "I:testing log file validity (only plain files allowed)"
+n=`expr $n + 1`
+echo "I: testing plain file (named -g) ($n)"
# First run with a known good config.
echo > $PLAINFILE
cp $PLAINCONF named.conf
grep "reloading configuration failed" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing plain file succeeded"
+ echo "I: testing plain file succeeded"
else
- echo "I: testing plain file failed (unexpected)"
+ echo "I: testing plain file failed (unexpected)"
echo "I:exit status: 1"
exit 1
fi
grep "configuring logging: invalid file" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing directory as file succeeded (UNEXPECTED)"
+ echo "I: testing directory as file succeeded (UNEXPECTED)"
echo "I:exit status: 1"
exit 1
else
- echo "I: testing directory as log file failed (expected)"
+ echo "I: testing directory as log file failed (expected)"
fi
else
- echo "I: skipping directory test (unable to create directory)"
+ echo "I: skipping directory test (unable to create directory)"
fi
# Now try pipe file, expect failure
grep "configuring logging: invalid file" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
+ echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
echo "I:exit status: 1"
exit 1
else
- echo "I: testing pipe file as log file failed (expected)"
+ echo "I: testing pipe file as log file failed (expected)"
fi
else
- echo "I: skipping pipe test (unable to create pipe)"
+ echo "I: skipping pipe test (unable to create pipe)"
fi
# Now try symlink file to plain file, expect success
grep "reloading configuration failed" named.run > /dev/null 2>&1
if [ $? -ne 0 ]
then
- echo "I: testing symlink to plain file succeeded"
+ echo "I: testing symlink to plain file succeeded"
else
- echo "I: testing symlink to plain file failed (unexpected)"
+ echo "I: testing symlink to plain file failed (unexpected)"
echo "I:exit status: 1"
exit 1
fi
else
- echo "I: skipping symlink test (unable to create symlink)"
+ echo "I: skipping symlink test (unable to create symlink)"
fi
status=0
cp $PLAINCONF named.conf
$myNAMED -L $DLFILE > /dev/null 2>&1
if [ $? -ne 0 ]; then
- echo "I:failed to start $myNAMED"
+ echo "I: failed to start $myNAMED"
echo "I:exit status: $status"
exit $status
fi
exit 1
fi
else
- echo "I:failed to cleanly stop $myNAMED"
+ echo "I: failed to cleanly stop $myNAMED"
echo "I:exit status: 1"
exit 1
fi
echo "I:testing logging functionality"
n=`expr $n + 1`
-echo "I: testing explict versions ($n)"
+echo "I: testing explicit versions ($n)"
cp $VERSCONF named.conf
# a seconds since epoch version number
touch $VERSFILE.1480039317
t=`expr ${t2:-0} - ${t1:-0}`
if test ${t:-1000} -gt 5
then
- echo "I: testing explict versions failed cleanup of old entries took too long ($t secs)"
+ echo "I: testing explicit versions failed: cleanup of old entries took too long ($t secs)"
status=`expr $status + 1`
fi
if ! grep "status: NOERROR" dig.out.test$n > /dev/null
then
- echo "I: testing explict versions failed DiG lookup failed"
+ echo "I: testing explicit versions failed: DiG lookup failed"
status=`expr $status + 1`
fi
-if test -f $VERSFILE.1480039317
+if test_with_retry -f $VERSFILE.1480039317
then
- echo "I: testing explict versions failed $VERSFILE.1480039317 not removed"
+ echo "I: testing explicit versions failed: $VERSFILE.1480039317 not removed"
status=`expr $status + 1`
fi
-if test -f $VERSFILE.5
+if test_with_retry -f $VERSFILE.5
then
- echo "I: testing explict versions failed $VERSFILE.5 exists"
+ echo "I: testing explicit versions failed: $VERSFILE.5 exists"
status=`expr $status + 1`
fi
-if test ! -f $VERSFILE.4
+if test_with_retry ! -f $VERSFILE.4
then
- echo "I: testing explict versions failed $VERSFILE.4 does not exist"
+ echo "I: testing explicit versions failed: $VERSFILE.4 does not exist"
status=`expr $status + 1`
fi
t=`expr ${t2:-0} - ${t1:-0}`
if test ${t:-1000} -gt 5
then
- echo "I: testing unlimited versions failed took too long ($t secs)"
+ echo "I: testing unlimited versions failed: took too long ($t secs)"
status=`expr $status + 1`
fi
if ! grep "status: NOERROR" dig.out.test$n > /dev/null
then
- echo "I: testing unlimited versions failed DiG lookup failed"
+ echo "I: testing unlimited versions failed: DiG lookup failed"
status=`expr $status + 1`
fi
-if test ! -f $UNLIMITEDFILE.1480039317
+if test_with_retry ! -f $UNLIMITEDFILE.1480039317
then
- echo "I: testing unlimited versions failed $UNLIMITEDFILE.1480039317 removed"
+ echo "I: testing unlimited versions failed: $UNLIMITEDFILE.1480039317 removed"
status=`expr $status + 1`
fi
-if test ! -f $UNLIMITEDFILE.4
+if test_with_retry ! -f $UNLIMITEDFILE.4
then
- echo "I: testing unlimited versions failed $UNLIMITEDFILE.4 does not"
+ echo "I: testing unlimited versions failed: $UNLIMITEDFILE.4 does not exist"
status=`expr $status + 1`
fi