[kvm-unit-tests PATCH v2] 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.
The changes below are to share the fix for the kvm unit test framework.

Changes v2:
  - Update usage message for the -a option
  - Remove skip_nodefaul call for the exclude_groups and exclude_tests
    check
  - Update skip output message: "(test group is excluded by -e)" and
    "(test is excluded by -x)"

Add to custom options to exclude tests or 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         | 15 ++++++++++++---
 scripts/runtime.bash | 10 ++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/run_tests.sh b/run_tests.sh
index aa2e65f..fe3e88e 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -14,14 +14,17 @@ 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
     -a: Run all tests, including those flagged as 'nodefault'
-        and those guarded by errata.
+        and those guarded by errata. Test or group will be
+        skipped, if it is excluded manually using -e or -x option
     -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 +35,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 +44,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..5de4552 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -76,6 +76,16 @@ function run()
         return;
     fi
 
+    if [ -n "$exclude_groups" ] && grep -qw "$groups" <<<$exclude_groups; then
+        echo -e "`SKIP` $testname (test group is excluded by -e)"
+        return;
+    fi
+
+    if [ -n "$exclude_tests" ] && grep -qw "$testname" <<<$exclude_tests; then
+        echo -e "`SKIP` $testname (test is excluded by -x)"
+        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