ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/03_errors.t
Revision: 1.5
Committed: Sun Apr 19 13:15:55 2009 UTC (15 years, 2 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-3_31, rel-3_4, rel-3_3, rel-3_2, rel-3_261, rel-3_19, rel-3_18, rel-3_26, rel-3_25, rel-3_22, rel-3_23, rel-3_21
Changes since 1.4: +3 -6 lines
Log Message:
*** empty log message ***

File Contents

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