Message ID | 20250318160510.3441646-1-yosry.ahmed@linux.dev (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | selftests/run_kselftest.sh: Use readlink if realpath is not available | expand |
diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh index 50e03eefe7ac7..0443beacf3621 100755 --- a/tools/testing/selftests/run_kselftest.sh +++ b/tools/testing/selftests/run_kselftest.sh @@ -3,7 +3,14 @@ # # Run installed kselftest tests. # -BASE_DIR=$(realpath $(dirname $0)) + +# Fallback to readlink if realpath is not available +if which realpath > /dev/null; then + BASE_DIR=$(realpath $(dirname $0)) +else + BASE_DIR=$(readlink -f $(dirname $0)) +fi + cd $BASE_DIR TESTS="$BASE_DIR"/kselftest-list.txt if [ ! -r "$TESTS" ] ; then
'realpath' is not always available, fallback to 'readlink -f' if is not available. They seem to work equally well in this context. Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev> --- tools/testing/selftests/run_kselftest.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)