From: Omar Sandoval Date: Tue, 26 Jun 2018 20:07:43 +0000 (-0700) Subject: check: allow setting config options as environment variables X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fa3196a54f18fd33a5ea4c6959ccb8f8e5945df8;p=users%2Fsagi%2Fblktests.git check: allow setting config options as environment variables Closes #25. Signed-off-by: Omar Sandoval --- diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md index 21235dd..8f32af3 100644 --- a/Documentation/running-tests.md +++ b/Documentation/running-tests.md @@ -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 fd9f09c..06b65b5 100755 --- 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')