]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: normalize boolean configuration in environment variables
authorThomas Haller <thaller@redhat.com>
Wed, 6 Sep 2023 11:52:08 +0000 (13:52 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 7 Sep 2023 17:35:20 +0000 (19:35 +0200)
Previously, we would honor "y" as opt-in, and all other values meant
false.

- accept alternatives to "y", like "1" or "true".

- normalize the value, to either be "y" or "n".

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

index 65aa041febb2f6f7ab0a4910a2493899bccca9d3..905fa0c10309627d7743165d4a1a80516fdc0001 100755 (executable)
@@ -13,6 +13,17 @@ msg_info() {
        echo "I: $1"
 }
 
+bool_y() {
+       case "$1" in
+               y|Y|yes|Yes|YES|1|true|True|TRUE)
+                       printf y
+                       ;;
+               *)
+                       printf n
+                       ;;
+       esac
+}
+
 usage() {
        echo " $0 [OPTIONS] [TESTS...]"
        echo
@@ -57,10 +68,10 @@ if [ "${1}" != "run" ]; then
 fi
 shift
 
-VERBOSE="$VERBOSE"
-DUMPGEN="$DUMPGEN"
-VALGRIND="$VALGRIND"
-KMEMLEAK="$KMEMLEAK"
+VERBOSE="$(bool_y "$VERBOSE")"
+DUMPGEN="$(bool_y "$DUMPGEN")"
+VALGRIND="$(bool_y "$VALGRIND")"
+KMEMLEAK="$(bool_y "$KMEMLEAK")"
 DO_LIST_TESTS=
 
 TESTS=()