[kvm-unit-tests PATCH] scripts: add test runner filter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Feiner <pfeiner@xxxxxxxxxx>

Add -t <name> option to run_tests.sh. Only test with the given name is
run. It's an error if there's no matching test.

Signed-off-by: Peter Feiner <pfeiner@xxxxxxxxxx>
Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
---
 run_tests.sh        |  6 +++++-
 scripts/common.bash | 19 +++++++++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/run_tests.sh b/run_tests.sh
index c35a05802346..9c914a3678ca 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -16,6 +16,7 @@ cat <<EOF
 
 Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS]
 
+    -t: Only execute this test
     -h: Output this help text
     -v: Enables verbose mode
     -a: Run all tests, including those flagged as 'nodefault'
@@ -31,10 +32,13 @@ EOF
 RUNTIME_arch_run="./$TEST_DIR/run"
 source scripts/runtime.bash
 
-while getopts "ag:hj:v" opt; do
+while getopts "t:ag:hj:v" opt; do
     case $opt in
         a)
             run_all_tests="yes"
+	    ;;
+        t)
+            only_test=$OPTARG
             ;;
         g)
             only_group=$OPTARG
diff --git a/scripts/common.bash b/scripts/common.bash
index ee9143c5d630..3c4e2ecdd603 100644
--- a/scripts/common.bash
+++ b/scripts/common.bash
@@ -12,12 +12,16 @@ function for_each_unittest()
 	local check
 	local accel
 	local timeout
+	local found=0
 
 	exec {fd}<"$unittests"
 
 	while read -u $fd line; do
 		if [[ "$line" =~ ^\[(.*)\]$ ]]; then
-			"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+			if [[ -z "$only_test" || "$testname" == "$only_test" ]]; then
+				"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+				found=$((found + 1))
+			fi
 			testname=${BASH_REMATCH[1]}
 			smp=1
 			kernel=""
@@ -45,6 +49,17 @@ function for_each_unittest()
 			timeout=${BASH_REMATCH[1]}
 		fi
 	done
-	"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+	if [[ -z "$only_test" || "$testname" == "$only_test" ]]; then
+		"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
+		found=$((found + 1))
+	fi
+
 	exec {fd}<&-
+
+	if [[ $found -eq 0 ]]; then
+		echo "Didn't run any tests."
+		return 1
+	fi
+
+	echo "Ran $found test(s)."
 }
-- 
2.12.2.816.g2cccc81164-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux