authorgravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-11-01 11:55:27+02:00
committergravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-11-01 11:55:27+02:00
loga67f140d2f1247d3996f763dd36e55cbecb09eef
tree8896a3a105ef8c3b31ee79d12e3e8ad8d78219c4
parent2dd8613adcac695468937156f6e13dc5a4828e4c

Add test


1 files changed, 19 insertions(+), 0 deletions(-)

lib/std/os/linux/test.zig+19
......@@ -11,6 +11,25 @@ const elf = std.elf;
1111const expect = std.testing.expect;
1212const fs = std.fs;
1313
14test "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
1433test "getpid" {
1534 expect(linux.getpid() != 0);
1635}