1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | $| = 1; |
3 | $| = 1; |
4 | |
4 | |
|
|
5 | # not tested: symlink, readlink, link, utime, chown, chmod |
|
|
6 | |
5 | BEGIN { |
7 | BEGIN { |
6 | print "1..24\n"; |
8 | print "1..37\n"; |
7 | print "ok 1 # MODEL=$AnyEvent::IO::MODEL\n"; |
9 | print "ok 1 # MODEL=$AnyEvent::IO::MODEL\n"; |
8 | } |
10 | } |
9 | use AnyEvent; |
11 | use AnyEvent; |
10 | use AnyEvent::IO qw(:DEFAULT :flags); |
12 | use AnyEvent::IO qw(:DEFAULT :flags); |
11 | BEGIN { |
13 | BEGIN { |
… | |
… | |
13 | } |
15 | } |
14 | |
16 | |
15 | our $t = 3; |
17 | our $t = 3; |
16 | |
18 | |
17 | sub t { |
19 | sub t { |
18 | my $cv = AE::cv; |
|
|
19 | my $ok = shift; |
20 | my $ok = shift; |
20 | my $f = "ae_" . shift; |
21 | my $f = "aio_" . shift; |
21 | $f->(@_, my $cv = AE::cv); |
22 | $f->(@_, my $cv = AE::cv); |
22 | my @res = $cv->recv; |
23 | my @res = $cv->recv; |
23 | |
24 | |
24 | print !@res != !$ok ? "not " : "", "ok ", $t++, " # $f (@_) = (@res)\n"; |
25 | print !@res != !$ok ? "not " : "", "ok ", $t++, " # $f (@_) = (@res)\n"; |
25 | |
26 | |
… | |
… | |
39 | my $fh = t 1, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666; |
40 | my $fh = t 1, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666; |
40 | t 0, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666; |
41 | t 0, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666; |
41 | |
42 | |
42 | t 0, rmdir => $DIR; |
43 | t 0, rmdir => $DIR; |
43 | |
44 | |
44 | t 1, write => $fh, "test1"; |
45 | t 1, write => $fh, "tes--"; |
45 | t 1, write => $fh, "test2"; |
46 | t 1, write => $fh, "test2"; |
46 | t 1, write => $fh, ""; |
47 | t 1, write => $fh, ""; |
|
|
48 | |
|
|
49 | t 1, seek => $fh, 3, 0; |
|
|
50 | t 1, write => $fh, "t1"; |
|
|
51 | |
|
|
52 | #t 1, truncate => $fh, 5+5; # not available on windows |
47 | |
53 | |
48 | t 1, stat => $fh; |
54 | t 1, stat => $fh; |
49 | print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size\n"; |
55 | print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size\n"; |
50 | |
56 | |
51 | t 1, close => $fh; |
57 | t 1, close => $fh; |
52 | |
58 | |
53 | t 1, stat => "$DIR/test"; |
59 | t 1, stat => "$DIR/test"; |
54 | print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size\n"; |
60 | print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size (", -s _,")\n"; |
55 | |
61 | |
56 | t 1, lstat => "$DIR/test"; |
62 | t 1, lstat => "$DIR/test"; |
57 | print -s _ != 10 ? "not " : "", "ok ", $t++, " # lstat size\n"; |
63 | print -s _ != 10 ? "not " : "", "ok ", $t++, " # lstat size\n"; |
58 | |
64 | |
59 | t 1, rename => "$DIR/test", "$DIR/test2"; |
65 | t 1, rename => "$DIR/test", "$DIR/test2"; |
60 | |
66 | |
61 | ############################################################################# |
67 | ############################################################################# |
|
|
68 | # test dir |
|
|
69 | |
|
|
70 | t 0, readdir => "$DIR/nonexistent"; |
|
|
71 | my $res = t 1, readdir => $DIR; |
|
|
72 | print @$res != 1 ? "not " : "", "ok ", $t++, " # res count\n"; |
|
|
73 | print $res->[0] ne "test2" ? "not " : "", "ok ", $t++, " # res data (@$res)\n"; |
|
|
74 | |
|
|
75 | ############################################################################# |
62 | # test file |
76 | # test file |
63 | |
77 | |
64 | my $fh = t 1, open => "$DIR/test2", O_RDONLY, 0; |
78 | $fh = t 1, open => "$DIR/test2", O_RDONLY, 0; |
65 | |
79 | |
66 | print +(t 1, read => $fh, 6) ne "test1t" ? "not " : "", "ok ", $t++, " # read 6\n"; |
80 | print +(t 1, read => $fh, 6) ne "test1t" ? "not " : "", "ok ", $t++, " # read 6\n"; |
67 | print +(t 1, read => $fh, 7) ne "est2" ? "not " : "", "ok ", $t++, " # read 7\n"; |
81 | print +(t 1, read => $fh, 7) ne "est2" ? "not " : "", "ok ", $t++, " # read 7\n"; |
68 | print +(t 1, read => $fh, 8) ne "" ? "not " : "", "ok ", $t++, " # read 8\n"; |
82 | print +(t 1, read => $fh, 8) ne "" ? "not " : "", "ok ", $t++, " # read 8\n"; |
69 | |
83 | |