From 7f37d0c4e9e7290bda8b9f0ced215edcc3802752 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 26 Jul 2026 22:15:03 +0200 Subject: [PATCH] test: refuse to run against a stale sysroot binary 'make check' refreshes the sysroot through the setup-chroot rule, but running a test script by hand does not, so the test exercises whichever finit was installed last and reports on code that is no longer there. Both a passing and a failing run are then meaningless, and nothing says so. Compare the built binary against the installed one at startup and fail with the command that fixes it. Signed-off-by: Joachim Wiberg --- test/lib/setup.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/lib/setup.sh b/test/lib/setup.sh index fb3334ba..f8b077ff 100755 --- a/test/lib/setup.sh +++ b/test/lib/setup.sh @@ -309,6 +309,18 @@ trap teardown EXIT SYSROOT="${SYSROOT:-$(pwd)/${TEST_DIR}/sysroot}" export SYSROOT +# 'make check' refreshes the sysroot through the setup-chroot rule, but +# running a test script by hand does not, and then the test silently +# exercises whatever finit was installed last. Compare and refuse. +top_builddir="${top_builddir:-$TEST_DIR/..}" +sysroot_finit="$SYSROOT/sbin/finit" +built_finit="$top_builddir/src/finit" +[ -x "$top_builddir/src/.libs/finit" ] && built_finit="$top_builddir/src/.libs/finit" + +if [ -x "$built_finit" ] && [ -e "$sysroot_finit" ] && ! cmp -s "$built_finit" "$sysroot_finit"; then + fail "Stale $sysroot_finit, run 'make -C test setup-chroot' or use 'make check'" +fi + TEST_TIMEOUT=300 # shellcheck source=/dev/null