scripts: add test runner filter
PATCH 1/1 scripts: add test runner filter
From: Peter Feiner <[email protected]>
Add -t <name> option to run_tests.sh. Only test with the given name is run. It's an error if there's no matching test.
Signed-off-by Peter Feiner <[email protected]>
Signed-off-by David Matlack <[email protected]>
--- run_tests.sh | 6 +++++- scripts/common.bash | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-)
run_tests.sh +5 -1
@@ -16,6 +16,7 @@ cat <<EOF Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] + -t: Only execute this test -h: Output this help text -v: Enables verbose mode -a: Run all tests, including those flagged as 'nodefault'
@@ -31,10 +32,13 @@ EOF RUNTIME_arch_run="./$TEST_DIR/run" source scripts/runtime.bash -while getopts "ag:hj:v" opt; do +while getopts "t:ag:hj:v" opt; do case $opt in a) run_all_tests="yes" + ;; + t) + only_test=$OPTARG ;; g) only_group=$OPTARG
scripts/common.bash +17 -2
@@ -12,12 +12,16 @@ function for_each_unittest() local check local accel local timeout + local found=0 exec {fd}<"$unittests" while read -u $fd line; do if [[ "$line" =~ ^\[(.*)\]$ ]]; then - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + if [[ -z "$only_test" || "$testname" == "$only_test" ]]; then + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + found=$((found + 1)) + fi testname=${BASH_REMATCH[1]} smp=1 kernel=""
@@ -45,6 +49,17 @@ function for_each_unittest() timeout=${BASH_REMATCH[1]} fi done - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + if [[ -z "$only_test" || "$testname" == "$only_test" ]]; then + "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + found=$((found + 1)) + fi + exec {fd}<&- + + if [[ $found -eq 0 ]]; then + echo "Didn't run any tests." + return 1 + fi + + echo "Ran $found test(s)." }
Signature · 1 line
2.12.2.816.g2cccc81164-goog