Commit 8c619219 authored by Pekka Pessi's avatar Pekka Pessi

Cleand up run_test_sresolv script.

darcs-hash:20060410232923-88462-6c2a06c2790327b0f3d9eabbf37efefb7e5f4bcd.gz
parent 865ddb12
......@@ -30,22 +30,19 @@
# Author(s): Pekka Pessi <Pekka.Pessi@nokia.com>.
#
#set -x
s=${0%/*}
test x$s = x$0 && s=`pwd`
PATH=/usr/sbin:/usr/local/sbin:/sbin:$PATH
export PATH
port=$((($$ % $((65536 - 1024))) + 1024))
# Test for support for IPv6 on Linux. This probably fails on everything else.
ipv6='sysctl net.ipv6.conf.default.mtu >& /dev/null'
# Bind not working with IPv6 on RHEL 4:
# client.c:1325: unexpected error: failed to get request's destination: failure
ipv6=false
#ipv6=false
port=`expr $$ % \( 65536 - 1024 \) + 1024`
# Try to find a free port
if netstat --ip >/dev/null 2>&1 ; then
......@@ -58,12 +55,20 @@ if netstat --ip >/dev/null 2>&1 ; then
done
fi
# No named, no fun
type -p named >/dev/null || exit 77
if eval $ipv6 &&
ns=$(ip addr ls | awk '
/^[0-9]:/ { up = ($3 ~ /UP/) && ($3 !~ /LOOPBACK/); }
up && $1 ~ /inet6/ { sub(/\/.*$/, "", $2); print $2; exit 0; }')
if eval $ipv6
then
# Figure out nice IPv6 address for us
ns=$(ip addr ls | awk '
/^[0-9]:/ { up = ($3 ~ /UP/) && ($3 !~ /LOOPBACK/); }
/inet6 fe80::/ { next; } # no link-local
up && $1 ~ /inet6/ { sub(/\/.*$/, "", $2); print $2; exit 0; }')
# Nothing found, use localnode ::1
if test -z "$ns"; then ns=::1 ; fi
listen6="listen-on-v6 port $port { any; };"
else
ns="127.0.0.1"
......@@ -71,32 +76,45 @@ else
fi
#
# We set up a DNS server at $ns
# Set up configuration. First, nice tmpdir
#
t=${TMPDIR:-/tmp}/sofia-sip-sresolv-$USER-$$
cat > resolv.conf <<EOF
mkdir $t || exit 77
# Main resolv.conf (with primary nameserver not answering)
cat > $t/resolv.conf <<EOF
# Zeroconf subnet, reserved range - no-one should answer this
nameserver 169.254.0.2
nameserver fe80::2
#nameserver 169.254.0.2
#...but bind9 listens to it if using IPv6 ... and chokes on it.
# 00:10:c6:e3:da:7f belongs to a Nokia WLAN card tucked safely in my closet
nameserver fe80::10:c6ff:fee3:da7f
# This is bind we set up
nameserver $ns
domain example.com
# This is our addition
port $port
EOF
cat > error.conf <<EOF
# Resolv.conf with bad namserver addresses
cat > $t/error.conf <<EOF
nameserver 0.0.0.2
nameserver 1.1.1.1.1
search example.com
port $port
EOF
cat > named.conf.tmp <<EOF
cat > $t/named.conf <<EOF
options {
directory "$(cd $s; pwd)";
pid-file "`pwd`/named.pid";
pid-file "$t/named.pid";
notify no;
$listen6
$listen4
$listen6
};
zone "example.com" in {
......@@ -131,24 +149,17 @@ zone "0.0.0.c.2.1.0.3.0.0.2.1.e.f.f.3.ip6.arpa" in {
EOF
PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
#echo $port; sleep 200 & echo sleep pid is $! ; wait $!
type -p named >/dev/null || exit 77
#named -d5 -c named.conf.tmp || exit 77 &
named -f -d 999 -c named.conf.tmp &
named -f -d 999 -c $t/named.conf &
echo $0: started named pid $!
for i in 1 2 3 4 5; do
test -r named.pid && break
test -r $t/named.pid && break
sleep 1;
done
test -r named.pid || {
test -r $t/named.pid || {
echo $0: cannot start named >&2 ;
if fgrep -q -i -e SELINUX=enforcing /etc/selinux/config ; then
if fgrep -q -i -e SELINUX=enforcing /etc/selinux/config 2>&/dev/null ; then
echo $0: perhaps you have to disable SELinux protection for named
fi
exit 77
......@@ -156,12 +167,14 @@ test -r named.pid || {
function kill_named
{
kill `cat named.pid`
kill `cat $t/named.pid`
rm $t/named.conf $t/resolv.conf $t/error.conf $t/named.pid
rmdir $t
}
trap kill_named EXIT
# export SOFIA_DEBUG=9
$VALGRIND ./test_sresolv "$@" - resolv.conf error.conf timeout.conf || exit 1
$VALGRIND ./test_sresolv "$@" - $t/resolv.conf $t/error.conf || exit 1
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment