public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob ab9ac22ac2661092604196f52b722e59d8e4eca5 637 bytes (raw)
$ git show HEAD: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
21
22
 
#!perl -w
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use v5.12;
use Test::More;
use autodie;
use PublicInbox::Syscall qw(EPOLLOUT);
plan skip_all => 'not Linux' if $^O ne 'linux';
require_ok 'PublicInbox::Epoll';
my $ep = PublicInbox::Epoll->new;
pipe(my $r, my $w);
is($ep->ep_add($w, EPOLLOUT), 0, 'epoll_ctl pipe EPOLLOUT');

my @events;
$ep->ep_wait(10000, \@events);
is(scalar(@events), 1, 'got one event');
is($events[0], fileno($w), 'got expected FD');
close $w;
$ep->ep_wait(0, \@events);
is(scalar(@events), 0, 'epoll_wait timeout');

done_testing;

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