tests.sh revision f97d56e757b9a293ffbaa915ca4d792ae84ba85a
# Copyright (C) 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
#
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id$
# test response policy zones (RPZ)
# responses for comparisons
NS3_STATS=47
USAGE="$0: [-x]"
while getopts "x" c; do
case $c in
x) set -x;;
esac
done
exit 1
fi
# really quit on control-C
trap 'exit 1' 1 2 15
TS='%H:%M:%S '
TS=
date "+I:${TS}$*"
fi
}
RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p 9953 -s"
digcmd_args="+noadd +time=1 +tries=1 -p 5300 $*"
digcmd_args="+noauth $digcmd_args"
#echo I:dig $digcmd_args 1>&2
}
# set DIGNM=file name for dig output
TEST_NUM=0
while test -f $DIGNM; do
done
}
ret=1
echo "$*"
}
# (re)load the reponse policy zones with the rules in the file $TEST_FILE
if ! $NSUPDATE -v $TEST_FILE; then
echo "I:failed to update policy zone with $TEST_FILE"
exit 1
fi
fi
}
# try to ensure that the server really has stopped
# and won't mess with ns$1/name.pid
sleep 1
echo "I:killing ns$1 server $PID"
kill -9 $PID
fi
fi
fi
done
fi
}
# $1=server and irrelevant args $2=error message
fi
eval CKALIVE_IP=\$ns$CKALIVE_NS
$RNDCCMD $CKALIVE_IP status >/dev/null 2>&1 && return 0
setret "$2"
# restart the server to avoid stalling waiting for it to stop
return 1
}
# check that statistics for $1 in $2 = $3
$2/named.stats`
fi
}
# $1=message $2=optional test file name
ret=0
TEST_FILE=$2
else
fi
TEST_NUM=0
}
# remove the previous set of test rules
fi
}
rm -f $*
fi
}
# $1=dig args $2=other dig output file
#ckalive "$1" "I:server crashed by 'dig $1'" || return 1
if $PERL $SYSTEMTESTTOP/digcomp.pl $DIGNM $2 >/dev/null; then
clean_result ${DIGNM}*
return 0
fi
return 1
}
# check only that the server does not crash
# $1=target domain $2=optional query type
ckalive "$*" "I:server crashed by 'dig $*'"
}
# check rewrite to NXDOMAIN
# $1=target domain $2=optional query type
digcmd $* \
-e 's/^[a-z].* IN RRSIG /;xxx &/' \
}
# check rewrite to NODATA
# $1=target domain $2=optional query type
digcmd $* \
}
# check rewrite to an address
# modify the output so that it is easily compared, but save the original line
# $1=IPv4 address $2=digcmd args $3=optional TTL
ADDR=$1
#ckalive "$2" "I:server crashed by 'dig $2'" || return 1
return 1
fi
return 1
fi
clean_result ${DIGNM}*
}
# check that a response is not rewritten
# $1=target domain $2=optional query type
}
# check against a 'here document'
}
# make prototype files to check against rewritten results
status=0
nochange . # 1 do not crash or rewrite root
# check that IP addresses for previous group were deleted from the radix tree
start_group "radix tree deletions"
# these tests assume "min-ns-dots 0"
NS3_STATS=`expr $NS3_STATS + 7`
else
echo "I:NSDNAME not checked; named configured with --disable-rpz-nsdname"
fi
# these tests assume "min-ns-dots 0"
NS3_STATS=`expr $NS3_STATS + 4`
else
echo "I:NSIP not checked; named configured with --disable-rpz-nsip"
fi
# policies in ./test5 overridden by response-policy{} in ns3/named.conf
# and in ns5/named.conf
# check that miscellaneous bugs are still absent
start_group "crashes"
nocrash www.redirect -t$Q
nocrash www.credirect -t$Q
done
# This is not a bug, because any data leaked by writing 24.4.3.2.10.rpz-ip
# (or whatever) is available by publishing "foo A 10.2.3.4" and then
# resolving foo.
# nxdomain 32.3.2.1.127.rpz-ip
# superficial test for major performance bugs
if test -n "$QPERF"; then
date "+I:${TS}checking performance $1"
# Dry run to prime everything
comment "before dry run $1"
comment "before real test $1"
comment "after test $1"
if test "$X" != "$3"; then
fi
}
}
# get qps with rpz
# turn off rpz and measure qps again
MIN_PERCENT=30
setret "I:$RPZ qps with rpz or $PERCENT% is below $MIN_PERCENT% of $NORPZ qps"
fi
fi
else
echo "I:performance not checked; queryperf not available"
fi
# restart the main test RPZ server to see if that creates a core file
if test -z "$HAVE_CORE"; then
restart 3
fi
if test -n "$EMSGS"; then
fi
echo "I:exit status: $status"
exit $status