1 |
$| = 1; |
2 |
|
3 |
if (-f "/etc/passwd" and -d "/etc") { |
4 |
print "1..10\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 |
aio_open "/etc/passwd", O_RDONLY, 0, sub { |
25 |
print $_[0] >= 0 ? "ok" : "not ok", " 1\n"; |
26 |
$pwd = $_[0]; |
27 |
}; |
28 |
|
29 |
pcb; |
30 |
|
31 |
aio_stat "/etc", sub { |
32 |
print -d _ ? "ok" : "not ok", " 2\n"; |
33 |
}; |
34 |
|
35 |
pcb; |
36 |
|
37 |
aio_stat "/etc/passwd", sub { |
38 |
@pwd = stat _; |
39 |
print -f _ ? "ok" : "not ok", " 3\n"; |
40 |
print eval { lstat _; 1 } ? "not ok" : "ok", " 4\n"; |
41 |
}; |
42 |
|
43 |
pcb; |
44 |
|
45 |
aio_lstat "/etc/passwd", sub { |
46 |
lstat _; |
47 |
print -f _ ? "ok" : "not ok", " 5\n"; |
48 |
print eval { stat _; 1 } ? "ok" : "not ok", " 6\n"; |
49 |
}; |
50 |
|
51 |
pcb; |
52 |
|
53 |
print open (PWD, "<&$pwd") ? "ok" : "not ok", " 7\n"; |
54 |
|
55 |
aio_stat *PWD, sub { |
56 |
print -f _ ? "ok" : "not ok", " 8\n"; |
57 |
print +(join ":", @pwd) eq (join ":", stat _) ? "ok" : "not ok", " 9\n"; |
58 |
}; |
59 |
|
60 |
pcb; |
61 |
|
62 |
aio_close *PWD, sub { |
63 |
print $_[0] ? "not ok" : "ok", " 10\n"; |
64 |
}; |
65 |
|
66 |
pcb; |