From bb0b256764bf8ec196aa18adce8cd1f578c090e8 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 20 Jun 2022 19:24:38 -0700 Subject: [PATCH] Fix truncate.test for macOS. Specifically we were ending up with 2048 blocks allocated, and that -- not the stat(1) behavior -- was the reason why this test was failing on macOS. --- tests/truncate.test | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/truncate.test b/tests/truncate.test index 253af626..2bb08280 100755 --- a/tests/truncate.test +++ b/tests/truncate.test @@ -9,7 +9,10 @@ testing "0" "truncate -s 0 freep $SIZE" "0\n" "" "" testing "12345" "truncate -s 12345 freep $SIZE" "12345\n" "" "" testing "1m" "truncate -s 1m freep $SIZE" "1048576\n" "" "" # We can't test against 0 because Android filesystems use an extra 4KiB for -# extended attributes (SELinux). +# extended attributes (SELinux). We recreate the file because macOS behavior +# is a bit weird; for some file sizes (12345, in this example) blocks will +# have been allocated that aren't deallocated by the 1g extension. +rm freep; touch freep testing "is sparse" "truncate -s 1g freep && [ $(stat -c %b freep) -le 8 ] && echo okay" \ "okay\n" "" "" -- 2.39.2