ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/01_stat.t
Revision: 1.5
Committed: Sun Jul 17 04:20:04 2011 UTC (12 years, 11 months ago) by root
Content type: application/x-troff
Branch: MAIN
Changes since 1.4: +4 -1 lines
Log Message:
initial windows support

File Contents

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