public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob 56ade672a902989c6ad861a875b616dcfc2bef80 633 bytes (raw)
$ git show v1.3.0:t/epoll.t	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
 
use strict;
use Test::More;
use IO::Handle;
use PublicInbox::Syscall qw(:epoll);
plan skip_all => 'not Linux' if $^O ne 'linux';
my $epfd = epoll_create();
ok($epfd >= 0, 'epoll_create');
my $hnd = IO::Handle->new_from_fd($epfd, 'r+'); # close on exit

pipe(my ($r, $w)) or die "pipe: $!";
is(epoll_ctl($epfd, EPOLL_CTL_ADD, fileno($w), EPOLLOUT), 0,
    'epoll_ctl socket EPOLLOUT');

my @events;
is(epoll_wait($epfd, 100, 10000, \@events), 1, 'epoll_wait returns');
is_deeply(\@events, [ [ fileno($w), EPOLLOUT ] ], 'got expected events');
close $w;
is(epoll_wait($epfd, 100, 0, \@events), 0, 'epoll_wait timeout');

done_testing;

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git