2 # Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use PublicInbox::Syscall qw(:epoll);
8 plan skip_all => 'not Linux' if $^O ne 'linux';
9 my $epfd = epoll_create();
10 ok($epfd >= 0, 'epoll_create');
11 open(my $hnd, '+<&=', $epfd); # for autoclose
13 pipe(my ($r, $w)) or die "pipe: $!";
14 is(epoll_ctl($epfd, EPOLL_CTL_ADD, fileno($w), EPOLLOUT), 0,
15 'epoll_ctl socket EPOLLOUT');
18 epoll_wait($epfd, 100, 10000, \@events);
19 is(scalar(@events), 1, 'got one event');
20 is($events[0], fileno($w), 'got expected FD');
22 epoll_wait($epfd, 100, 0, \@events);
23 is(scalar(@events), 0, 'epoll_wait timeout');