[PATCH] testsuite: fix out-of-tree make check with broken shell echo
Karl Mehltretter via busybox <[email protected]> Sun, 24 May 2026 19:30:31 +0200
| Newsgroups | gmane.linux.busybox |
|---|---|
| Message-ID | <[email protected]> |
make check copies testsuite/ to objtree and runs runtest there with srcdir pointing at the source testsuite. If /bin/sh echo does not support -ne, testing.sh builds the echo-ne helper. This used ../scripts/echo.c, which exists for in-tree manual tests but not in the copied out-of-tree testsuite, causing: cc1: fatal error: ../scripts/echo.c: No such file or directory Use srcdir to find scripts/echo.c when available, and pass HOSTCC from make check for building the host-side helper. Keep gcc as the fallback for manual tests. Signed-off-by: Karl Mehltretter <[email protected]> --- Makefile.custom | 2 +- testsuite/testing.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile.custom b/Makefile.custom index 6f679c4e1..12dfa1561 100644 --- a/Makefile.custom +++ b/Makefile.custom @@ -71,7 +71,7 @@ endif check test: busybox busybox.links $(UNIT_CMD) test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree) - bindir=$(objtree) srcdir=$(srctree)/testsuite \ + bindir=$(objtree) srcdir=$(srctree)/testsuite HOSTCC="$(HOSTCC)" \ $(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)" .PHONY: release diff --git a/testsuite/testing.sh b/testsuite/testing.sh index 95bb46dda..83d18017b 100644 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh @@ -44,7 +44,11 @@ test x"$ECHO" != x"" || { # Compile and use a replacement 'echo' which understands -e -n ECHO="$PWD/echo-ne" test -x "$ECHO" || { - gcc -Os -o "$ECHO" ../scripts/echo.c || exit 1 + echo_src=../scripts/echo.c + if test x"$srcdir" != x"" && test -f "$srcdir/../scripts/echo.c"; then + echo_src="$srcdir/../scripts/echo.c" + fi + ${HOSTCC:-gcc} -Os -o "$ECHO" "$echo_src" || exit 1 } } export ECHO -- 2.39.5 (Apple Git-154)