ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/t/03_errors.t
Revision: 1.2
Committed: Mon Aug 1 08:53:27 2005 UTC (18 years, 11 months ago) by root
Content type: application/x-troff
Branch: MAIN
Changes since 1.1: +1 -3 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.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 => 9 }
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    
19     # create a file in a non-existent directory
20     aio_open $some_file, O_RDWR|O_CREAT|O_TRUNC, 0, sub {
21     ok((!defined $_[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 $fh = shift;
29     ok(defined $fh);
30     print $fh "contents.";
31     close $fh;
32     ok(-e $some_file);
33     };
34     pcb;
35    
36     # test error on unlinking non-empty directory
37     aio_unlink "$some_dir/notfound.txt", sub {
38     ok($_[0] < 0);
39     ok($! == ENOENT);
40     };
41     pcb;
42    
43     # write to file open for reading
44     ok(open(F, $some_file)) or die $!;
45     aio_write *F, 0, 10, "foobarbaz.", 0, sub {
46     my $written = shift;
47     ok($written < 0);
48     ok($! == EBADF);
49     };
50 root 1.2 pcb;
51 root 1.1