[CRIU] [PATCH] test/zdtm: use TEST_PATTERN as argument

Yicheng Qin yichengq at google.com
Mon Aug 12 21:22:24 EDT 2013


Use TEST_PATTERN instead of TEST_NAME as argument.
All previous zdtm commands can be used still.
It is useful to run certain part of tests.

Example of running in-namespace tests only:
	./test/zdtm.sh ^ns/.*

Signed-off-by: Yicheng Qin <yichengq at google.com>
---
 test/zdtm.sh | 50 +++++++++++++++++++++++---------------------------
 1 file changed, 23 insertions(+), 27 deletions(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index b370a9e..8881b3a 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -642,32 +642,14 @@ if [ $COMPILE_ONLY -eq 0 ]; then
 	check_criu || exit 1
 fi
 
-if [ $# -eq 0 ]; then
-
-	if [ $COMPILE_ONLY -eq 0 ]; then
-		check_mainstream || exit 1
-	fi
-
-	for t in $TEST_LIST; do
-		run_test $t || case_error $t
-	done
-	for t in $UTS_TEST_LIST; do
-		run_test $t -n uts || case_error $t
-	done
-	for t in $MNT_TEST_LIST; do
-		run_test $t -n mnt || case_error $t
-	done
-	for t in $IPC_TEST_LIST; do
-		run_test $t -n ipc || case_error $t
-	done
-elif [ "$1" = "-l" ]; then
+if [ "$1" = "-l" ]; then
 	echo $TEST_LIST $UTS_TEST_LIST $MNT_TEST_LIST $IPC_TEST_LIST | tr ' ' '\n'
 elif [ "$1" = "-h" ]; then
 	cat >&2 <<EOF
 This script is used for executing unit tests.
 Usage:
 zdtm.sh [OPTIONS]
-zdtm.sh [OPTIONS] [TEST NAME]
+zdtm.sh [OPTIONS] [TEST PATTERN]
 Options:
 	-l : Show list of tests.
 	-d : Dump a test process and check that this process can continue working.
@@ -683,15 +665,29 @@ EOF
 elif [ "${1:0:1}" = '-' ]; then
 	echo "unrecognized option $1"
 else
-	if echo $UTS_TEST_LIST | fgrep -qw $1; then
-		run_test $1 -n uts || case_error $1
-	elif echo $MNT_TEST_LIST | fgrep -qw $1; then
-		run_test $1 -n mnt || case_error $1
-	elif echo $IPC_TEST_LIST | fgrep -qw $1; then
-		run_test $1 -n ipc || case_error $1
+	if [ $COMPILE_ONLY -eq 0 ]; then
+		check_mainstream || exit 1
+	fi
+
+	local pattern
+	if [ $# -eq 0 ]; then
+		pattern='.*'
 	else
-		run_test $1 || case_error $1
+		pattern=$1
 	fi
+
+	for t in $(echo "$TEST_LIST" | grep -x "$pattern"); do
+		run_test $t || case_error $t
+	done
+	for t in $(echo "$UTS_TEST_LIST" | grep -x "$pattern"); do
+		run_test $t -n uts || case_error $t
+	done
+	for t in $(echo "$MNT_TEST_LIST" | grep -x "$pattern"); do
+		run_test $t -n mnt || case_error $t
+	done
+	for t in $(echo "$IPC_TEST_LIST" | grep -x "$pattern"); do
+		run_test $t -n ipc || case_error $t
+	done
 fi
 
 [ -n "$TMP_TREE" ] && rm -rf $TMP_TREE || exit 0
-- 
1.8.3



More information about the CRIU mailing list