From e38dc152d6b96aa724c6b77f3383bb75787c6f81 Mon Sep 17 00:00:00 2001
From: Corinna Vinschen <github@cygwin.de>
Date: Wed, 4 Mar 2015 11:55:50 +0100
Subject: Allow to disable tests easily

- Introduce the tests_disabled array, add biotest, explicit_bzero and
  pidwraptest.
- Add preceeding comment to explain why every test is skipped
- Rearrange loops generating Makefile.am dependencies to look for tests
  in tests_disabled first and skip them.

Signed-off-by: Corinna Vinschen <github@cygwin.de>
---
 update.sh | 58 +++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 33 insertions(+), 25 deletions(-)

diff --git a/update.sh b/update.sh
index 29012ad..435c888 100755
--- a/update.sh
+++ b/update.sh
@@ -198,9 +198,6 @@ for i in `find $libcrypto_regress -name '*.c'`; do
 	 $CP "$i" tests
 done
 
-# the BIO tests rely on resolver results that are OS and environment-specific
-rm tests/biotest.c
-
 # copy libc tests
 $CP $libc_regress/arc4random-fork/arc4random-fork.c tests/arc4randomforktest.c
 $CP $libc_regress/explicit_bzero/explicit_bzero.c tests
@@ -229,27 +226,38 @@ tests_posix_only=(
 	explicit_bzero
 	pidwraptest
 )
+# the BIO tests rely on resolver results that are OS and environment-specific
+# explicit_bzero relies on SA_ONSTACK, not available on all systems
+# pidwraptest relies on an OS-specific way to give out pids and is generally
+# awkward on systems with slow fork
+tests_disabled=(
+	biotest
+	explicit_bzero
+	pidwraptest
+)
 $CP $libc_src/string/memmem.c tests/
 (cd tests
 	$CP Makefile.am.tpl Makefile.am
 
 	for i in `ls -1 *.c|sort|grep -v memmem.c`; do
 		TEST=`echo $i|sed -e "s/\.c//"`
-		if [[ ${tests_posix_only[*]} =~ "$TEST" ]]; then
-			echo "if !HOST_WIN" >> Makefile.am
-		fi
-		if ! [[ ${test_drivers[*]} =~ "$TEST" ]]; then
-			echo "TESTS += $TEST" >> Makefile.am
-		fi
-		echo "check_PROGRAMS += $TEST" >> Makefile.am
-		echo "${TEST}_SOURCES = $i" >> Makefile.am
-		if [[ ${TEST} = "explicit_bzero" ]]; then
-			echo "if !HAVE_MEMMEM" >> Makefile.am
-			echo "explicit_bzero_SOURCES += memmem.c" >> Makefile.am
-			echo "endif" >> Makefile.am
-		fi
-		if [[ ${tests_posix_only[*]} =~ "$TEST" ]]; then
-			echo "endif" >> Makefile.am
+		if ! [[ ${tests_disabled[*]} =~ "$TEST" ]]; then
+			if [[ ${tests_posix_only[*]} =~ "$TEST" ]]; then
+				echo "if !HOST_WIN" >> Makefile.am
+			fi
+			if ! [[ ${test_drivers[*]} =~ "$TEST" ]]; then
+				echo "TESTS += $TEST" >> Makefile.am
+			fi
+			echo "check_PROGRAMS += $TEST" >> Makefile.am
+			echo "${TEST}_SOURCES = $i" >> Makefile.am
+			if [[ ${TEST} = "explicit_bzero" ]]; then
+				echo "if !HAVE_MEMMEM" >> Makefile.am
+				echo "explicit_bzero_SOURCES += memmem.c" >> Makefile.am
+				echo "endif" >> Makefile.am
+			fi
+			if [[ ${tests_posix_only[*]} =~ "$TEST" ]]; then
+				echo "endif" >> Makefile.am
+			fi
 		fi
 	done
 )
@@ -259,16 +267,16 @@ $CP $libcrypto_regress/pqueue/expected.txt tests/pq_expected.txt
 chmod 755 tests/testssl
 for i in "${test_drivers[@]}"; do
 	if [ -e tests/${i}.sh ]; then
-		if [[ ${tests_posix_only[*]} =~ "$i" ]]; then
-			echo "if !HOST_WIN" >> tests/Makefile.am
-		fi
 		if ! [[ ${tests_disabled[*]} =~ "$i" ]]; then
+			if [[ ${tests_posix_only[*]} =~ "$i" ]]; then
+				echo "if !HOST_WIN" >> tests/Makefile.am
+			fi
 			echo "TESTS += ${i}.sh" >> tests/Makefile.am
+			if [[ ${tests_posix_only[*]} =~ "$i" ]]; then
+				echo "endif" >> tests/Makefile.am
+			fi
+			echo "EXTRA_DIST += ${i}.sh" >> tests/Makefile.am
 		fi
-		if [[ ${tests_posix_only[*]} =~ "$i" ]]; then
-			echo "endif" >> tests/Makefile.am
-		fi
-		echo "EXTRA_DIST += ${i}.sh" >> tests/Makefile.am
 	fi
 done
 echo "EXTRA_DIST += aeadtests.txt" >> tests/Makefile.am
-- 
cgit v1.2.3-55-g6feb