diff --git a/CHANGES b/CHANGES index 10970f4b77..be0642c29c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +2917. [func] Virtual time test framework. [RT #20801] + 2916. [func] Add framework to use IPv6 in tests. fd92:7065:b8e:ffff::1 ... fd92:7065:b8e:ffff::7 diff --git a/bin/tests/virtual-time/.cvsignore b/bin/tests/virtual-time/.cvsignore new file mode 100644 index 0000000000..c280f7a2be --- /dev/null +++ b/bin/tests/virtual-time/.cvsignore @@ -0,0 +1,4 @@ +conf.sh +vtwrapper.bin +libvtwrapper.so +setepoch diff --git a/bin/tests/virtual-time/Makefile.in b/bin/tests/virtual-time/Makefile.in new file mode 100644 index 0000000000..5fe6c2e214 --- /dev/null +++ b/bin/tests/virtual-time/Makefile.in @@ -0,0 +1,45 @@ +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: Makefile.in,v 1.2 2010/06/17 05:38:04 marka Exp $ + +TARGETS = libvtwrapper.so +SRCS = vtwrapper.c +CFLAGS += -fPIC +LDFLAGS = +LIBS = + +all: libvtwrapper.so + +.SUFFIXES: .c .o + +.c.o: + ${CC} ${CFLAGS} -c $< + +libvtwrapper.so: vtwrapper.o + ${CC} ${CFLAGS} ${LDFLAGS} -nostdlib -export-dynamic -shared -o $@ vtwrapper.o ${LIBS} + +clean distclean:: + rm -f ${TARGETS} *.o + +SUBDIRS = + +test: + if test -f ./runall.sh; then sh ./runall.sh; fi + +testclean clean distclean:: + if test -f ./cleanall.sh; then sh ./cleanall.sh; fi + +distclean:: + rm -f conf.sh diff --git a/bin/tests/virtual-time/README b/bin/tests/virtual-time/README new file mode 100644 index 0000000000..4aab9513ea --- /dev/null +++ b/bin/tests/virtual-time/README @@ -0,0 +1,19 @@ +Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +See COPYRIGHT in the source root or http://isc.org/copyright.html for terms. + +This is copied from ../system. + +This test suite uses a virtual time, gettimeofday(), select(), +poll(), kevent() and epoll_wait() Unix system calls are redirected: +gettimeofday() returns a date in virtual/exponentially inflated +delay from an epoch, select(), poll(), kevent() and epoll_wait() +timeouts are deflated down to at least 10ms. + +These tests depends on LD_PRELOAD being supported by the runtime +loader. + +Beware BIND clock uses unsigned integer, in 22 seconds isc_time_now() +overflows and breaks assertions. Note 22 real seconds is 136 virtual +years... + +$Id: README,v 1.2 2010/06/17 05:38:04 marka Exp $ diff --git a/bin/tests/virtual-time/autosign/prereq.sh b/bin/tests/virtual-time/autosign/prereq.sh new file mode 100644 index 0000000000..b955b6abd3 --- /dev/null +++ b/bin/tests/virtual-time/autosign/prereq.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: prereq.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +echo "I:This test is not yet written." >&2 +exit 1 diff --git a/bin/tests/virtual-time/cleanall.sh b/bin/tests/virtual-time/cleanall.sh new file mode 100644 index 0000000000..4a3f463ffa --- /dev/null +++ b/bin/tests/virtual-time/cleanall.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: cleanall.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# +# Clean up after system tests. +# + +SYSTEMTESTTOP=. +. $SYSTEMTESTTOP/conf.sh + + +find . -type f \( \ + -name 'K*' -o -name '*~' -o -name '*.core' -o -name '*.log' \ + -o -name '*.pid' -o -name '*.keyset' -o -name named.run \ + -o -name lwresd.run -o -name ans.run \) -print | xargs rm -f + +status=0 + +for d in $SUBDIRS +do + test ! -f $d/clean.sh || ( cd $d && sh clean.sh ) +done diff --git a/bin/tests/virtual-time/common/controls.conf b/bin/tests/virtual-time/common/controls.conf new file mode 100644 index 0000000000..41d638d44d --- /dev/null +++ b/bin/tests/virtual-time/common/controls.conf @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * 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: controls.conf,v 1.2 2010/06/17 05:38:05 marka Exp $ */ + +key rndc_key { + secret "1234abcd8765"; + algorithm hmac-md5; +}; + +controls { + inet 10.53.0.2 port 9953 allow { any; } keys { rndc_key; }; +}; + diff --git a/bin/tests/virtual-time/common/rndc.conf b/bin/tests/virtual-time/common/rndc.conf new file mode 100644 index 0000000000..f25af9727f --- /dev/null +++ b/bin/tests/virtual-time/common/rndc.conf @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * 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: rndc.conf,v 1.2 2010/06/17 05:38:05 marka Exp $ */ + +options { + default-key "rndc_key"; +}; + +key rndc_key { + algorithm hmac-md5; + secret "1234abcd8765"; +}; diff --git a/bin/tests/virtual-time/common/root.hint b/bin/tests/virtual-time/common/root.hint new file mode 100644 index 0000000000..5c092fb19b --- /dev/null +++ b/bin/tests/virtual-time/common/root.hint @@ -0,0 +1,19 @@ +; Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +; +; Permission to use, copy, modify, and/or distribute this software for any +; 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: root.hint,v 1.2 2010/06/17 05:38:05 marka Exp $ + +$TTL 999999 +. IN NS a.root-servers.nil. +a.root-servers.nil. IN A 10.53.0.1 diff --git a/bin/tests/virtual-time/conf.sh.in b/bin/tests/virtual-time/conf.sh.in new file mode 100644 index 0000000000..a6f23b2065 --- /dev/null +++ b/bin/tests/virtual-time/conf.sh.in @@ -0,0 +1,52 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: conf.sh.in,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# +# Common configuration data for system tests, to be sourced into +# other shell scripts. +# + +# Find the top of the BIND9 tree. +TOP=${SYSTEMTESTTOP:=.}/../../.. + +# Make it absolute so that it continues to work after we cd. +TOP=`cd $TOP && pwd` + +NAMED=$TOP/bin/named/named +# We must use "named -l" instead of "lwresd" because argv[0] is lost +# if the program is libtoolized. +LWRESD="$TOP/bin/named/named -l" +DIG=$TOP/bin/dig/dig +RNDC=$TOP/bin/rndc/rndc +NSUPDATE=$TOP/bin/nsupdate/nsupdate +DDNSCONFGEN=$TOP/bin/confgen/ddns-confgen +KEYGEN=$TOP/bin/dnssec/dnssec-keygen +SIGNER=$TOP/bin/dnssec/dnssec-signzone +REVOKE=$TOP/bin/dnssec/dnssec-revoke +SETTIME=$TOP/bin/dnssec/dnssec-settime +DSFROMKEY=$TOP/bin/dnssec/dnssec-dsfromkey +CHECKZONE=$TOP/bin/check/named-checkzone +CHECKCONF=$TOP/bin/check/named-checkconf + +SUBDIRS="autosign slave" + +# PERL will be an empty string if no perl interpreter was found. +PERL=@PERL@ + +export NAMED LWRESD DIG NSUPDATE KEYGEN SIGNER KEYSIGNER KEYSETTOOL PERL \ + SUBDIRS RNDC CHECKZONE diff --git a/bin/tests/virtual-time/run.sh b/bin/tests/virtual-time/run.sh new file mode 100644 index 0000000000..5581e3133c --- /dev/null +++ b/bin/tests/virtual-time/run.sh @@ -0,0 +1,109 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: run.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +SYSTEMTESTTOP=. +. $SYSTEMTESTTOP/conf.sh + +stopservers=true + +case $1 in + --keep) stopservers=false; shift ;; +esac + +test $# -gt 0 || { echo "usage: $0 [--keep] test-directory" >&2; exit 1; } + +test=$1 +shift + +test -d $test || { echo "$0: $test: no such test" >&2; exit 1; } + +echo "S:$test:`date`" >&2 +echo "T:$test:1:A" >&2 +echo "A:Virtual time test $test" >&2 + +if [ x$PERL = x ] +then + echo "I:Perl not available. Skipping test." >&2 + echo "R:UNTESTED" >&2 + echo "E:$test:`date`" >&2 + exit 0; +fi + +$PERL testsock.pl || { + echo "I:Network interface aliases not set up. Skipping test." >&2 + echo "R:UNTESTED" >&2 + echo "E:$test:`date`" >&2 + exit 0; +} + +# Check for test-specific prerequisites. +if + test ! -f $test/prereq.sh || + ( cd $test && sh prereq.sh "$@" ) +then + : prereqs ok +else + echo "I:Prerequisites for $test missing, skipping test." >&2 + echo "R:UNTESTED" >&2 + echo "E:$test:`date`" >&2 + exit 0; +fi + +# Set up any dynamically generated test data +if test -f $test/setup.sh +then + ( cd $test && sh setup.sh "$@" ) +fi + +# Start name servers running +$PERL start.pl $test || exit 1 + +# Run the tests +( cd $test ; sh tests.sh ) + +status=$? + +if $stopservers +then + : +else + exit $status +fi + +# Shutdown +$PERL stop.pl $test + +status=`expr $status + $?` + +if [ $status != 0 ]; then + echo "R:FAIL" + # Don't clean up - we need the evidence. + find . -name core -exec chmod 0644 '{}' \; +else + echo "R:PASS" + + # Clean up. + if test -f $test/clean.sh + then + ( cd $test && sh clean.sh "$@" ) + fi +fi + +echo "E:$test:`date`" + +exit $status diff --git a/bin/tests/virtual-time/runall.sh b/bin/tests/virtual-time/runall.sh new file mode 100644 index 0000000000..6e476f5d79 --- /dev/null +++ b/bin/tests/virtual-time/runall.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: runall.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# +# Run all the virtual time tests. +# + +SYSTEMTESTTOP=. +. $SYSTEMTESTTOP/conf.sh + +$PERL testsock.pl || { + echo "I:Network interface aliases not set up. Skipping tests." >&2; + echo "R:UNTESTED" >&2; + echo "E:virtual-time:`date`" >&2; + exit 0; +} + +status=0 + +for d in $SUBDIRS +do + sh run.sh $d || status=1 +done + +exit $status diff --git a/bin/tests/virtual-time/setup.sh b/bin/tests/virtual-time/setup.sh new file mode 100644 index 0000000000..ab29381cf2 --- /dev/null +++ b/bin/tests/virtual-time/setup.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: setup.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# +# Run a system test. +# + +SYSTEMTESTTOP=. +. $SYSTEMTESTTOP/conf.sh + +test $# -gt 0 || { echo "usage: $0 test-directory" >&2; exit 1; } + +test=$1 +shift + +test -d $test || { echo "$0: $test: no such test" >&2; exit 1; } + +# Set up any dynamically generated test data +if test -f $test/setup.sh +then + ( cd $test && sh setup.sh "$@" ) +fi diff --git a/bin/tests/virtual-time/slave/clean.sh b/bin/tests/virtual-time/slave/clean.sh new file mode 100644 index 0000000000..b2e663c103 --- /dev/null +++ b/bin/tests/virtual-time/slave/clean.sh @@ -0,0 +1,23 @@ +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: clean.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# +# Clean up after virtual time tests. +# +rm -f dig.out.* +rm -f ns1/named.memstats +rm -f ns1/vtwrapper.* +rm -f ns1/example.db diff --git a/bin/tests/virtual-time/slave/ns1/.cvsignore b/bin/tests/virtual-time/slave/ns1/.cvsignore new file mode 100644 index 0000000000..6af68aad15 --- /dev/null +++ b/bin/tests/virtual-time/slave/ns1/.cvsignore @@ -0,0 +1 @@ +named.run diff --git a/bin/tests/virtual-time/slave/ns1/example.db.in b/bin/tests/virtual-time/slave/ns1/example.db.in new file mode 100644 index 0000000000..961f819f61 --- /dev/null +++ b/bin/tests/virtual-time/slave/ns1/example.db.in @@ -0,0 +1,12 @@ +$TTL 300 ; 5 minutes +@ IN SOA ns root ( + 2000042100 ; serial + 600 ; refresh + 600 ; retry + 12000 ; expire + 600 ; minimum + ) + NS ns +ns A 10.53.0.1 + +txt TXT "recursed" diff --git a/bin/tests/virtual-time/slave/ns1/named.conf b/bin/tests/virtual-time/slave/ns1/named.conf new file mode 100644 index 0000000000..1c83de9e27 --- /dev/null +++ b/bin/tests/virtual-time/slave/ns1/named.conf @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * 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: named.conf,v 1.2 2010/06/17 05:38:06 marka Exp $ */ + +controls { /* empty */ }; + +options { + query-source address 10.53.0.1; + notify-source 10.53.0.1; + transfer-source 10.53.0.1; + port 5300; + pid-file "named.pid"; + listen-on { 10.53.0.1; }; + listen-on-v6 { none; }; + recursion no; + notify no; +}; + +key rndc_key { + secret "1234abcd8765"; + algorithm hmac-md5; +}; + +controls { + inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; }; +}; + +zone "." { + type master; + file "root.db"; +}; + +zone "example." { + type slave; + masters { 10.53.0.111; }; + file "example.db"; +}; + diff --git a/bin/tests/virtual-time/slave/ns1/root.db b/bin/tests/virtual-time/slave/ns1/root.db new file mode 100644 index 0000000000..5e02ab704f --- /dev/null +++ b/bin/tests/virtual-time/slave/ns1/root.db @@ -0,0 +1,30 @@ +; Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") +; +; Permission to use, copy, modify, and/or distribute this software for any +; 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: root.db,v 1.2 2010/06/17 05:38:06 marka Exp $ + +$TTL 300 +. IN SOA gson.nominum.com. a.root.servers.nil. ( + 2000082401 ; serial + 1800 ; refresh (30 minutes) + 1800 ; retry (30 minutes) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) +. NS a.root-servers.nil. +a.root-servers.nil. A 10.53.0.1 + +example NS ns.example +ns.example A 10.53.0.1 + diff --git a/bin/tests/virtual-time/slave/ns1/wrap.sh b/bin/tests/virtual-time/slave/ns1/wrap.sh new file mode 100644 index 0000000000..e91d048620 --- /dev/null +++ b/bin/tests/virtual-time/slave/ns1/wrap.sh @@ -0,0 +1,24 @@ +# Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: wrap.sh,v 1.2 2010/06/17 05:38:06 marka Exp $ + +# +# Wrapper for named +# + +LD_PRELOAD=../../libvtwrapper.so +export LD_PRELOAD + +exec $* diff --git a/bin/tests/virtual-time/slave/setup.sh b/bin/tests/virtual-time/slave/setup.sh new file mode 100644 index 0000000000..1f8d47a9c2 --- /dev/null +++ b/bin/tests/virtual-time/slave/setup.sh @@ -0,0 +1,18 @@ +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: setup.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +rm -f ns1/example.db +cp ns1/example.db.in ns1/example.db diff --git a/bin/tests/virtual-time/slave/tests.sh b/bin/tests/virtual-time/slave/tests.sh new file mode 100644 index 0000000000..768c54fab5 --- /dev/null +++ b/bin/tests/virtual-time/slave/tests.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: tests.sh,v 1.2 2010/06/17 05:38:06 marka Exp $ + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +status=0 + +rm -f dig.out.* + +DIGOPTS="+tcp +noadd +nosea +nostat +nocmd -p 5300" + +echo "I:checking slave expiry" +ret=0 +$DIG $DIGOPTS txt.example. txt @10.53.0.1 > dig.out.before || ret=1 +echo "I:waiting for expiry (10s real, 6h virtual)" +sleep 10 +$DIG $DIGOPTS txt.example. txt @10.53.0.1 > dig.out.after || ret=1 +if [ $ret != 0 ]; then echo "I:failed"; fi +status=`expr $status + $ret` + +ret=0 +grep "status: NOERROR" dig.out.before > /dev/null || ret=1 +if [ $ret -eq 1 ] ; then + echo "I:failed (before)"; status=1 +fi +ret=0 +grep "status: SERVFAIL" dig.out.after > /dev/null || ret=1 +if [ $ret -eq 1 ] ; then + echo "I:failed (after)"; status=1 +fi + +echo "I:exit status: $status" +exit $status diff --git a/bin/tests/virtual-time/start.pl b/bin/tests/virtual-time/start.pl new file mode 100644 index 0000000000..ea8e6fdb87 --- /dev/null +++ b/bin/tests/virtual-time/start.pl @@ -0,0 +1,183 @@ +#!/usr/bin/perl -w +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: start.pl,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# Framework for starting test servers. +# Based on the type of server specified, check for port availability, remove +# temporary files, start the server, and verify that the server is running. +# If a server is specified, start it. Otherwise, start all servers for test. + +use strict; +use Cwd 'abs_path'; +use Getopt::Long; + +# Option handling +# --noclean test [server [options]] +# +# --noclean - Do not cleanup files in server directory +# test - name of the test directory +# server - name of the server directory +# options - alternate options for the server + +my $usage = "usage: $0 [--noclean] test-directory [server-directory [server-options]]"; +my $noclean; +GetOptions('noclean' => \$noclean); +my $test = $ARGV[0]; +my $server = $ARGV[1]; +my $options = $ARGV[2]; + +if (!$test) { + print "$usage\n"; +} +if (!-d $test) { + print "No test directory: \"$test\"\n"; +} +if ($server && !-d "$test/$server") { + print "No server directory: \"$test/$server\"\n"; +} + +# Global variables +my $topdir = abs_path("$test/.."); +my $testdir = abs_path("$test"); +my $NAMED = $ENV{'NAMED'}; +my $DIG = $ENV{'DIG'}; +my $PERL = $ENV{'PERL'}; + +# Start the server(s) + +if ($server) { + if ($server =~ /^ns/) { + &check_ports($server); + } + &start_server($server, $options); + if ($server =~ /^ns/) { + &verify_server($server); + } +} else { + # Determine which servers need to be started for this test. + opendir DIR, $testdir; + my @files = sort readdir DIR; + closedir DIR; + + my @ns = grep /^ns[0-9]*$/, @files; + + # Start the servers we found. + &check_ports(); + foreach (@ns) { + &start_server($_); + } + foreach (@ns) { + &verify_server($_); + } +} + +# Subroutines + +sub check_ports { + my $server = shift; + my $options = ""; + + if ($server && $server =~ /(\d+)$/) { + $options = "-i $1"; + } + + my $tries = 0; + while (1) { + my $return = system("$PERL $topdir/testsock.pl -p 5300 $options"); + last if ($return == 0); + if (++$tries > 4) { + print "$0: could not bind to server addresses, still running?\n"; + print "I:server sockets not available\n"; + print "R:FAIL\n"; + system("$PERL $topdir/stop.pl $testdir"); # Is this the correct behavior? + exit 1; + } + print "I:Couldn't bind to socket (yet)\n"; + sleep 2; + } +} + +sub start_server { + my $server = shift; + my $options = shift; + + my $cleanup_files; + my $command; + my $pid_file; + + if ($server =~ /^ns/) { + $cleanup_files = "{*.jnl,*.bk,*.st,named.run}"; + $command = "sh wrap.sh "; + $command .= "$NAMED "; + if ($options) { + $command .= "$options"; + } else { + $command .= "-m record,size,mctx "; + $command .= "-T clienttest "; + $command .= "-c named.conf -d 99 -g"; + } + $command .= " >named.run 2>&1 &"; + $pid_file = "named.pid"; + } else { + print "I:Unknown server type $server\n"; + print "R:FAIL\n"; + system "$PERL $topdir/stop.pl $testdir"; + exit 1; + } + +# print "I:starting server $server\n"; + + chdir "$testdir/$server"; + + unless ($noclean) { + unlink glob $cleanup_files; + } + + system "$command"; + + my $tries = 0; + while (!-f $pid_file) { + if (++$tries > 14) { + print "I:Couldn't start server $server\n"; + print "R:FAIL\n"; + system "$PERL $topdir/stop.pl $testdir"; + exit 1; + } + sleep 1; + } +} + +sub verify_server { + my $server = shift; + my $n = $server; + $n =~ s/^ns//; + + my $tries = 0; + while (1) { + my $return = system("$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd -p 5300 version.bind. chaos txt \@10.53.0.$n > dig.out"); + last if ($return == 0); + print `grep ";" dig.out`; + if (++$tries >= 30) { + print "I:no response from $server\n"; + print "R:FAIL\n"; + system("$PERL $topdir/stop.pl $testdir"); + exit 1; + } + sleep 2; + } + unlink "dig.out"; +} diff --git a/bin/tests/virtual-time/start.sh b/bin/tests/virtual-time/start.sh new file mode 100644 index 0000000000..fe702c7bb0 --- /dev/null +++ b/bin/tests/virtual-time/start.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: start.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +. ./conf.sh +$PERL start.pl "$@" diff --git a/bin/tests/virtual-time/stop.pl b/bin/tests/virtual-time/stop.pl new file mode 100644 index 0000000000..b65c7d394e --- /dev/null +++ b/bin/tests/virtual-time/stop.pl @@ -0,0 +1,181 @@ +#!/usr/bin/perl -w +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: stop.pl,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# Framework for stopping test servers +# Based on the type of server specified, signal the server to stop, wait +# briefly for it to die, and then kill it if it is still alive. +# If a server is specified, stop it. Otherwise, stop all servers for test. + +use strict; +use Cwd 'abs_path'; + +# Option handling +# [--use-rndc] test [server] +# +# test - name of the test directory +# server - name of the server directory + +my $usage = "usage: $0 [--use-rndc] test-directory [server-directory]"; +my $use_rndc; + +while (@ARGV && $ARGV[0] =~ /^-/) { + my $opt = shift @ARGV; + if ($opt eq '--use-rndc') { + $use_rndc = 1; + } else { + die "$usage\n"; + } +} + +my $test = $ARGV[0]; +my $server = $ARGV[1]; + +my $errors = 0; + +die "$usage\n" unless defined($test); +die "No test directory: \"$test\"\n" unless (-d $test); +die "No server directory: \"$server\"\n" if (defined($server) && !-d "$test/$server"); + +# Global variables +my $testdir = abs_path($test); +my @servers; + + +# Determine which servers need to be stopped. +if (defined $server) { + @servers = ($server); +} else { + local *DIR; + opendir DIR, $testdir or die "$testdir: $!\n"; + my @files = sort readdir DIR; + closedir DIR; + + my @ns = grep /^ns[0-9]*$/, @files; + + push @servers, @ns; +} + + +# Stop the server(s), pass 1: rndc. +if ($use_rndc) { + foreach my $server (grep /^ns/, @servers) { + stop_rndc($server); + } + + wait_for_servers(30, grep /^ns/, @servers); +} + + +# Pass 2: SIGTERM +foreach my $server (@servers) { + stop_signal($server, "TERM"); +} + +wait_for_servers(60, @servers); + +# Pass 3: SIGABRT +foreach my $server (@servers) { + stop_signal($server, "ABRT"); +} + +exit($errors ? 1 : 0); + +# Subroutines + +# Return the full path to a given server's PID file. +sub server_pid_file { + my($server) = @_; + + my $pid_file; + if ($server =~ /^ns/) { + $pid_file = "named.pid"; + } else { + print "I:Unknown server type $server\n"; + exit 1; + } + $pid_file = "$testdir/$server/$pid_file"; +} + +# Read a PID. +sub read_pid { + my($pid_file) = @_; + + local *FH; + my $result = open FH, "< $pid_file"; + if (!$result) { + print "I:$pid_file: $!\n"; + unlink $pid_file; + return; + } + + my $pid = ; + chomp($pid); + return $pid; +} + +# Stop a named process with rndc. +sub stop_rndc { + my($server) = @_; + + return unless ($server =~ /^ns(\d+)$/); + my $ip = "10.53.0.$1"; + + # Ugly, but should work. + system("$ENV{RNDC} -c $testdir/../common/rndc.conf -s $ip -p 9953 stop | sed 's/^/I:$server /'"); + return; +} + +# Stop a server by sending a signal to it. +sub stop_signal { + my($server, $sig) = @_; + + my $pid_file = server_pid_file($server); + return unless -f $pid_file; + + my $pid = read_pid($pid_file); + return unless defined($pid); + + if ($sig eq 'ABRT') { + print "I:$server didn't die when sent a SIGTERM\n"; + $errors++; + } + + my $result = kill $sig, $pid; + if (!$result) { + print "I:$server died before a SIG$sig was sent\n"; + unlink $pid_file; + $errors++; + } + + return; +} + +sub wait_for_servers { + my($timeout, @servers) = @_; + + my @pid_files = grep { defined($_) } + map { server_pid_file($_) } @servers; + + while ($timeout > 0 && @pid_files > 0) { + @pid_files = grep { -f $_ } @pid_files; + sleep 1 if (@pid_files > 0); + $timeout--; + } + + return; +} diff --git a/bin/tests/virtual-time/stop.sh b/bin/tests/virtual-time/stop.sh new file mode 100644 index 0000000000..f9a342dc53 --- /dev/null +++ b/bin/tests/virtual-time/stop.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: stop.sh,v 1.2 2010/06/17 05:38:05 marka Exp $ + +. ./conf.sh +$PERL ./stop.pl "$@" + diff --git a/bin/tests/virtual-time/testsock.pl b/bin/tests/virtual-time/testsock.pl new file mode 100644 index 0000000000..bb7e43dc0c --- /dev/null +++ b/bin/tests/virtual-time/testsock.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +# +# Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# 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: testsock.pl,v 1.2 2010/06/17 05:38:05 marka Exp $ + +# Test whether the interfaces on 10.53.0.* are up. + +require 5.001; + +use Socket; +use Getopt::Long; + +my $port = 0; +my $id = 0; +GetOptions("p=i" => \$port, + "i=i" => \$id); + +my @ids; +if ($id != 0) { + @ids = ($id); +} else { + @ids = (1..5); +} + +foreach $id (@ids) { + my $addr = pack("C4", 10, 53, 0, $id); + my $sa = pack_sockaddr_in($port, $addr); + socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname("tcp")) + or die "$0: socket: $!\n"; + setsockopt(SOCK, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); + + bind(SOCK, $sa) + or die sprintf("$0: bind(%s, %d): $!\n", + inet_ntoa($addr), $port); + close(SOCK); + sleep(1); +} diff --git a/bin/tests/virtual-time/vtwrapper.c b/bin/tests/virtual-time/vtwrapper.c new file mode 100644 index 0000000000..ebad264222 --- /dev/null +++ b/bin/tests/virtual-time/vtwrapper.c @@ -0,0 +1,307 @@ +/* + * Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * 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: vtwrapper.c,v 1.2 2010/06/17 05:38:05 marka Exp $ */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#ifdef SYS_select +#include +#endif +#ifdef SYS_poll +#include +#endif +#ifdef SYS_kevent +#include +#endif +#ifdef SYS_epoll_wait +#include +#endif + + +#ifdef SYS_gettimeofday +#define VIRTUAL_TIME +#ifdef VIRTUAL_TIME +static struct timeval epoch = { 0, 0 }; +static int _init_called = 0; + +void +_init(void) { + (void)syscall(SYS_gettimeofday, &epoch, NULL); + _init_called = 1; +} + +static void +absolute_inflate(struct timeval *vt, struct timeval *rt) +{ + double d; + + rt->tv_sec = vt->tv_sec; + rt->tv_usec = vt->tv_usec; + + if ((epoch.tv_sec > vt->tv_sec) || + ((epoch.tv_sec == vt->tv_sec) && (epoch.tv_usec > vt->tv_usec))) + return; + + rt->tv_sec -= epoch.tv_sec; + rt->tv_usec -= epoch.tv_usec; + while (rt->tv_usec < 0) { + rt->tv_sec -= 1; + rt->tv_usec += 1000000; + } + + if (rt->tv_sec == 0) + goto done; + + d = (double) (rt->tv_sec - 1); + d += (double) rt->tv_usec / 1000000.; + d = exp(d); + rt->tv_sec = (time_t) d; + d -= (double) rt->tv_sec; + rt->tv_usec = (suseconds_t) (d * 1000000.); + + done: + rt->tv_sec += epoch.tv_sec; + rt->tv_usec += epoch.tv_usec; + while (rt->tv_usec >= 1000000) { + rt->tv_sec += 1; + rt->tv_usec -= 1000000; + } + return; +} + +static void +absolute_deflate(struct timeval *rt, struct timeval *vt) { + double d; + + vt->tv_sec = rt->tv_sec; + vt->tv_usec = rt->tv_usec; + + if ((epoch.tv_sec > rt->tv_sec) || + ((epoch.tv_sec == rt->tv_sec) && (epoch.tv_usec > rt->tv_usec))) + return; + + vt->tv_sec -= epoch.tv_sec; + vt->tv_usec -= epoch.tv_usec; + while (vt->tv_usec < 0) { + vt->tv_sec -= 1; + vt->tv_usec += 1000000; + } + + if (vt->tv_sec == 0) + goto done; + + d = (double) vt->tv_sec; + d += (double) vt->tv_usec / 1000000.; + d = log(d); + vt->tv_sec = (time_t) d; + d -= (double) vt->tv_sec; + vt->tv_sec += 1; + vt->tv_usec = (suseconds_t) (d * 1000000.); + + done: + vt->tv_sec += epoch.tv_sec; + vt->tv_usec += epoch.tv_usec; + while (vt->tv_usec >= 1000000) { + vt->tv_sec += 1; + vt->tv_usec -= 1000000; + } + return; +} + +static void +interval_inflate(struct timeval *vt, struct timeval *rt) { + struct timeval now, tv; + + (void) gettimeofday(&now, NULL); + + absolute_deflate(&now, &tv); + + tv.tv_sec += vt->tv_sec; + tv.tv_usec += vt->tv_usec; + while (tv.tv_usec >= 1000000) { + tv.tv_sec += 1; + tv.tv_usec -= 1000000; + } + + absolute_inflate(&tv, rt); + + rt->tv_sec -= now.tv_sec; + rt->tv_usec -= now.tv_usec; + if (rt->tv_usec < 0) { + rt->tv_sec -= 1; + rt->tv_usec += 1000000; + } + return; +} + +static void +interval_deflate(struct timeval *rt, struct timeval *vt) { + struct timeval now, tv; + + vt->tv_sec = rt->tv_sec; + vt->tv_usec = rt->tv_usec; + + if ((vt->tv_sec == 0) && (vt->tv_usec <= 10000)) + return; + + (void) gettimeofday(&now, NULL); + + tv.tv_sec = now.tv_sec + rt->tv_sec; + tv.tv_usec = now.tv_usec + rt->tv_usec; + while (tv.tv_usec >= 1000000) { + tv.tv_sec += 1; + tv.tv_usec -= 1000000; + } + + absolute_deflate(&now, &now); + absolute_deflate(&tv, vt); + + vt->tv_sec -= now.tv_sec; + vt->tv_usec -= now.tv_usec; + while (vt->tv_usec < 0) { + vt->tv_sec -= 1; + vt->tv_usec += 1000000; + } + + if ((vt->tv_sec == 0) && (vt->tv_usec < 10000)) + vt->tv_usec = 10000; + return; +} +#endif + +int +gettimeofday(struct timeval *tv, struct timezone *tz) { +#ifdef VIRTUAL_TIME + struct timeval now; + int ret; + + if (!_init_called) _init(); + + if (epoch.tv_sec == 0) + return syscall(SYS_gettimeofday, tv, tz); + + ret = syscall(SYS_gettimeofday, &now, tz); + if (ret == 0) + absolute_inflate(&now, tv); + return ret; +#else + return syscall(SYS_gettimeofday, tv, tz); +#endif +} + +#ifdef SYS_select +int +select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, + struct timeval *timeout) +{ +#ifdef VIRTUAL_TIME + struct timeval tv; + + if (!_init_called) _init(); + + if (epoch.tv_sec == 0 || timeout == NULL || + (timeout->tv_sec == 0 && timeout->tv_usec == 0)) + return syscall(SYS_select, nfds, rfds, wfds, xfds, timeout); + + interval_deflate(timeout, &tv); + return syscall(SYS_select, nfds, rfds, wfds, xfds, &tv); +#else + return syscall(SYS_select, nfds, rfds, wfds, xfds, timeout); +#endif +} +#endif + +#ifdef SYS_poll +int +poll(struct pollfd fds[], nfds_t nfds, int timeout) { +#ifdef VIRTUAL_TIME + struct timeval in, out; + + if (!_init_called) _init(); + + if (timeout <= 0 || epoch.tv_sec == 0) + return syscall(SYS_poll, fds, nfds, timeout); + + in.tv_sec = timeout / 1000; + in.tv_usec = (timeout % 1000) * 1000; + interval_deflate(&in, &out); + timeout = out.tv_sec * 1000 + out.tv_usec / 1000; + return syscall(SYS_poll, fds, nfds, timeout); +#else + return syscall(SYS_poll, fds, nfds, timeout); +#endif +} +#endif + +#ifdef SYS_kevent +int +kevent(int kq, struct kevent *changelist, int nchanges, + struct kevent *eventlist, int nevents, const struct timespec *timeout) +{ +#ifdef VIRTUAL_TIME + struct timeval in, out; + struct timespec ts; + + if (!_init_called) _init(); + + if (epoch.tv_sec == 0 || timeout == NULL || + (timeout->tv_sec == 0 && timeout->tv_nsec == 0)) + return syscall(SYS_kevent, kq, changelist, nchanges, + eventlist, nevents, timeout); + + in.tv_sec = timeout->tv_sec; + in.tv_usec = timeout->tv_nsec / 1000; + interval_deflate(&in, &out); + ts.tv_sec = out.tv_sec; + ts.tv_nsec = out.tv_usec * 1000; + return syscall(SYS_kevent, kq, changelist, nchanges, eventlist, + nevents, &ts); +#else + return syscall(SYS_kevent, kq, changelist, nchanges, eventlist, + nevents, timeout); +#endif +} +#endif + +#ifdef SYS_epoll_wait +int +epoll_wait(int fd, struct epoll_event *events, int maxevents, int timeout) { +#ifdef VIRTUAL_TIME + struct timeval in, out; + + if (!_init_called) _init(); + + if (timeout == 0 || timeout == -1 || epoch.tv_sec == 0) + return syscall(SYS_epoll_wait, fd, events, maxevents, timeout); + + in.tv_sec = timeout / 1000; + in.tv_usec = (timeout % 1000) * 1000; + interval_deflate(&in, &out); + timeout = out.tv_sec * 1000 + out.tv_usec / 1000; + return syscall(SYS_poll, fd, events, maxevents, timeout); +#else + return syscall(SYS_poll, fd, events, maxevents, timeout); +#endif +} +#endif +#endif diff --git a/configure b/configure index fadd720d96..3a3b930765 100755 --- a/configure +++ b/configure @@ -14,7 +14,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # -# $Id: configure,v 1.481 2010/06/09 01:47:54 marka Exp $ +# $Id: configure,v 1.482 2010/06/17 05:39:19 marka Exp $ # # Portions Copyright (C) 1996-2001 Nominum, Inc. # @@ -29,7 +29,7 @@ # 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. -# From configure.in Revision: 1.498 . +# From configure.in Revision: 1.499 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.62. # @@ -34774,7 +34774,7 @@ ac_config_commands="$ac_config_commands chmod" # elsewhere if there's a good reason for doing so. # -ac_config_files="$ac_config_files Makefile make/Makefile make/mkdep lib/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/nls/Makefile lib/isc/$thread_dir/Makefile lib/isc/$thread_dir/include/Makefile lib/isc/$thread_dir/include/isc/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/export/Makefile lib/export/isc/Makefile lib/export/isc/include/Makefile lib/export/isc/include/isc/Makefile lib/export/isc/unix/Makefile lib/export/isc/unix/include/Makefile lib/export/isc/unix/include/isc/Makefile lib/export/isc/nls/Makefile lib/export/isc/$thread_dir/Makefile lib/export/isc/$thread_dir/include/Makefile lib/export/isc/$thread_dir/include/isc/Makefile lib/export/dns/Makefile lib/export/dns/include/Makefile lib/export/dns/include/dns/Makefile lib/export/dns/include/dst/Makefile lib/export/irs/Makefile lib/export/irs/include/Makefile lib/export/irs/include/irs/Makefile lib/export/isccfg/Makefile lib/export/isccfg/include/Makefile lib/export/isccfg/include/isccfg/Makefile lib/export/samples/Makefile lib/export/samples/Makefile-postinstall lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/lwres/Makefile lib/lwres/include/Makefile lib/lwres/include/lwres/Makefile lib/lwres/include/lwres/netdb.h lib/lwres/include/lwres/platform.h lib/lwres/man/Makefile lib/lwres/unix/Makefile lib/lwres/unix/include/Makefile lib/lwres/unix/include/lwres/Makefile lib/tests/Makefile lib/tests/include/Makefile lib/tests/include/tests/Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/named/Makefile bin/named/unix/Makefile bin/rndc/Makefile bin/dig/Makefile bin/nsupdate/Makefile bin/tests/Makefile bin/tests/names/Makefile bin/tests/master/Makefile bin/tests/rbt/Makefile bin/tests/db/Makefile bin/tests/tasks/Makefile bin/tests/timers/Makefile bin/tests/dst/Makefile bin/tests/mem/Makefile bin/tests/net/Makefile bin/tests/sockaddr/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/lwresd/Makefile bin/tests/system/tkey/Makefile bin/tests/headerdep_test.sh bin/tools/Makefile bin/dnssec/Makefile bin/pkcs11/Makefile doc/Makefile doc/arm/Makefile doc/misc/Makefile isc-config.sh doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-docbook-latex.xsl doc/xsl/isc-manpage.xsl doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter" +ac_config_files="$ac_config_files Makefile make/Makefile make/mkdep lib/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/nls/Makefile lib/isc/$thread_dir/Makefile lib/isc/$thread_dir/include/Makefile lib/isc/$thread_dir/include/isc/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/export/Makefile lib/export/isc/Makefile lib/export/isc/include/Makefile lib/export/isc/include/isc/Makefile lib/export/isc/unix/Makefile lib/export/isc/unix/include/Makefile lib/export/isc/unix/include/isc/Makefile lib/export/isc/nls/Makefile lib/export/isc/$thread_dir/Makefile lib/export/isc/$thread_dir/include/Makefile lib/export/isc/$thread_dir/include/isc/Makefile lib/export/dns/Makefile lib/export/dns/include/Makefile lib/export/dns/include/dns/Makefile lib/export/dns/include/dst/Makefile lib/export/irs/Makefile lib/export/irs/include/Makefile lib/export/irs/include/irs/Makefile lib/export/isccfg/Makefile lib/export/isccfg/include/Makefile lib/export/isccfg/include/isccfg/Makefile lib/export/samples/Makefile lib/export/samples/Makefile-postinstall lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/lwres/Makefile lib/lwres/include/Makefile lib/lwres/include/lwres/Makefile lib/lwres/include/lwres/netdb.h lib/lwres/include/lwres/platform.h lib/lwres/man/Makefile lib/lwres/unix/Makefile lib/lwres/unix/include/Makefile lib/lwres/unix/include/lwres/Makefile lib/tests/Makefile lib/tests/include/Makefile lib/tests/include/tests/Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/named/Makefile bin/named/unix/Makefile bin/rndc/Makefile bin/dig/Makefile bin/nsupdate/Makefile bin/tests/Makefile bin/tests/names/Makefile bin/tests/master/Makefile bin/tests/rbt/Makefile bin/tests/db/Makefile bin/tests/tasks/Makefile bin/tests/timers/Makefile bin/tests/dst/Makefile bin/tests/mem/Makefile bin/tests/net/Makefile bin/tests/sockaddr/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/lwresd/Makefile bin/tests/system/tkey/Makefile bin/tests/headerdep_test.sh bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile bin/dnssec/Makefile bin/pkcs11/Makefile doc/Makefile doc/arm/Makefile doc/misc/Makefile isc-config.sh doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-docbook-latex.xsl doc/xsl/isc-manpage.xsl doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter" # @@ -35471,6 +35471,8 @@ do "bin/tests/system/lwresd/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/system/lwresd/Makefile" ;; "bin/tests/system/tkey/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/system/tkey/Makefile" ;; "bin/tests/headerdep_test.sh") CONFIG_FILES="$CONFIG_FILES bin/tests/headerdep_test.sh" ;; + "bin/tests/virtual-time/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/virtual-time/Makefile" ;; + "bin/tests/virtual-time/conf.sh") CONFIG_FILES="$CONFIG_FILES bin/tests/virtual-time/conf.sh" ;; "bin/tools/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tools/Makefile" ;; "bin/dnssec/Makefile") CONFIG_FILES="$CONFIG_FILES bin/dnssec/Makefile" ;; "bin/pkcs11/Makefile") CONFIG_FILES="$CONFIG_FILES bin/pkcs11/Makefile" ;; diff --git a/configure.in b/configure.in index 9368cfa749..752b2a25a8 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_DIVERT_PUSH(1)dnl esyscmd([sed "s/^/# /" COPYRIGHT])dnl AC_DIVERT_POP()dnl -AC_REVISION($Revision: 1.498 $) +AC_REVISION($Revision: 1.499 $) AC_INIT(lib/dns/name.c) AC_PREREQ(2.59) @@ -3285,6 +3285,8 @@ AC_CONFIG_FILES([ bin/tests/system/lwresd/Makefile bin/tests/system/tkey/Makefile bin/tests/headerdep_test.sh + bin/tests/virtual-time/Makefile + bin/tests/virtual-time/conf.sh bin/tools/Makefile bin/dnssec/Makefile bin/pkcs11/Makefile