svn commit: samba r20750 - in branches/SAMBA_4_0/source/script/tests: .

jelmer at samba.org jelmer at samba.org
Sun Jan 14 02:02:07 GMT 2007


Author: jelmer
Date: 2007-01-14 02:02:06 +0000 (Sun, 14 Jan 2007)
New Revision: 20750

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20750

Log:
Use files in script/tests to build a recipe rather than running the tests immediately.

Modified:
   branches/SAMBA_4_0/source/script/tests/selftest.sh
   branches/SAMBA_4_0/source/script/tests/test_functions.sh


Changeset:
Modified: branches/SAMBA_4_0/source/script/tests/selftest.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/selftest.sh	2007-01-14 01:44:24 UTC (rev 20749)
+++ branches/SAMBA_4_0/source/script/tests/selftest.sh	2007-01-14 02:02:06 UTC (rev 20750)
@@ -104,6 +104,107 @@
 	TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:progress=no"
 fi
 
+ runtest() {
+	if [ -z "$PREFIX" ]; then
+	    PREFIX=test_prefix
+	    mkdir -p $PREFIX
+	fi
+	name=$1
+	shift 1
+	cmdline="$*"
+
+	SMBD_IS_UP="no"
+
+	shname=`echo $name | \
+	sed -e 's%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g'`
+
+	UNIQUE_PID=`/bin/sh -c 'echo $$'`
+	TEST_LOG="$PREFIX/test_log.${UNIQUE_PID}"
+	TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap"
+	trap "rm -f $TEST_LOG $TEST_PCAP" EXIT
+
+        if [ -n "$SMBD_TEST_LOG" -a -z "$smbd_log_size" ]; then
+	    smbd_log_size=`wc -l < $SMBD_TEST_LOG`;
+	fi
+
+	if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+		echo "--==--==--==--==--==--==--==--==--==--==--"
+		echo "Running test $name (level 0 stdout)"
+		echo "--==--==--==--==--==--==--==--==--==--==--"
+		date
+		echo "Testing $name"
+	else
+	        nf="`expr $failed + $totalfailed`";
+		if [ "$nf" = "0" ]; then 
+		    echo "Testing $name"
+		else 
+		    echo "Testing $name ($nf tests failed so far)"
+		fi
+	fi
+
+	smbd_check_only && SMBD_IS_UP="yes"
+	if [ x"$SMBD_IS_UP" != x"yes" ];then
+		if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+			echo "SMBD is down! Skipping: $cmdline"
+			echo "=========================================="
+			echo "TEST SKIPPED: $name (reason SMBD is down)"
+			echo "=========================================="
+   		else
+			echo "TEST SKIPPED: $name (reason SMBD is down)"
+		fi
+		return 1
+	fi
+
+	if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
+		SOCKET_WRAPPER_PCAP_FILE=$TEST_PCAP
+		export SOCKET_WRAPPER_PCAP_FILE
+	fi
+
+	( $cmdline > $TEST_LOG 2>&1 )
+	status=$?
+	# show any additional output from smbd that has happened in this test
+	smbd_have_test_log && {		    
+	    new_log_size=`wc -l < $SMBD_TEST_LOG`;
+	    test "$new_log_size" = "$smbd_log_size" || {
+		echo "SMBD OUTPUT:";
+		incr_log_size=`expr $new_log_size - $smbd_log_size`;
+		tail -$incr_log_size $SMBD_TEST_LOG;
+		smbd_log_size=$new_log_size;
+	    }
+	}
+	if [ x"$status" != x"0" ]; then
+		echo "TEST OUTPUT:"
+		cat $TEST_LOG;
+		rm -f $TEST_LOG;
+		if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
+			echo "TEST PCAP: $TEST_PCAP"
+		fi
+		if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+			echo "=========================================="
+			echo "TEST FAILED: $name (status $status)"
+			echo "=========================================="
+   		else
+			echo "TEST FAILED: $cmdline (status $status)"
+		fi
+		trap "" EXIT
+		return 1;
+	fi
+	rm -f $TEST_LOG;
+	if [ x"$MAKE_TEST_KEEP_PCAP" = x"yes" ];then
+		echo "TEST PCAP: $TEST_PCAP"
+	else
+		rm -f $TEST_PCAP;
+	fi
+	if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+		echo "ALL OK: $cmdline"
+		echo "=========================================="
+		echo "TEST PASSED: $name"
+		echo "=========================================="
+	fi
+	trap "" EXIT
+	return 0;
+}
+
 START=`date`
 (
  # give time for nbt server to register its names
@@ -123,7 +224,19 @@
 totalfailed=0
 export totalfailed
 
- . script/tests/tests_$TESTS.sh
+. script/tests/tests_$TESTS.sh | (
+ 	while read LINE
+	do
+		if [ "$LINE" = "-- TEST --" ]; then
+			read NAME
+			read CMDLINE
+			runtest "$NAME" "$CMDLINE"
+		else
+			echo "$LINE"
+		fi
+ done
+	 )
+
  exit $totalfailed
 ) 9>$SMBD_TEST_FIFO
 failed=$?

