]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid false failures with older strace
authorPádraig Brady <P@draigBrady.com>
Tue, 19 May 2026 17:45:26 +0000 (18:45 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 19 May 2026 18:06:13 +0000 (19:06 +0100)
* tests/tee/short-write.sh: Check that all the required strace
options are supported, which is not the case with strace 5.10 at least.
* tests/tee/write-eagain.sh: Likewise.

tests/tee/short-write.sh
tests/tee/write-eagain.sh

index 42709260d2316700a3096c4cfcffc56e96addd14..dde209b9dd8ea20f556d532aff2f42108c2a0a68 100755 (executable)
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ tee
-require_strace_ write
+uses_strace_
 
 printf 'abcdef' >file1-exp || framework_failure_
 printf 'f' >out-exp || framework_failure_
 
+short_write() {
+  strace -qqq -o /dev/null --trace-fds=1 -e trace=write \
+    -e inject=write:retval=1:when=1..5 "$@"
+}
+
+short_write true || skip_ No functional strace found
+
 # In coreutils-9.11, a short write would be treated as an error.
-strace -qqq -o /dev/null --trace-fds=1 -e trace=write \
-  -e inject=write:retval=1:when=1..5 tee file1 >out 2>err <file1-exp || fail=1
+# Using 'returns_ 0' to avoid tracing impinging on stderr.
+returns_ 0 short_write tee file1 >out 2>err <file1-exp || fail=1
 compare file1-exp file1 || fail=1
 compare out-exp out || fail=1
 compare /dev/null err || fail=1
index f434ee62b2a5868e62a9a53102cb30673dd41eca..b8a7167cc3a43a9511e6aeae34a55ff89d1e25eb 100755 (executable)
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ tee
-require_strace_ write
+uses_strace_
+
+write_eagain() {
+  timeout 10 strace -qqq -o /dev/null -e trace-fds=3 \
+    -e inject=write:error=EAGAIN:when=1 "$@"
+}
+
+write_eagain true || skip_ No functional strace found
 
 # In coreutils-9.11 the following test would infinite loop.
+# Using 'returns_ 0' to avoid tracing impinging on stderr.
 echo a >exp || framework_failure_
-timeout 10 strace -qqq -o /dev/null -e trace-fds=3 \
-  -e inject=write:error=EAGAIN:when=1 tee file1 <exp >out 2>err || fail=1
+returns_ 0 write_eagain tee file1 <exp >out 2>err || fail=1
 compare exp file1 || fail=1
 compare exp out || fail=1
 compare /dev/null err || fail=1