[kvm-unit-tests PATCH v2 1/6] run_tests.sh: share run_all as for_each_unittest

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

 



To avoid duplicating unittests.cfg parsing code in other scripts,
let's put it in a file where it can be shared.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 run_tests.sh           | 46 ++--------------------------------------------
 scripts/functions.bash | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 44 deletions(-)
 create mode 100644 scripts/functions.bash

diff --git a/run_tests.sh b/run_tests.sh
index e48f1db049f81..ebb7e9fe6fdfc 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -5,6 +5,7 @@ if [ ! -f config.mak ]; then
     exit
 fi
 source config.mak
+source scripts/functions.bash
 
 config=$TEST_DIR/unittests.cfg
 qemu=${QEMU:-qemu-system-$ARCH}
@@ -61,49 +62,6 @@ function run()
     fi
 }
 
-function run_all()
-{
-    local config="$1"
-    local testname
-    local smp
-    local kernel
-    local opts
-    local groups
-    local arch
-    local check
-
-    exec {config_fd}<$config
-
-    while read -u $config_fd line; do
-        if [[ "$line" =~ ^\[(.*)\]$ ]]; then
-            run "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
-            testname=${BASH_REMATCH[1]}
-            smp=1
-            kernel=""
-            opts=""
-            groups=""
-            arch=""
-            check=""
-        elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
-            kernel=$TEST_DIR/${BASH_REMATCH[1]}
-        elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
-            smp=${BASH_REMATCH[1]}
-        elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
-            opts=${BASH_REMATCH[1]}
-        elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
-            groups=${BASH_REMATCH[1]}
-        elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
-            arch=${BASH_REMATCH[1]}
-        elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
-            check=${BASH_REMATCH[1]}
-        fi
-    done
-
-    run "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
-
-    exec {config_fd}<&-
-}
-
 function usage()
 {
 cat <<EOF
@@ -139,4 +97,4 @@ while getopts "g:hv" opt; do
     esac
 done
 
-run_all $config
+for_each_unittest $config run
diff --git a/scripts/functions.bash b/scripts/functions.bash
new file mode 100644
index 0000000000000..7ed5a517250bc
--- /dev/null
+++ b/scripts/functions.bash
@@ -0,0 +1,42 @@
+
+function for_each_unittest()
+{
+	local unittests="$1"
+	local cmd="$2"
+	local testname
+	local smp
+	local kernel
+	local opts
+	local groups
+	local arch
+	local check
+
+	exec {fd}<"$unittests"
+
+	while read -u $fd line; do
+		if [[ "$line" =~ ^\[(.*)\]$ ]]; then
+			"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
+			testname=${BASH_REMATCH[1]}
+			smp=1
+			kernel=""
+			opts=""
+			groups=""
+			arch=""
+			check=""
+		elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
+			kernel=$TEST_DIR/${BASH_REMATCH[1]}
+		elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
+			smp=${BASH_REMATCH[1]}
+		elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
+			opts=${BASH_REMATCH[1]}
+		elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
+			groups=${BASH_REMATCH[1]}
+		elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
+			arch=${BASH_REMATCH[1]}
+		elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
+			check=${BASH_REMATCH[1]}
+		fi
+	done
+	"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
+	exec {fd}<&-
+}
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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