ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/01_stat.t
Revision: 1.2
Committed: Sun Jul 10 18:16:49 2005 UTC (19 years ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_1
Changes since 1.1: +3 -2 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     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 root 1.2 print $_[0] ? "ok" : "not ok", " 1\n";
26    
27 root 1.1 $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 root 1.2 print open (PWD, "<&" . fileno $pwd) ? "ok" : "not ok", " 7\n";
55 root 1.1
56     aio_stat *PWD, sub {
57     print -f _ ? "ok" : "not ok", " 8\n";
58     print +(join ":", @pwd) eq (join ":", stat _) ? "ok" : "not ok", " 9\n";
59     };
60    
61     pcb;
62    
63     aio_close *PWD, sub {
64     print $_[0] ? "not ok" : "ok", " 10\n";
65     };
66    
67     pcb;