]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
check: allow setting config options as environment variables
authorOmar Sandoval <osandov@fb.com>
Tue, 26 Jun 2018 20:07:43 +0000 (13:07 -0700)
committerOmar Sandoval <osandov@fb.com>
Tue, 26 Jun 2018 20:07:43 +0000 (13:07 -0700)
Closes #25.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Documentation/running-tests.md
check

index 21235dd3ce6d4f3f3d6c34c6878a35b114951944..8f32af38008e08b6b3fa630c0f6c1e9bcf0589b3 100644 (file)
@@ -20,7 +20,8 @@ will run all tests in the `loop` group and the `block/002` test.
 ## Configuration
 
 Test configuration goes in the `config` file at the top-level directory of the
-blktests repository.
+blktests repository. Test configuration options can also be set as environment
+variables instead of in the `config` file.
 
 ### Test Devices
 
@@ -33,7 +34,8 @@ TEST_DEVS=(/dev/nvme0n1 /dev/sdb)
 ```
 
 If `TEST_DEVS` is not defined or is empty, only tests which do not require a
-device will be run.
+device will be run. If `TEST_DEVS` is defined as a normal variable instead of
+an array, it will be converted to an array by splitting on whitespace.
 
 ### Excluding Tests
 
@@ -48,6 +50,9 @@ EXCLUDE=(loop block/001)
 Tests specified explicitly on the command line will always run even if they are
 in `EXCLUDE`.
 
+If `EXCLUDE` is defined as a normal variable instead of an array, it will be
+converted to an array by splitting on whitespace.
+
 ### Quick Runs and Test Timeouts
 
 Many tests can take a long time to run. By setting the `TIMEOUT` variable, you
diff --git a/check b/check
index fd9f09ca57b4b32415590e919417dc479043fbde..06b65b5092f4fdd814a49dcc4f4620735388a278 100755 (executable)
--- a/check
+++ b/check
@@ -588,17 +588,29 @@ fi
 eval set -- "$TEMP"
 unset TEMP
 
-# Default configuration.
-DEVICE_ONLY=0
-QUICK_RUN=0
-EXCLUDE=()
-TEST_DEVS=()
-
 if [[ -r config ]]; then
        # shellcheck disable=SC1091
        . config
 fi
 
+# Default configuration.
+: "${DEVICE_ONLY:=0}"
+: "${QUICK_RUN:=0}"
+if [[ -v EXCLUDE ]] && ! declare -p EXCLUDE | grep -q '^declare -a'; then
+       # If EXCLUDE was not defined as an array, convert it to one.
+       # shellcheck disable=SC2190,SC2206
+       EXCLUDE=($EXCLUDE)
+elif [[ ! -v EXCLUDE ]]; then
+       EXCLUDE=()
+fi
+if [[ -v TEST_DEVS ]] && ! declare -p TEST_DEVS | grep -q '^declare -a'; then
+       # If TEST_DEVS was not defined as an array, convert it to one.
+       # shellcheck disable=SC2206
+       TEST_DEVS=($TEST_DEVS)
+else
+       TEST_DEVS=()
+fi
+
 while true; do
        case "$1" in
                '-d'|'--device-only')