]> Sergey Matveev's repositories - public-inbox.git/blob - t/epoll.t
syscall: support Linux x32 ABI
[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_deeply(\@events, [ [ fileno($w), EPOLLOUT ] ], 'got expected events');
17 close $w;
18 is(epoll_wait($epfd, 100, 0, \@events), 0, 'epoll_wait timeout');
19
20 done_testing;