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