Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/run_kselftest.sh: Use readlink if realpath is not available

'realpath' is not always available, fallback to 'readlink -f' if is not
available. They seem to work equally well in this context.

Link: https://lore.kernel.org/r/20250318160510.3441646-1-yosry.ahmed@linux.dev
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Yosry Ahmed and committed by
Shuah Khan
1107dc4c 1efe2022

+8 -1
+8 -1
tools/testing/selftests/run_kselftest.sh
··· 3 3 # 4 4 # Run installed kselftest tests. 5 5 # 6 - BASE_DIR=$(realpath $(dirname $0)) 6 + 7 + # Fallback to readlink if realpath is not available 8 + if which realpath > /dev/null; then 9 + BASE_DIR=$(realpath $(dirname $0)) 10 + else 11 + BASE_DIR=$(readlink -f $(dirname $0)) 12 + fi 13 + 7 14 cd $BASE_DIR 8 15 TESTS="$BASE_DIR"/kselftest-list.txt 9 16 if [ ! -r "$TESTS" ] ; then