The kselftest runner currently uses `cd -` to restore its working directory after running a test.
This is not supported by the minimal BusyBox hush shell used by some NOMMU targets. Store the original directory explicitly and restore it with a quoted path instead. This also avoids printing the directory change performed by `cd -` and handles paths containing whitespace correctly. Cc: Shuah Khan <[email protected]> Cc: Kees Cook <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Will Drewry <[email protected]> Cc: Mark Brown <[email protected]> Cc: Brendan Jackman <[email protected]> Cc: Hangbin Liu <[email protected]> Cc: "Ricardo B. Marliere" <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Hajime Tazaki <[email protected]> --- tools/testing/selftests/kselftest/runner.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 311811dc55a0..8fc1018d6fec 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -130,6 +130,7 @@ run_one() return $KSFT_FAIL fi fi + OLDDIR=$(pwd) cd `dirname $TEST` > /dev/null (((( tap_timeout "$cmd" 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) | @@ -147,7 +148,7 @@ run_one() *) ktap_test_fail "$TEST_HDR_MSG # exit=$rc";; esac - cd - >/dev/null + cd "$OLDDIR" >/dev/null fi return $rc -- 2.43.0
