ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/03_errors.t
(Generate patch)

Comparing IO-AIO/t/03_errors.t (file contents):
Revision 1.1 by root, Sun Jul 31 17:24:05 2005 UTC vs.
Revision 1.6 by root, Thu Jan 7 18:25:51 2010 UTC

5use POSIX qw(ENOENT EACCES EBADF); 5use POSIX qw(ENOENT EACCES EBADF);
6use FindBin; 6use FindBin;
7use lib "$FindBin::Bin"; 7use lib "$FindBin::Bin";
8use aio_test_common; 8use aio_test_common;
9 9
10BEGIN { plan tests => 9 } 10BEGIN { plan tests => 12 }
11 11
12IO::AIO::min_parallel 2; 12IO::AIO::min_parallel 2;
13 13
14my $tempdir = tempdir(); 14my $tempdir = tempdir();
15 15
16my $some_dir = "$tempdir/some_dir/"; 16my $some_dir = "$tempdir/some_dir";
17my $some_file = "$some_dir/some_file"; 17my $some_file = "$some_dir/some_file";
18my $some_link = "$some_dir/some_link";
18 19
19# create a file in a non-existent directory 20# create a file in a non-existent directory
20aio_open $some_file, O_RDWR|O_CREAT|O_TRUNC, 0, sub { 21aio_open $some_file, O_RDWR|O_CREAT|O_TRUNC, 0, sub {
21 ok((!defined $_[0]) && $! == ENOENT); 22 ok((!defined $_[0]) && $! == ENOENT);
22}; 23};
26ok(mkdir $some_dir); 27ok(mkdir $some_dir);
27aio_open $some_file, O_RDWR|O_CREAT|O_TRUNC, 0644, sub { 28aio_open $some_file, O_RDWR|O_CREAT|O_TRUNC, 0644, sub {
28 my $fh = shift; 29 my $fh = shift;
29 ok(defined $fh); 30 ok(defined $fh);
30 print $fh "contents."; 31 print $fh "contents.";
32 ok(-e $some_file);
31 close $fh; 33 close $fh;
32 ok(-e $some_file);
33}; 34};
34pcb; 35pcb;
35 36
36# test error on unlinking non-empty directory 37# test error on unlinking nonexistent file
37aio_unlink "$some_dir/notfound.txt", sub { 38aio_unlink "$some_dir/notfound.txt", sub {
38 ok($_[0] < 0); 39 ok($_[0] < 0);
39 ok($! == ENOENT); 40 ok($! == ENOENT);
40}; 41};
41pcb; 42pcb;
42 43
43# write to file open for reading 44# write to file open for reading
44ok(open(F, $some_file)) or die $!; 45ok(open(F, $some_file)) or die $!;
45aio_write *F, 0, 10, "foobarbaz.", 0, sub { 46eval { aio_write *F, 0, 10, "foobarbaz.", 0, sub { ok (0) } };
46 my $written = shift; 47ok ($@ =~ /mode mismatch/);
47 ok($written < 0); 48pcb;
48 ok($! == EBADF); 49
50close F;
51
52aio_symlink "\\test\\", $some_link, sub {
53 if ($^O eq "cygwin") {
54 ok (1);
55 ok (1);
56 } else {
57 ok (!$_[0]);
58 ok ("\\test\\" eq readlink $some_link);
59 }
49}; 60};
61pcb;
62unlink $some_link;
63
64# test unlinking and rmdir
65aio_unlink $some_file, sub {
66 ok (!shift);
67};
68pcb;
69aio_rmdir $some_dir, sub {
70 ok (!shift);
71};
72pcb;
50 73
51 74
52 75
53

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines