From ab045bf3bc45fc995a00edf233ab18bb580834f1 Mon Sep 17 00:00:00 2001 From: Gerard Louis Recinto Date: Mon, 19 Oct 2026 18:57:02 -0700 Subject: [PATCH] fix flaky seed write in the hashmap scenarios test Direct I/O rejects unaligned buffers with EINVAL, so the seed write failed whenever the allocator returned an unaligned slice. Seed with a plain file write. --- fs/hashmap_scenarios_test.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/hashmap_scenarios_test.go b/fs/hashmap_scenarios_test.go index 34328415e..ca712646e 100644 --- a/fs/hashmap_scenarios_test.go +++ b/fs/hashmap_scenarios_test.go @@ -274,17 +274,13 @@ func TestHashmap_AllScenarios(t *testing.T) { // --- Scenario: write error in updateFileBlockRegion (err != nil branch) --- // Covered separately from partial write above which exercises (err == nil && n != blockSize). - dioWriteErr := newFileDirectIO() segFileWE := filepath.Join(base, "writeerr-seg.reg") - if err := dioWriteErr.open(ctx, segFileWE, os.O_CREATE|os.O_RDWR, permission); err != nil { - t.Fatalf("open seg: %v", err) + // Seed a full block so read succeeds (avoids partial read branch). A plain + // file write is used because direct I/O rejects unaligned buffers with + // EINVAL, and Go does not align a make([]byte) allocation. + if err := os.WriteFile(segFileWE, make([]byte, blockSize), permission); err != nil { + t.Fatalf("seed full block: %v", err) } - // Seed a full block so read succeeds (avoids partial read branch). - seed := make([]byte, blockSize) - if n, err := dioWriteErr.file.WriteAt(seed, 0); err != nil || n != blockSize { - t.Fatalf("seed full block: n=%d err=%v", n, err) - } - dioWriteErr.file.Close() dioRO := newFileDirectIO() if err := dioRO.open(ctx, segFileWE, os.O_RDONLY, permission); err != nil { t.Fatalf("ro open: %v", err)