| ... | @@ -11,6 +11,25 @@ const elf = std.elf; | ... | @@ -11,6 +11,25 @@ const elf = std.elf; |
| 11 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const fs = std.fs; | 12 | const fs = std.fs; |
| 13 | | 13 | |
| | 14 | test "fallocate" { |
| | 15 | const path = "test_fallocate"; |
| | 16 | const file = try fs.cwd().createFile(path, .{ .truncate = true, .mode = 0o666 }); |
| | 17 | defer file.close(); |
| | 18 | defer fs.cwd().deleteFile(path) catch {}; |
| | 19 | |
| | 20 | expect((try file.stat()).size == 0); |
| | 21 | |
| | 22 | const len: u64 = 65536; |
| | 23 | switch (linux.getErrno(linux.fallocate(file.handle, 0, 0, len))) { |
| | 24 | 0 => {}, |
| | 25 | linux.ENOSYS => return error.SkipZigTest, |
| | 26 | linux.EOPNOTSUPP => return error.SkipZigTest, |
| | 27 | else => unreachable, |
| | 28 | } |
| | 29 | |
| | 30 | expect((try file.stat()).size == len); |
| | 31 | } |
| | 32 | |
| 14 | test "getpid" { | 33 | test "getpid" { |
| 15 | expect(linux.getpid() != 0); | 34 | expect(linux.getpid() != 0); |
| 16 | } | 35 | } |