Skip to content

Commit 710632b

Browse files
rootbeeralexrp
authored andcommitted
lib/std/fs/test.zig: Some filesystems support 8 EiB files
Btrfs at least supports 16 EiB files (limited in practice to 8EiB by the Linux VFS code which uses signed 64-bit offsets). So fix the fs.zig test case to expect either a FileTooBig or success from truncating a file to 8EiB. And test that beyond that size the offset is interpreted as a negative number. Fixes #24242
1 parent 640a130 commit 710632b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/std/fs/test.zig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,14 +1435,17 @@ test "setEndPos" {
14351435
try testing.expectEqual(0, try f.preadAll(&buffer, 0));
14361436

14371437
// Invalid file length should error gracefully. Actual limit is host
1438-
// and file-system dependent, but 1PB should fail most everywhere.
1439-
// Except MacOS APFS limit is 8 exabytes.
1438+
// and file-system dependent, but 1PB should fail on filesystems like
1439+
// EXT4 and NTFS. But XFS or Btrfs support up to 8EiB files.
14401440
f.setEndPos(0x4_0000_0000_0000) catch |err| if (err != error.FileTooBig) {
14411441
return err;
14421442
};
14431443

1444-
try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u63))); // Maximum signed value
1444+
f.setEndPos(std.math.maxInt(u63)) catch |err| if (err != error.FileTooBig) {
1445+
return err;
1446+
};
14451447

1448+
try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u63) + 1));
14461449
try testing.expectError(error.FileTooBig, f.setEndPos(std.math.maxInt(u64)));
14471450
}
14481451

0 commit comments

Comments
 (0)