I followed up with the attached to fix a false failure on dash.
cheers,
Padraig
From 8587084c047f30810f6112febc0abeae541b1692 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Sat, 24 Oct 2026 14:23:35 +0100
Subject: [PATCH] tests: avoid false failure with dash
* tests/cp/link-no-deref.sh: Use printf rather than echo, as echo
unconditionally interprets backslashes in dash. Also use %q in
printf to decouple from the shell escaping implementation.
Also refactor strace usage to its own function, and avoid
a false failure in case strace didn't intercept the chown.
---
tests/cp/link-no-deref.sh | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/tests/cp/link-no-deref.sh b/tests/cp/link-no-deref.sh
index c21764355..a70955055 100755
--- a/tests/cp/link-no-deref.sh
+++ b/tests/cp/link-no-deref.sh
@@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ cp
+print_ver_ cp printf
getlimits_
uses_strace_
@@ -28,17 +28,22 @@ ln -s no-such-file dangling-slink || framework_failure_
# with link being applied to the dangling symlink.
cp --link --no-dereference dangling-slink d2 || fail=1
+fail_chown() {
+ chowns=chown,lchown,fchownat
+ eval "file=\${$#}"
+ strace --quiet=all -o fc.strace -P "$file" -e inject=$chowns:error=ENOSYS "$@"
+}
+
NL='
'
-chowns=chown,lchown,fchownat
-if strace --quiet=all -o /dev/null -P foo \
- -e inject=$chowns:error=EPERM true 2>/dev/null; then
- echo "cp: failed to preserve ownership for ''\$'\\n': $ENOSYS" >exp \
- || framework_failure_
+if fail_chown true foo; then
+ env printf '%s %q: %s\n' \
+ "cp: failed to preserve ownership for" "$NL" "$ENOSYS" >exp \
+ || framework_failure_
touch file && ln -s file slink || framework_failure_
- returns_ 1 strace --quiet=all -o /dev/null -P "$NL" \
- -e inject=$chowns:error=ENOSYS cp -P --preserve=ownership slink "$NL" \
+ returns_ 1 fail_chown cp -P --preserve=ownership slink "$NL" \
>out 2>err || fail=1
+ grep 'chown.*INJECTED' fc.strace || { cat fc.strace; framework_failure_; }
compare exp err || fail=1
compare /dev/null out || fail=1
fi
--
2.55.0