From 908fd659ac22d6c367123b157f98990164a0b938 Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Wed, 21 Oct 2026 09:38:47 +0200 Subject: [PATCH 1/2] gen-test-helper.sh: get utility names from --list run-tests.sh runs the util-linux test suite on the utilities listed by gen-test-helper.sh, which derived them from the directory names under src/uu/. That assumes every crate directory is a utility built into the binary and that each utility is named after its directory. Neither holds in general: a build may enable only some features, and a crate can provide several utility names (e.g. setarch and its i386/linux32/... aliases), as noted in the review of #517. Use the multicall binary's new --list flag instead, so the list matches what was actually built. run-tests.sh already builds the binary before calling gen-test-helper.sh; fail with a clear message if it's missing. For the current tree, the resulting utility list is unchanged. --- scripts/gen-test-helper.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/gen-test-helper.sh b/scripts/gen-test-helper.sh index dd98578e..761a67c5 100755 --- a/scripts/gen-test-helper.sh +++ b/scripts/gen-test-helper.sh @@ -24,9 +24,17 @@ ours_tmp=$(mktemp) gnu_tmp=$(mktemp) trap 'rm -f "$ours_tmp" "$gnu_tmp"' EXIT -for d in "$PROJECT_DIR/src/uu/"*/; do - basename "$d" -done | sort > "$ours_tmp" +if [[ ! -x "$BINARY" ]]; then + echo "ERROR: $BINARY not found." >&2 + echo " Run 'cargo build --release' first." >&2 + exit 2 +fi + +# Ask the binary which utilities it provides instead of listing src/uu/: +# this only includes utilities enabled by the build's features, and a +# utility name need not match its crate directory (e.g. setarch's +# i386/linux32/... aliases). +"$BINARY" --list | sort > "$ours_tmp" for d in "$GNU_TS_DIR/"*/; do basename "$d" From c771b20f4f819298fe2287ea67b895037485896f Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Wed, 21 Oct 2026 15:56:40 +0200 Subject: [PATCH 2/2] gen-test-helper.sh: remove existing entries before writing `cat > .test-helpers/` opens the existing path for writing. If that path is a symlink or hard link to target/release/util-linux, e.g. left over from experimenting with linking the multicall binary instead of generating wrappers, the wrapper script is written into the release binary itself (and into its hard-linked copy under target/release/deps). The binary then becomes a script that execs itself, so every GNU test run by run-tests.sh breaks, since run-tests.sh builds before calling this script. Only the next cargo build repairs it. Remove each entry before writing it, so a fresh file is always created. --- scripts/gen-test-helper.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/gen-test-helper.sh b/scripts/gen-test-helper.sh index 761a67c5..60d97adb 100755 --- a/scripts/gen-test-helper.sh +++ b/scripts/gen-test-helper.sh @@ -50,6 +50,11 @@ if [[ ${#UTILS[@]} -eq 0 ]]; then fi for util in "${UTILS[@]}"; do + # Remove any existing entry first: if it is a symlink or hard link to + # the release binary (e.g. left over from linking the multicall binary + # by hand), writing through it would replace the binary with a wrapper + # that execs itself, breaking every test until the next cargo build. + rm -f ".test-helpers/$util" cat > ".test-helpers/$util" <