On 27/11/2026 02:25, Collin Funk wrote:
It would be good to add a test case for 'sync' and 'truncate', but it
isn't as simple as 'csplit'. I guess maybe using 'strace' to inject a
sync(2) or ftruncate(2) failure, respectively?
truncate is easy enough.
You can squash in the attached.

Otherwise LGTM.

cheers,
Padraig
diff --git a/tests/truncate/truncate-fail-diag.sh b/tests/truncate/truncate-fail-diag.sh
index 7907adc25..2b1dc30f3 100755
--- a/tests/truncate/truncate-fail-diag.sh
+++ b/tests/truncate/truncate-fail-diag.sh
@@ -23,6 +23,7 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ truncate
 skip_if_root_
+getlimits_
 
 
 d1=no
@@ -40,4 +41,10 @@ truncate -s0 $dir > out 2>&1 && fail=1
 #truncate: cannot open '$dir' for writing: Not a directory
 #truncate: cannot open '$dir' for writing: Is a directory
 
+# Up to and including v9.12, with stderr closed, a diagnostic
+# would overwrite the file.
+echo x > exp && cp exp file || framework_failure_
+returns_ 1 truncate -s+"$OFF_T_MAX" file 2>&- || fail=1
+compare exp file || fail=1
+
 Exit $fail

Reply via email to