ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/03_errors.t
Revision: 1.6
Committed: Thu Jan 7 18:25:51 2010 UTC (14 years, 5 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-3_65, rel-3_71, rel-3_7, rel-3_6, rel-3_5, rel-3_9, rel-3_8, rel-3_93, rel-3_92, rel-3_91
Changes since 1.5: +7 -2 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 if ($^O eq "cygwin") {
54 ok (1);
55 ok (1);
56 } else {
57 ok (!$_[0]);
58 ok ("\\test\\" eq readlink $some_link);
59 }
60 };
61 pcb;
62 unlink $some_link;
63
64 # test unlinking and rmdir
65 aio_unlink $some_file, sub {
66 ok (!shift);
67 };
68 pcb;
69 aio_rmdir $some_dir, sub {
70 ok (!shift);
71 };
72 pcb;
73
74
75