]> Sergey Matveev's repositories - public-inbox.git/blob - t/epoll.t
t/epoll: adjust for u64_mod_8 case
[public-inbox.git] / t / epoll.t
1 use strict;
2 use Test::More;
3 use IO::Handle;
4 use PublicInbox::Syscall qw(:epoll);
5 plan skip_all => 'not Linux' if $^O ne 'linux';
6 my $epfd = epoll_create();
7 ok($epfd >= 0, 'epoll_create');
8 my $hnd = IO::Handle->new_from_fd($epfd, 'r+'); # close on exit
9
10 pipe(my ($r, $w)) or die "pipe: $!";
11 is(epoll_ctl($epfd, EPOLL_CTL_ADD, fileno($w), EPOLLOUT), 0,
12     'epoll_ctl socket EPOLLOUT');
13
14 my @events;
15 is(epoll_wait($epfd, 100, 10000, \@events), 1, 'epoll_wait returns');
16 is(scalar(@events), 1, 'got one event');
17 is($events[0]->[0], fileno($w), 'got expected FD');
18 is($events[0]->[1], EPOLLOUT, 'got expected event');
19 close $w;
20 is(epoll_wait($epfd, 100, 0, \@events), 0, 'epoll_wait timeout');
21
22 done_testing;