]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: check test names before start and support directories
authorThomas Haller <thaller@redhat.com>
Wed, 6 Sep 2023 11:52:06 +0000 (13:52 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 7 Sep 2023 17:35:20 +0000 (19:35 +0200)
Check for valid test names early. That's useful because we treat any
unrecognized options as test names. We should detect a mistake early.

While at it, also support specifying directory names instead of
executable files.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/run-tests.sh

index 5f526dd8f258934c4bb8c12a70f69992025c7054..34c3b324b04b808e898276a1838e03d34e355d45 100755 (executable)
@@ -109,6 +109,18 @@ if [ "${#TESTS[@]}" -eq 0 ] ; then
        test "${#TESTS[@]}" -gt 0 || msg_error "Could not find tests"
 fi
 
+TESTSOLD=( "${TESTS[@]}" )
+TESTS=()
+for t in "${TESTSOLD[@]}" ; do
+       if [ -f "$t" -a -x "$t" ] ; then
+               TESTS+=( "$t" )
+       elif [ -d "$t" ] ; then
+               TESTS+=( $(find_tests "$t") )
+       else
+               msg_error "Unknown test \"$t\""
+       fi
+done
+
 if [ "$DO_LIST_TESTS" = y ] ; then
        printf '%s\n' "${TESTS[@]}"
        exit 0