From de73a867ca989e6cf1929f511d2679aa2085c2be Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Sat, 29 Feb 2020 20:23:44 +0000 Subject: [PATCH] tests: avoid false failures on darwin 19.2.0 With these adjustments, all tests pass on macOS Catalina. * tests/dd/sparse.sh: Adjust so that systems like apfs that don't create holes < 16 MiB do not fail erroneously. * tests/touch/trailing-slash.sh: Darwin was seen to dereference symlinks to files when given a trailing slash, so avoid that particular case. --- tests/dd/sparse.sh | 11 ++++++++++- tests/touch/trailing-slash.sh | 8 ++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/dd/sparse.sh b/tests/dd/sparse.sh index 6b84aef55b..58cedf24ab 100755 --- a/tests/dd/sparse.sh +++ b/tests/dd/sparse.sh @@ -77,7 +77,16 @@ if test $(kb_alloc file.in) -gt 3000; then # Ensure that this 1MiB *output* block of NULs *is* converted to a hole. dd if=file.in of=file.out ibs=2M obs=1M conv=sparse,notrunc - test $(kb_alloc file.out) -lt 2500 || fail=1 + if test $(kb_alloc file.out) -ge 2500; then + # Double check the failure by creating a sparse file in + # the traditional manner for comparison, as we're not guaranteed + # that seek=1M will create a hole. apfs on darwin 19.2.0 for example + # was seen to not to create holes < 16MiB. + dd if=file.in of=manual.out bs=1M count=1 || fail=1 + dd if=file.in of=manual.out bs=1M count=1 seek=2 conv=notrunc || fail=1 + + test $(kb_alloc file.out) -eq $(kb_alloc manual.out) || fail=1 + fi fi diff --git a/tests/touch/trailing-slash.sh b/tests/touch/trailing-slash.sh index f87fe22cab..8f21546d0f 100755 --- a/tests/touch/trailing-slash.sh +++ b/tests/touch/trailing-slash.sh @@ -33,7 +33,9 @@ returns_ 1 touch no-file/ || fail=1 returns_ 1 touch file/ || fail=1 returns_ 1 touch dangling/ || fail=1 returns_ 1 touch loop/ || fail=1 -returns_ 1 touch link1/ || fail=1 +if returns_ 2 ls link1/; then # darwin allows trailing slash to files + returns_ 1 touch link1/ || fail=1 +fi touch dir/ || fail=1 # -c silences ENOENT, but not ENOTDIR or ELOOP @@ -41,7 +43,9 @@ touch -c no-file/ || fail=1 returns_ 1 touch -c file/ || fail=1 touch -c dangling/ || fail=1 returns_ 1 touch -c loop/ || fail=1 -returns_ 1 touch -c link1/ || fail=1 +if returns_ 2 ls link1/; then + returns_ 1 touch -c link1/ || fail=1 +fi touch -c dir/ || fail=1 returns_ 1 test -f no-file || fail=1 returns_ 1 test -f nowhere || fail=1 -- 2.47.2