[kvm-unit-tests PATCH v1] Enhance tests with the exclude options

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

 



During custom linux kernel development it was found out that sometimes it
is really useful to exclude the tests from automatic CI step. It is not
always easy to modify the unittest.cfg file so the exclude options were
added to the test framework:
  -x: Exclude tests from running
  -e: Exclude test groups from running
As a result the command like:
  ./run_tests.sh -e "vmexit vmx"  -x "apic vmware_backdoors"
Will exclude apic and vmware_backdoors tests from running. And will
exclude vmexit and vmx groups from running. If -a option is set, then
both options will be ignored.
The changes below are to share the fix for the kvm unit test framework.

Add two custom options to exclude tests and groups from running. It can be
useful for running the tests automatically in the custom environment
without modifying the unittest.cfg file.

Signed-off-by: Dima Stepanov <dstepanov.src@xxxxxxxxx>
---
 run_tests.sh         | 12 ++++++++++--
 scripts/runtime.bash | 12 ++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/run_tests.sh b/run_tests.sh
index aa2e65f..3e109b3 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -14,7 +14,7 @@ function usage()
 {
 cat <<EOF
 
-Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS]
+Usage: $0 [-h] [-v] [-a] [-g group] [-x test] [-e group] [-j NUM-TASKS]
 
     -h: Output this help text
     -v: Enables verbose mode
@@ -22,6 +22,8 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS]
         and those guarded by errata.
     -g: Only execute tests in the given group
     -j: Execute tests in parallel
+    -x: Exclude tests from running
+    -e: Exclude test groups from running
 
 Set the environment variable QEMU=/path/to/qemu-system-ARCH to
 specify the appropriate qemu binary for ARCH-run.
@@ -32,7 +34,7 @@ EOF
 RUNTIME_arch_run="./$TEST_DIR/run"
 source scripts/runtime.bash
 
-while getopts "ag:hj:v" opt; do
+while getopts "ag:e:x:hj:v" opt; do
     case $opt in
         a)
             run_all_tests="yes"
@@ -41,6 +43,12 @@ while getopts "ag:hj:v" opt; do
         g)
             only_group=$OPTARG
             ;;
+        x)
+            exclude_tests=$OPTARG
+            ;;
+        e)
+            exclude_groups=$OPTARG
+            ;;
         h)
             usage
             exit
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index a31ae91..6a36459 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -76,6 +76,18 @@ function run()
         return;
     fi
 
+    if [ -n "$exclude_groups" ] && grep -qw "$groups" <<<$exclude_groups &&
+            skip_nodefault; then
+        echo -e "`SKIP` $testname (test group is marked as exclude -e option)"
+        return;
+    fi
+
+    if [ -n "$exclude_tests" ] && grep -qw "$testname" <<<$exclude_tests &&
+            skip_nodefault; then
+        echo -e "`SKIP` $testname (test is marked as exclude -x option)"
+        return;
+    fi
+
     if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
         echo "`SKIP` $1 ($arch only)"
         return 2
-- 
2.7.4



[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