zig

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

commit cdcb746cc2c96f5e968fe95a117dfc3901bd9fb9 (tree)
parent 3e2ddbfdd7e43788de51b3166e3dbc523c6b7b88
Author: Jan Philipp Hafer <jan.hafer@rwth-aachen.de>
Date:   Thu,  8 Dec 2022 21:06:33 +0100

std.os.linux: fix timerfd test

Remove timerfd timeout and fix timerfd_settime flag.
CI tests should not rely on timings to succeed.

Closes #13721.

Diffstat:
Mlib/std/os/test.zig | 15+++++----------
1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig @@ -1054,11 +1054,6 @@ test "access smoke test" { } test "timerfd" { - if (true) { - // https://github.com/ziglang/zig/issues/13721 - return error.SkipZigTest; - } - if (native_os != .linux) return error.SkipZigTest; @@ -1066,16 +1061,16 @@ test "timerfd" { var tfd = try os.timerfd_create(linux.CLOCK.MONOTONIC, linux.TFD.CLOEXEC); defer os.close(tfd); + // Fire event 10_000_000ns = 10ms after the os.timerfd_settime call. var sit: linux.itimerspec = .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 10 * (1000 * 1000) } }; try os.timerfd_settime(tfd, 0, &sit, null); var fds: [1]os.pollfd = .{.{ .fd = tfd, .events = os.linux.POLL.IN, .revents = 0 }}; - try expectEqual(try os.poll(&fds, -1), 1); - var git = try os.timerfd_gettime(tfd); - try expectEqual(git, .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 0 } }); + try expectEqual(@as(usize, 1), try os.poll(&fds, -1)); // -1 => infinite waiting - try os.timerfd_settime(tfd, 0, &sit, null); - try expectEqual(try os.poll(&fds, 5), 0); + var git = try os.timerfd_gettime(tfd); + var expect_disarmed_timer: linux.itimerspec = .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 0 } }; + try expectEqual(expect_disarmed_timer, git); } test "isatty" {