[kvm-unit-tests PATCH v1 2/2] run_tests: fix command line options handling

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

 



When specifying desired tests on the command line, options are ignored
unless specified prior to any desired tests.
E.g.

  $ ./run_tests.sh sthyi -t emulator -j5
  PASS emulator (102 tests)
  PASS sthyi (19 tests)

Note that the output is not in TAP13 format, and the tests are not executed
in parallel.
This patch fixes the issue by switching to getopt instead. Might not be the
optimum solution, but threw in long command line opts as a bonus.

Signed-off-by: Stefan Raspl <raspl@xxxxxxxxxxxxx>
---
 run_tests.sh | 45 +++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/run_tests.sh b/run_tests.sh
index 7ae37e0..a0555ce 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -17,13 +17,13 @@ cat <<EOF
 
 Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] [-t]
 
-    -h: Output this help text
-    -v: Enables verbose mode
-    -a: Run all tests, including those flagged as 'nodefault'
-        and those guarded by errata.
-    -g: Only execute tests in the given group
-    -j: Execute tests in parallel
-    -t: Output test results in TAP format
+    -h, --help      Output this help text
+    -v, --verbose   Enables verbose mode
+    -a, --all       Run all tests, including those flagged as 'nodefault'
+                    and those guarded by errata.
+    -g, --group     Only execute tests in the given group
+    -j, --parallel  Execute tests in parallel
+    -t, --tap13     Output test results in TAP format
 
 Set the environment variable QEMU=/path/to/qemu-system-ARCH to
 specify the appropriate qemu binary for ARCH-run.
@@ -34,36 +34,45 @@ EOF
 RUNTIME_arch_run="./$TEST_DIR/run"
 source scripts/runtime.bash
 
-while getopts "ag:htj:v" opt; do
-    case $opt in
-        a)
+only_tests=""
+args=`getopt -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*`
+[ $? -ne 0 ] && exit 2;
+set -- $args;
+while [ $# -gt 0 ]; do
+    case "$1" in
+        -a | --all)
             run_all_tests="yes"
             export ERRATA_FORCE=y
             ;;
-        g)
-            only_group=$OPTARG
+        -g | --group)
+            shift
+            only_group=$1
             ;;
-        h)
+        -h | --help)
             usage
             exit
             ;;
-        j)
-            unittest_run_queues=$OPTARG
+        -j | --parallel)
+            shift
+            unittest_run_queues=$1
             if (( $unittest_run_queues <= 0 )); then
                 echo "Invalid -j option: $unittest_run_queues"
                 exit 2
             fi
             ;;
-        v)
+        -v | --verbose)
             verbose="yes"
             ;;
-        t)
+        -t | --tap13)
             tap_output="yes"
             ;;
+        --)
+            ;;
         *)
-            exit 2
+            only_tests="$only_tests $1"
             ;;
     esac
+    shift
 done
 
 # RUNTIME_log_file will be configured later
-- 
2.16.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