tests: avoid false failure when O_DIRECT isn't supported

* tests/dd/nocache_eof.sh: Only run the O_DIRECT tests
when 512 byte alignment is supported.  Otherwise with older
XFS on systems with > 1MiB pages, or on file systems not
supporting O_DIRECT, there would have been false failures.
* tests/dd/direct.sh: Clarify the skip message.
This commit is contained in:
Pádraig Brady
2017-10-24 19:54:16 -07:00
parent de15a497d1
commit e818f19cf8
2 changed files with 10 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ print_ver_ dd
truncate -s 8192 in || framework_failure_
dd if=in oflag=direct of=out 2> /dev/null \
|| skip_ 'this file system lacks support for O_DIRECT'
|| skip_ '512 byte aligned O_DIRECT is not supported on this (file) system'
truncate -s 511 short || framework_failure_
truncate -s 8191 m1 || framework_failure_

View File

@@ -41,12 +41,6 @@ advised_to_eof() {
# The commented fadvise64 calls are what are expected with
# a 4KiB page size and 128KiB IO_BUFSIZE.
strace_dd if=in.f of=out.f bs=1M oflag=direct
#The first call is redundant but inconsequential
#fadvise64(1, 1048576, 0, POSIX_FADV_DONTNEED) = 0
#fadvise64(1, 1048576, 0, POSIX_FADV_DONTNEED) = 0
advised_to_eof || fail=1
strace_dd if=in.f of=out.f bs=1M oflag=nocache,sync
#fadvise64(1, 0, 1048576, POSIX_FADV_DONTNEED) = 0
#fadvise64(1, 1048576, 131072, POSIX_FADV_DONTNEED) = 0
@@ -84,15 +78,20 @@ advised_to_eof || fail=1
# Ensure sub page size offsets are handled.
# I.e., only page aligned offsets are sent to fadvise.
if ! strace -o dd.strace -e fadvise64 dd status=none \
if=in.f of=out.f bs=1M oflag=direct seek=512 oflag=seek_bytes 2>err; then
# older XFS had a page size alignment requirement
echo "dd: error writing 'out.f': Invalid argument" > err_ok
compare err_ok err || fail=1
if=in.f of=out.f bs=1M oflag=direct seek=512 oflag=seek_bytes; then
warn_ '512 byte aligned O_DIRECT is not supported on this (file) system'
# The current file system may not support O_DIRECT,
# or older XFS had a page size alignment requirement
else
#The first call is redundant but inconsequential
#fadvise64(1, 1048576, 0, POSIX_FADV_DONTNEED) = 0
#fadvise64(1, 1048576, 0, POSIX_FADV_DONTNEED) = 0
advised_to_eof || fail=1
strace_dd if=in.f of=out.f bs=1M oflag=direct
#fadvise64(1, 1048576, 0, POSIX_FADV_DONTNEED) = 0
#fadvise64(1, 1048576, 0, POSIX_FADV_DONTNEED) = 0
advised_to_eof || fail=1
fi
Exit $fail