File: 05_readdir.t

package info (click to toggle)
libio-aio-perl 2.4-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 356 kB
  • ctags: 76
  • sloc: perl: 413; ansic: 97; makefile: 50
file content (51 lines) | stat: -rw-r--r-- 746 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl

use Test;
use IO::AIO;

# this is a lame test, but....

BEGIN { plan tests => 8 }

my %f;
ok ((opendir my $dir, "."), 1, "$!");
$f{$_}++ for readdir $dir;

my %x = %f;

aio_readdir ".", sub {
   delete $x{"."};
   delete $x{".."};
   if ($_[0]) {
      ok (1);
      my $ok = 1;
      $ok &&= delete $x{$_} for @{$_[0]};
      ok ($ok);
      ok (!scalar keys %x);
   } else {
      ok (0,1,"$!");
   }
};

IO::AIO::poll;

%x = %f;

aio_scandir ".", 0, sub {
   delete $x{"."};
   delete $x{".."};
   if (@_) {
      ok (1);
      my $ok = 1;
      $ok &&= delete $x{$_} for (@{$_[0]}, @{$_[1]});
      ok ($ok);
      ok (!scalar keys %x);
   } else {
      ok (0,1,"$!");
   }
};

IO::AIO::poll while IO::AIO::nreqs;

ok (1);