Modified: branches/SAMBA_4_0/source/script/tests/test_functions.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/test_functions.sh	2007-01-14 01:44:24 UTC (rev 20749)
+++ branches/SAMBA_4_0/source/script/tests/test_functions.sh	2007-01-14 02:02:06 UTC (rev 20750)
@@ -78,104 +78,12 @@
 }
 
 testit() {
-	if [ -z "$PREFIX" ]; then
-	    PREFIX=test_prefix
-	    mkdir -p $PREFIX
-	fi
 	name=$1
 	shift 1
 	cmdline="$*"
-
-	SMBD_IS_UP="no"
-
-	shname=`echo $name | \
-	sed -e 's%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g'`
-
-	UNIQUE_PID=`/bin/sh -c 'echo $$'`
-	TEST_LOG="$PREFIX/test_log.${UNIQUE_PID}"
-	TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap"
-	trap "rm -f $TEST_LOG $TEST_PCAP" EXIT
-
-        if [ -n "$SMBD_TEST_LOG" -a -z "$smbd_log_size" ]; then
-	    smbd_log_size=`wc -l < $SMBD_TEST_LOG`;
-	fi
-
-	if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
-		echo "--==--==--==--==--==--==--==--==--==--==--"
-		echo "Running test $name (level 0 stdout)"
-		echo "--==--==--==--==--==--==--==--==--==--==--"
-		date
-		echo "Testing $name"
-	else
-	        nf="`expr $failed + $totalfailed`";
-		if [ "$nf" = "0" ]; then 
-		    echo "Testing $name"
-		else 
-		    echo "Testing $name ($nf tests failed so far)"
-		fi
-	fi
-
-	smbd_check_only && SMBD_IS_UP="yes"
-	if [ x"$SMBD_IS_UP" != x"yes" ];then
-		if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
-			echo "SMBD is down! Skipping: $cmdline"
-			echo "=========================================="
-			echo "TEST SKIPPED: $name (reason SMBD is down)"
-			echo "=========================================="
-   		else
-			echo "TEST SKIPPED: $name (reason SMBD is down)"
-		fi
-		return 1
-	fi
-
-	if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
-		SOCKET_WRAPPER_PCAP_FILE=$TEST_PCAP
-		export SOCKET_WRAPPER_PCAP_FILE
-	fi
-
-	( $cmdline > $TEST_LOG 2>&1 )
-	status=$?
-	# show any additional output from smbd that has happened in this test
-	smbd_have_test_log && {		    
-	    new_log_size=`wc -l < $SMBD_TEST_LOG`;
-	    test "$new_log_size" = "$smbd_log_size" || {
-		echo "SMBD OUTPUT:";
-		incr_log_size=`expr $new_log_size - $smbd_log_size`;
-		tail -$incr_log_size $SMBD_TEST_LOG;
-		smbd_log_size=$new_log_size;
-	    }
-	}
-	if [ x"$status" != x"0" ]; then
-		echo "TEST OUTPUT:"
-		cat $TEST_LOG;
-		rm -f $TEST_LOG;
-		if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
-			echo "TEST PCAP: $TEST_PCAP"
-		fi
-		if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
-			echo "=========================================="
-			echo "TEST FAILED: $name (status $status)"
-			echo "=========================================="
-   		else
-			echo "TEST FAILED: $cmdline (status $status)"
-		fi
-		trap "" EXIT
-		return 1;
-	fi
-	rm -f $TEST_LOG;
-	if [ x"$MAKE_TEST_KEEP_PCAP" = x"yes" ];then
-		echo "TEST PCAP: $TEST_PCAP"
-	else
-		rm -f $TEST_PCAP;
-	fi
-	if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
-		echo "ALL OK: $cmdline"
-		echo "=========================================="
-		echo "TEST PASSED: $name"
-		echo "=========================================="
-	fi
-	trap "" EXIT
-	return 0;
+	echo "-- TEST --"
+	echo $name
+	echo $cmdline
 }
 
 testok() {



More information about the samba-cvs mailing list