If settings files are present in upper directories of a test directory, load those first before the local settings. This allows a top-level directory to define settings for subdirectories while still allowing the subdirectories to override them on a per-directory basis.
Signed-off-by: Kees Cook keescook@chromium.org --- Note that this depends on Matt's patch: https://lore.kernel.org/lkml/20191022171223.27934-1-matthieu.baerts@tessares... --- tools/testing/selftests/kselftest/runner.sh | 30 +++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 84de7bc74f2c..666cfeaa8046 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -39,6 +39,27 @@ tap_timeout() fi }
+load_settings() +{ + local fullpath="$1" + local upperpath=${fullpath%/*} + + # Load upper path settings first. + if [ "$fullpath" != "$upperpath" ] ; then + load_settings "$upperpath" + fi + + # Load per-test-directory kselftest "settings" file. + local settings="$BASE_DIR/$fullpath/settings" + if [ -r "$settings" ] ; then + while read line ; do + local field=$(echo "$line" | cut -d= -f1) + local value=$(echo "$line" | cut -d= -f2-) + eval "kselftest_$field"="$value" + done < "$settings" + fi +} + run_one() { DIR="$1" @@ -50,14 +71,7 @@ run_one() # Reset any "settings"-file variables. export kselftest_timeout="$kselftest_default_timeout" # Load per-test-directory kselftest "settings" file. - settings="$BASE_DIR/$DIR/settings" - if [ -r "$settings" ] ; then - while read line ; do - field=$(echo "$line" | cut -d= -f1) - value=$(echo "$line" | cut -d= -f2-) - eval "kselftest_$field"="$value" - done < "$settings" - fi + load_settings "$DIR"
TEST_HDR_MSG="selftests: $DIR: $BASENAME_TEST" echo "# $TEST_HDR_MSG"
linux-kselftest-mirror@lists.linaro.org