On 22/02/19 15:38, Stefan Raspl wrote: > 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 | 47 +++++++++++++++++++++++++++-------------------- > 1 file changed, 27 insertions(+), 20 deletions(-) > > diff --git a/run_tests.sh b/run_tests.sh > index 01acc38..bb13fbf 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,39 +34,46 @@ 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 > -shift $((OPTIND - 1)) > -only_tests="$*" > > # RUNTIME_log_file will be configured later > RUNTIME_log_stderr () { cat >> $RUNTIME_log_file; } > Pushed, thanks. Paolo