ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/02_read.t
Revision: 1.4
Committed: Sun Jun 3 09:44:17 2007 UTC (17 years, 1 month ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-3_31, rel-2_6, rel-2_4, rel-2_5, rel-3_65, rel-3_71, rel-3_7, rel-3_6, rel-3_5, rel-3_4, rel-3_3, rel-3_2, rel-3_1, rel-3_0, rel-3_9, rel-3_8, rel-2_51, rel-3_261, rel-3_01, rel-3_02, rel-3_03, rel-3_04, rel-3_05, rel-3_06, rel-3_07, rel-2_41, rel-3_93, rel-3_92, rel-3_91, rel-3_19, rel-3_18, rel-3_17, rel-3_16, rel-3_15, rel-3_26, rel-3_25, rel-3_22, rel-3_23, rel-3_21, rel-2_61, rel-2_62
Changes since 1.3: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 $| = 1;
2    
3     if (-f "/etc/passwd" and -d "/etc") {
4 root 1.2 print "1..2\n";
5 root 1.1 } 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 root 1.2 print $_[0] ? "ok" : "not ok", " 1\n";
28     $pwd = $_[0];
29 root 1.1 };
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 root 1.4 $aioread = "xxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
41 root 1.1
42 root 1.3 aio_read $pwd, 7, 15, $aioread, 3, sub {
43     print +($aioread eq "xxx$sysread") ? "ok" : "not ok", " 2\n";
44 root 1.1 };
45    
46     pcb;
47