ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/t/03_errors.t
Revision: 1.2
Committed: Mon Aug 1 08:52:32 2005 UTC (18 years, 10 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -4 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 => 10 }
11
12 Linux::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
19 # create a file in a non-existent directory
20 aio_open $some_file, O_RDWR|O_CREAT|O_TRUNC, 0, sub {
21 ok($_[0] < 0 && $! == ENOENT);
22 };
23 pcb;
24
25 # now actually make that file
26 ok(mkdir $some_dir);
27 aio_open $some_file, O_RDWR|O_CREAT|O_TRUNC, 0644, sub {
28 my $fd = shift;
29 ok($fd > 0);
30 ok(open (FH, ">&$fd"));
31 print FH "contents.";
32 close FH;
33 ok(-e $some_file);
34 };
35 pcb;
36
37 # test error on unlinking non-empty directory
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 aio_write *F, 0, 10, "foobarbaz.", 0, sub {
47 my $written = shift;
48 ok($written < 0);
49 ok($! == EBADF);
50 };
51 pcb;