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..10\n"; |
4 | print "1..10\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 | |
9 | |
10 | # relies on /etc/passwd to exist... |
10 | # relies on /etc/passwd to exist... |
11 | |
11 | |
… | |
… | |
19 | my $rfd = ""; vec ($rfd, IO::AIO::poll_fileno, 1) = 1; select $rfd, undef, undef, undef; |
19 | my $rfd = ""; vec ($rfd, IO::AIO::poll_fileno, 1) = 1; select $rfd, undef, undef, undef; |
20 | IO::AIO::poll_cb; |
20 | IO::AIO::poll_cb; |
21 | } |
21 | } |
22 | } |
22 | } |
23 | |
23 | |
24 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
24 | aio_open "AIO.xs", O_RDONLY, 0, sub { |
25 | print $_[0] >= 0 ? "ok" : "not ok", " 1\n"; |
25 | print $_[0] ? "ok" : "not ok", " 1\n"; |
|
|
26 | |
26 | $pwd = $_[0]; |
27 | $pwd = $_[0]; |
27 | }; |
28 | }; |
28 | |
29 | |
29 | pcb; |
30 | pcb; |
30 | |
31 | |
31 | aio_stat "/etc", sub { |
32 | aio_stat "bin", sub { |
32 | print -d _ ? "ok" : "not ok", " 2\n"; |
33 | print -d _ ? "ok" : "not ok", " 2\n"; |
33 | }; |
34 | }; |
34 | |
35 | |
35 | pcb; |
36 | pcb; |
36 | |
37 | |
37 | aio_stat "/etc/passwd", sub { |
38 | aio_stat "AIO.xs", sub { |
38 | @pwd = stat _; |
39 | @pwd = stat _; |
39 | print -f _ ? "ok" : "not ok", " 3\n"; |
40 | print -f _ ? "ok" : "not ok", " 3\n"; |
40 | print eval { lstat _; 1 } ? "not ok" : "ok", " 4\n"; |
41 | print eval { lstat _; 1 } ? "not ok" : "ok", " 4\n"; |
41 | }; |
42 | }; |
42 | |
43 | |
43 | pcb; |
44 | pcb; |
44 | |
45 | |
45 | aio_lstat "/etc/passwd", sub { |
46 | aio_lstat "AIO.xs", sub { |
46 | lstat _; |
47 | lstat _; |
47 | print -f _ ? "ok" : "not ok", " 5\n"; |
48 | print -f _ ? "ok" : "not ok", " 5\n"; |
48 | print eval { stat _; 1 } ? "ok" : "not ok", " 6\n"; |
49 | print eval { stat _; 1 } ? "ok" : "not ok", " 6\n"; |
49 | }; |
50 | }; |
50 | |
51 | |
51 | pcb; |
52 | pcb; |
52 | |
53 | |
53 | print open (PWD, "<&$pwd") ? "ok" : "not ok", " 7\n"; |
54 | print open (PWD, "<&" . fileno $pwd) ? "ok" : "not ok", " 7\n"; |
54 | |
55 | |
55 | aio_stat *PWD, sub { |
56 | aio_stat *PWD, sub { |
56 | print -f _ ? "ok" : "not ok", " 8\n"; |
57 | print -f _ ? "ok" : "not ok", " 8\n"; |
|
|
58 | my @stat = stat _; |
|
|
59 | $stat[0] = $pwd[0]; # dev unreliable on windows |
|
|
60 | $stat[6] = $pwd[6]; # rdev unreliable on windows |
|
|
61 | $stat[8] = $pwd[8]; # atime unreliable on windows |
57 | print +(join ":", @pwd) eq (join ":", stat _) ? "ok" : "not ok", " 9\n"; |
62 | print +(join ":", @pwd) eq (join ":", @stat) ? "ok" : "not ok", " 9 # @pwd == @stat\n"; |
58 | }; |
63 | }; |
59 | |
64 | |
60 | pcb; |
65 | pcb; |
61 | |
66 | |
62 | aio_close *PWD, sub { |
67 | aio_close *PWD, sub { |
63 | print $_[0] ? "not ok" : "ok", " 10\n"; |
68 | print $_[0] ? "not ok" : "ok", " 10 # <@_>\n"; |
64 | }; |
69 | }; |
65 | |
70 | |
66 | pcb; |
71 | pcb; |
|
|
72 | |