diff options
Diffstat (limited to 'testcode')
| -rwxr-xr-x | testcode/do-tests.sh | 26 | ||||
| -rw-r--r-- | testcode/fake_event.c | 2 | ||||
| -rwxr-xr-x | testcode/mini_tdir.sh | 171 | ||||
| -rw-r--r-- | testcode/petal.c | 4 | ||||
| -rwxr-xr-x | testcode/run_vm.sh | 26 | ||||
| -rw-r--r-- | testcode/streamtcp.c | 4 | ||||
| -rw-r--r-- | testcode/unitverify.c | 3 | 
7 files changed, 206 insertions, 30 deletions
diff --git a/testcode/do-tests.sh b/testcode/do-tests.sh index dcf93907e3882..5439f0f285e6a 100755 --- a/testcode/do-tests.sh +++ b/testcode/do-tests.sh @@ -1,15 +1,15 @@  #!/usr/bin/env bash  . testdata/common.sh -NEED_SPLINT='00-lint.tpkg' -NEED_DOXYGEN='01-doc.tpkg' -NEED_XXD='fwd_compress_c00c.tpkg fwd_zero.tpkg' -NEED_NC='fwd_compress_c00c.tpkg fwd_zero.tpkg' -NEED_CURL='06-ianaports.tpkg root_anchor.tpkg' -NEED_WHOAMI='07-confroot.tpkg' -NEED_IPV6='fwd_ancil.tpkg fwd_tcp_tc6.tpkg stub_udp6.tpkg edns_cache.tpkg' -NEED_NOMINGW='tcp_sigpipe.tpkg 07-confroot.tpkg 08-host-lib.tpkg fwd_ancil.tpkg' -NEED_DNSCRYPT_PROXY='dnscrypt_queries.tpkg dnscrypt_queries_chacha.tpkg' +NEED_SPLINT='00-lint.tdir' +NEED_DOXYGEN='01-doc.tdir' +NEED_XXD='fwd_compress_c00c.tdir fwd_zero.tdir' +NEED_NC='fwd_compress_c00c.tdir fwd_zero.tdir' +NEED_CURL='06-ianaports.tdir root_anchor.tdir' +NEED_WHOAMI='07-confroot.tdir' +NEED_IPV6='fwd_ancil.tdir fwd_tcp_tc6.tdir stub_udp6.tdir edns_cache.tdir' +NEED_NOMINGW='tcp_sigpipe.tdir 07-confroot.tdir 08-host-lib.tdir fwd_ancil.tdir' +NEED_DNSCRYPT_PROXY='dnscrypt_queries.tdir dnscrypt_queries_chacha.tdir'  # test if dig and ldns-testns are available.  test_tool_avail "dig" @@ -30,9 +30,9 @@ else  fi  cd testdata; -sh ../testcode/mini_tpkg.sh clean +sh ../testcode/mini_tdir.sh clean  rm -f .perfstats.txt -for test in `ls *.tpkg`; do +for test in `ls -d *.tdir`; do  	SKIP=0  	skip_if_in_list $test "$NEED_SPLINT" "splint"  	skip_if_in_list $test "$NEED_DOXYGEN" "doxygen" @@ -54,10 +54,10 @@ for test in `ls *.tpkg`; do  	fi  	if test $SKIP -eq 0; then  		echo $test -		sh ../testcode/mini_tpkg.sh -a ../.. exe $test +		sh ../testcode/mini_tdir.sh -a ../.. exe $test  	else  		echo "skip $test"  	fi  done -sh ../testcode/mini_tpkg.sh report +sh ../testcode/mini_tdir.sh report  cat .perfstats.txt diff --git a/testcode/fake_event.c b/testcode/fake_event.c index 154013a8c8e3c..cd23b8feb49a9 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -1331,7 +1331,7 @@ int serviced_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))  	return 0;  } -/* timers in testbound for autotrust. statistics tested in tpkg. */ +/* timers in testbound for autotrust. statistics tested in tdir. */  struct comm_timer* comm_timer_create(struct comm_base* base,   	void (*cb)(void*), void* cb_arg)  { diff --git a/testcode/mini_tdir.sh b/testcode/mini_tdir.sh new file mode 100755 index 0000000000000..96745515e3e4a --- /dev/null +++ b/testcode/mini_tdir.sh @@ -0,0 +1,171 @@ +# tdir that only exes the files. +args="../.." +if test "$1" = "-a"; then +	args=$2 +	shift +	shift +fi +	 +if test "$1" = "clean"; then +	echo "rm -f result.* .done* .tdir.var.master .tdir.var.test" +	rm -f result.* .done* .tdir.var.master .tdir.var.test +	exit 0 +fi +if test "$1" = "fake"; then +	echo "minitdir fake $2" +	echo "fake" > .done-`basename $2 .tdir` +	exit 0 +fi +if test "$1" = "-f" && test "$2" = "report"; then +	echo "Minitdir Long Report" +	pass=0 +	fail=0 +	skip=0 +	echo "   STATUS    ELAPSED TESTNAME TESTDESCRIPTION" +	for result in *.tdir; do +		name=`basename $result .tdir` +		timelen="     " +		desc="" +		if test -f "result.$name"; then +			timestart=`grep ^DateRunStart: "result.$name" | sed -e 's/DateRunStart: //'` +			timeend=`grep ^DateRunEnd: "result.$name" | sed -e 's/DateRunEnd: //'` +			timesec=`expr $timeend - $timestart` +			timelen=`printf %4ds $timesec` +			if test $? -ne 0; then +				timelen="$timesec""s" +			fi +			desc=`grep ^Description: "result.$name" | sed -e 's/Description: //'` +		fi +		if test -f ".done-$name"; then +			if test "$1" != "-q"; then +				echo "** PASSED ** $timelen $name: $desc" +				pass=`expr $pass + 1` +			fi +		else +			if test -f "result.$name"; then +				echo "!! FAILED !! $timelen $name: $desc" +				fail=`expr $fail + 1` +			else +				echo ".> SKIPPED<< $timelen $name: $desc" +				skip=`expr $skip + 1` +			fi +		fi +	done +	echo "" +	if test "$skip" = "0"; then +		echo "$pass pass, $fail fail" +	else +		echo "$pass pass, $fail fail, $skip skip" +	fi +	echo "" +	exit 0 +fi +if test "$1" = "report" || test "$2" = "report"; then +	echo "Minitdir Report" +	for result in *.tdir; do +		name=`basename $result .tdir` +		if test -f ".done-$name"; then +			if test "$1" != "-q"; then +				echo "** PASSED ** : $name" +			fi +		else +			if test -f "result.$name"; then +				echo "!! FAILED !! : $name" +			else +				echo ">> SKIPPED<< : $name" +			fi +		fi +	done +	exit 0 +fi + +if test "$1" != 'exe'; then +	# usage +	echo "mini tdir. Reduced functionality for old shells." +	echo "	tdir exe <file>" +	echo "	tdir fake <file>" +	echo "	tdir clean" +	echo "	tdir [-q|-f] report" +	exit 1 +fi +shift + +# do not execute if the disk is too full +#DISKLIMIT=100000 +# This check is not portable (to Solaris 10). +#avail=`df . | tail -1 | awk '{print $4}'` +#if test "$avail" -lt "$DISKLIMIT"; then +	#echo "minitdir: The disk is too full! Only $avail." +	#exit 1 +#fi + +name=`basename $1 .tdir` +dir=$name.$$ +result=result.$name +done=.done-$name +success="no" +if test -x "`which bash`"; then +	shell="bash" +else +	shell="sh" +fi + +# check already done +if test -f .done-$name; then +	echo "minitdir .done-$name exists. skip test." +	exit 0 +fi + +# Copy +echo "minitdir copy $1 to $dir" +mkdir $dir +cp -a $name.tdir/* $dir/ +cd $dir + +# EXE +echo "minitdir exe $name" > $result +grep "Description:" $name.dsc >> $result 2>&1 +echo "DateRunStart: "`date "+%s" 2>/dev/null` >> $result +if test -f $name.pre; then +	echo "minitdir exe $name.pre" +	echo "minitdir exe $name.pre" >> $result +	$shell $name.pre $args >> $result +	if test $? -ne 0; then +		echo "Warning: $name.pre did not exit successfully" +	fi +fi +if test -f $name.test; then +	echo "minitdir exe $name.test" +	echo "minitdir exe $name.test" >> $result +	$shell $name.test $args >>$result 2>&1 +	if test $? -ne 0; then +		echo "$name: FAILED" >> $result +		echo "$name: FAILED" +		success="no" +	else +		echo "$name: PASSED" >> $result +		echo "$name: PASSED" > ../.done-$name +		echo "$name: PASSED" +		success="yes" +	fi +fi +if test -f $name.post; then +	echo "minitdir exe $name.post" +	echo "minitdir exe $name.post" >> $result +	$shell $name.post $args >> $result +	if test $? -ne 0; then +		echo "Warning: $name.post did not exit successfully" +	fi +fi +echo "DateRunEnd: "`date "+%s" 2>/dev/null` >> $result + +mv $result .. +cd .. +rm -rf $dir +# compat for windows where deletion may not succeed initially (files locked +# by processes that still have to exit). +if test $? -eq 1; then +	echo "minitdir waiting for processes to terminate" +	sleep 2 # some time to exit, and try again +	rm -rf $dir +fi diff --git a/testcode/petal.c b/testcode/petal.c index b30549365f514..1c26fa700346d 100644 --- a/testcode/petal.c +++ b/testcode/petal.c @@ -643,7 +643,9 @@ int main(int argc, char* argv[])  #ifdef HAVE_ERR_LOAD_CRYPTO_STRINGS  	ERR_load_crypto_strings();  #endif +#if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_SSL)  	ERR_load_SSL_strings(); +#endif  #if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_CRYPTO)  	OpenSSL_add_all_algorithms();  #else @@ -654,7 +656,7 @@ int main(int argc, char* argv[])  #if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_SSL)  	(void)SSL_library_init();  #else -	(void)OPENSSL_init_ssl(0, NULL); +	(void)OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);  #endif  	do_service(addr, port, key, cert); diff --git a/testcode/run_vm.sh b/testcode/run_vm.sh index 78649f07a9415..d4c2a2e11dda4 100755 --- a/testcode/run_vm.sh +++ b/testcode/run_vm.sh @@ -1,7 +1,7 @@  #!/usr/local/bin/bash -# run tpkg tests from within a VM.  Looks for loopback addr. +# run tdir tests from within a VM.  Looks for loopback addr.  # if run not from within a VM, runs the tests as usual. -# with one argument: run that tpkg, otherwise, run all tpkgs. +# with one argument: run that tdir, otherwise, run all tdirs.  get_lo0_ip4() {          if test -x /sbin/ifconfig @@ -23,12 +23,12 @@ else          ALT_LOOPBACK=true  fi  cd testdata -TPKG=../testcode/mini_tpkg.sh -#RUNLIST=`(ls -1 *.tpkg|grep -v '^0[016]')` -RUNLIST=`(ls -1 *.tpkg)` +TPKG=../testcode/mini_tdir.sh +#RUNLIST=`(ls -1d *.tdir|grep -v '^0[016]')` +RUNLIST=`(ls -1d *.tdir)`  if test "$#" = "1"; then RUNLIST="$1"; fi -# fix up tpkg that was edited on keyboard interrupt. +# fix up tdir that was edited on keyboard interrupt.  cleanup() {  	echo cleanup  	if test -f "$t.bak"; then mv "$t.bak" "$t"; fi @@ -44,16 +44,15 @@ do  		continue  	fi  	# We have alternative 127.0.0.1 number -	if ( echo $t | grep '6\.tpkg$' ) # skip IPv6 tests +	if ( echo $t | grep '6\.tdir$' ) # skip IPv6 tests  	then  		continue -       	elif test "$t" = "edns_cache.tpkg" # This one is IPv6 too! +       	elif test "$t" = "edns_cache.tdir" # This one is IPv6 too!  	then  		continue  	fi -	cp -p "$t" "$t.bak" -	tar xzf $t -	find "${t%.tpkg}.dir" -type f \ +	cp -ap "$t" "$t.bak" +	find "${t}" -type f \  		-exec grep -q -e '127\.0\.0\.1' -e '@localhost' {} \; -print | {  		while read f  		do @@ -63,15 +62,14 @@ do  			mv "$f._" "$f"  		done  	} -	find "${t%.tpkg}.dir" -type d -name "127.0.0.1" -print | { +	find "${t}" -type d -name "127.0.0.1" -print | {  		while read d  		do  			mv -v "$d" "${d%127.0.0.1}${LO0_IP4}"  		done  	} -	tar czf $t "${t%.tpkg}.dir" -	rm -fr "${t%.tpkg}.dir"  	$TPKG exe $t +	rm -fr "${t}"  	mv "$t.bak" "$t"  done  # get out of testdata/ diff --git a/testcode/streamtcp.c b/testcode/streamtcp.c index f5eb8fc48b1da..b494507def265 100644 --- a/testcode/streamtcp.c +++ b/testcode/streamtcp.c @@ -410,7 +410,9 @@ int main(int argc, char** argv)  		return 1;  	}  	if(usessl) { +#if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_SSL)  		ERR_load_SSL_strings(); +#endif  #if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_CRYPTO)  		OpenSSL_add_all_algorithms();  #else @@ -421,7 +423,7 @@ int main(int argc, char** argv)  #if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_SSL)  		(void)SSL_library_init();  #else -		(void)OPENSSL_init_ssl(0, NULL); +		(void)OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);  #endif  	}  	send_em(svr, udp, usessl, noanswer, argc, argv); diff --git a/testcode/unitverify.c b/testcode/unitverify.c index e5e5b0f7bacb0..e421d90bca569 100644 --- a/testcode/unitverify.c +++ b/testcode/unitverify.c @@ -299,6 +299,7 @@ verifytest_file(const char* fname, const char* at_date)  	struct module_env env;  	struct val_env ve;  	time_t now = time(NULL); +	unit_show_func("signature verify", fname);  	if(!list)  		fatal_exit("could not read %s: %s", fname, strerror(errno)); @@ -341,6 +342,7 @@ dstest_file(const char* fname)  	struct entry* e;  	struct entry* list = read_datafile(fname, 1);  	struct module_env env; +	unit_show_func("DS verify", fname);  	if(!list)  		fatal_exit("could not read %s: %s", fname, strerror(errno)); @@ -474,6 +476,7 @@ nsec3_hash_test(const char* fname)  	sldns_buffer* buf = sldns_buffer_new(65535);  	struct entry* e;  	struct entry* list = read_datafile(fname, 1); +	unit_show_func("NSEC3 hash", fname);  	if(!list)  		fatal_exit("could not read %s: %s", fname, strerror(errno));  | 
