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

selftests: find echo binary to use -ne options

Find the actual echo binary using $(which echo) and use it for
formatted output with -ne. On some systems, the default echo command
doesn't handle the -e option and the output looks like this (arm64
build):

-ne Emit Tests for alsa

-ne Emit Tests for amd-pstate

-ne Emit Tests for arm64

This is for example the case with the KernelCI Docker images
e.g. kernelci/gcc-10:x86-kselftest-kernelci. With the actual echo
binary (e.g. in /bin/echo), the output is formatted as expected (x86
build this time):

Emit Tests for alsa
Emit Tests for amd-pstate
Skipping non-existent dir: arm64

Only the install target is using "echo -ne" so keep the $ECHO variable
local to it.

Reported-by: "kernelci.org bot" <bot@kernelci.org>
Fixes: 3297a4df805d ("kselftests: Enable the echo command to print newlines in Makefile")
Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Guillaume Tucker and committed by
Shuah Khan
4ebe3339 4b225d4f

+3 -2
+3 -2
tools/testing/selftests/Makefile
··· 234 234 @# While building kselftest-list.text skip also non-existent TARGET dirs: 235 235 @# they could be the result of a build failure and should NOT be 236 236 @# included in the generated runlist. 237 + ECHO=`which echo`; \ 237 238 for TARGET in $(TARGETS); do \ 238 239 BUILD_TARGET=$$BUILD/$$TARGET; \ 239 - [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \ 240 - echo -ne "Emit Tests for $$TARGET\n"; \ 240 + [ ! -d $(INSTALL_PATH)/$$TARGET ] && $$ECHO "Skipping non-existent dir: $$TARGET" && continue; \ 241 + $$ECHO -ne "Emit Tests for $$TARGET\n"; \ 241 242 $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ 242 243 -C $$TARGET emit_tests >> $(TEST_LIST); \ 243 244 done;