selftests: Load settings from subdirs
PATCH 1/1 selftests: Load settings from subdirs
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 <[email protected]>
---
Note that this depends on Matt's patch:
https://lore.kernel.org/lkml/[email protected]
--- tools/testing/selftests/kselftest/runner.sh | 30 +++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-)
tools/testing/selftests/kselftest/runner.sh +22 -8
@@ -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"
Signature · 5 lines
2.17.1 -- Kees Cook