zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit a67f140d2f1247d3996f763dd36e55cbecb09eef (tree)
parent 2dd8613adcac695468937156f6e13dc5a4828e4c
Author: Joran Dirk Greef <joran@ronomon.com>
Date:   Sun,  1 Nov 2020 11:55:27 +0200

Add test

Diffstat:
Mlib/std/os/linux/test.zig | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig @@ -11,6 +11,25 @@ const elf = std.elf; const expect = std.testing.expect; const fs = std.fs; +test "fallocate" { + const path = "test_fallocate"; + const file = try fs.cwd().createFile(path, .{ .truncate = true, .mode = 0o666 }); + defer file.close(); + defer fs.cwd().deleteFile(path) catch {}; + + expect((try file.stat()).size == 0); + + const len: u64 = 65536; + switch (linux.getErrno(linux.fallocate(file.handle, 0, 0, len))) { + 0 => {}, + linux.ENOSYS => return error.SkipZigTest, + linux.EOPNOTSUPP => return error.SkipZigTest, + else => unreachable, + } + + expect((try file.stat()).size == len); +} + test "getpid" { expect(linux.getpid() != 0); }