t5351: avoid relying on `core.fsyncMethod = batch` to be supported

On FreeBSD, this mode is not supported. But since 3a251bac0d1a (trace2: only include "fsync" events if we git_fsync(), 2022-07-18) t5351 will fail if this mode is unsupported. Let's address this in the minimal fashion, by detecting that that mode is unsupported and expecting a different count of hardware flushes in that case. This fixes the CI/PR builds on FreeBSD again. Note: A better way would be to test only what is relevant in t5351.6 "unpack big object in stream (core.fsyncmethod=batch)" again instead of blindly comparing the output against some exact text. But that would pretty much revert the idea of above-mentioned commit, and that commit was _just_ accepted into Git's main branch so one must assume that it was intentional. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 29, 2022 at 12:28 UTC ce50f1f3ac9c2e053b1b4644587be8ef1f69af88
2 files changed +10 -2
bulk-checkin.c
+2
@@ -340,6 +340,8 @@ void fsync_loose_object_bulk_checkin(int fd, const char *filename)
340 */
341 if (!bulk_fsync_objdir ||
342 git_fsync(fd, FSYNC_WRITEOUT_ONLY) < 0) {
343 + if (errno == ENOSYS)
344 + warning(_("core.fsyncMethod = batch is unsupported on this platform"));
345 fsync_or_die(fd, filename);
346 }
347 }
t/t5351-unpack-large-objects.sh
+8 -2
@@ -70,9 +70,15 @@ test_expect_success 'unpack big object in stream (core.fsyncmethod=batch)' '
70 GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
71 GIT_TEST_FSYNC=true \
72 git -C dest.git $BATCH_CONFIGURATION unpack-objects <pack-$PACK.pack &&
73 - check_fsync_events trace2.txt <<-\EOF &&
73 + if grep "core.fsyncMethod = batch is unsupported" trace2.txt
74 + then
75 + flush_count=7
76 + else
77 + flush_count=1
78 + fi &&
79 + check_fsync_events trace2.txt <<-EOF &&
80 "key":"fsync/writeout-only","value":"6"
75 - "key":"fsync/hardware-flush","value":"1"
81 + "key":"fsync/hardware-flush","value":"$flush_count"
82 EOF
83
84 test_dir_is_empty dest.git/objects/pack &&