ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/02_read.t
Revision: 1.2
Committed: Sun Jul 10 18:16:50 2005 UTC (18 years, 11 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_61, rel-1_73, rel-1_72, rel-1_71, rel-2_0, rel-2_1, rel-0_1, rel-0_2, rel-0_4, rel-0_5, rel-0_9, rel-1_8, rel-1_1, rel-1_0, rel-1_3, rel-1_2, rel-1_5, rel-1_4, rel-1_7, rel-1_6
Changes since 1.1: +4 -4 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 $| = 1;
2
3 if (-f "/etc/passwd" and -d "/etc") {
4 print "1..2\n";
5 } else {
6 print "1..0 # Skipped: unexpected /etc and/or /etc/passwd\n";
7 exit;
8 }
9
10 # relies on /etc/passwd to exist...
11
12 use Fcntl;
13 use IO::AIO;
14
15 IO::AIO::min_parallel 2;
16
17 sub pcb {
18 while (IO::AIO::nreqs) {
19 my $rfd = ""; vec ($rfd, IO::AIO::poll_fileno, 1) = 1; select $rfd, undef, undef, undef;
20 IO::AIO::poll_cb;
21 }
22 }
23
24 my $pwd;
25
26 aio_open "/etc/passwd", O_RDONLY, 0, sub {
27 print $_[0] ? "ok" : "not ok", " 1\n";
28 $pwd = $_[0];
29 };
30
31 pcb;
32
33 my ($sysread, $aioread);
34
35 sysseek $pwd, 7, 0;
36 sysread $pwd, $sysread, 15;
37
38 # I found no way to silence the stupid "uninitialized...subroutine entry" warning.
39 # this is just braindamaged. Don't use -w, it introduces more bugs than it fixes.
40 $aioread = "";
41
42 aio_read $pwd, 7, 15, $aioread, 0, sub {
43 print +($aioread eq $sysread) ? "ok" : "not ok", " 2\n";
44 };
45
46 pcb;
47