From: Collin Funk Date: Mon, 22 Jun 2026 03:45:09 +0000 (-0700) Subject: tests: dd: check that files are opened with O_TRUNC X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=57fe9ecd694459c44fa59b903d5dbb001f22ce66;p=thirdparty%2Fcoreutils.git tests: dd: check that files are opened with O_TRUNC * tests/dd/misc.sh: Add the test case. --- diff --git a/tests/dd/misc.sh b/tests/dd/misc.sh index aa776b1379..5e2eb8ed50 100755 --- a/tests/dd/misc.sh +++ b/tests/dd/misc.sh @@ -19,6 +19,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ dd +uses_strace_ export LC_ALL=C tmp_in=dd-in @@ -129,5 +130,16 @@ if test -c /dev/tty && >/dev/tty; then dd if=/dev/null of=/dev/tty || fail=1 fi +# Ensure that the output file is opened with O_TRUNC. +if strace -o /dev/null -e inject=truncate,ftruncate:error=EIO true; then + echo a > $tmp_out || framework_failure_ + strace --quiet=all -o /dev/null \ + -e inject=truncate,ftruncate:error=EIO -P $tmp_out \ + dd if=/dev/null of=$tmp_out status=none skip=1B >out 2>err || fail=1 + compare /dev/null out || fail=1 + compare /dev/null err || fail=1 + compare /dev/null $tmp_out || fail=1 +fi + Exit $fail