| 1 |
use Test::Simple tests => 5; |
| 2 |
use Linux::Inotify2; |
| 3 |
|
| 4 |
my $in = Linux::Inotify2->new; |
| 5 |
ok ($in, "inotify handle created"); |
| 6 |
|
| 7 |
# create directory for watch |
| 8 |
mkdir $$; |
| 9 |
|
| 10 |
my $watch = $in->watch ($$, IN_ALL_EVENTS); |
| 11 |
ok ($watch, "watch created for directory $$"); |
| 12 |
|
| 13 |
$in->blocking (0); |
| 14 |
|
| 15 |
{ |
| 16 |
my @list = $in->read; |
| 17 |
ok (@list==0, "non blocking: $!"); |
| 18 |
} |
| 19 |
|
| 20 |
rmdir $$; |
| 21 |
|
| 22 |
{ |
| 23 |
my @list = $in->poll; |
| 24 |
ok (@list > 0, scalar @list . " events read"); |
| 25 |
} |
| 26 |
|
| 27 |
ok ($watch->cancel, "watch canceled"); |
| 28 |
|
| 29 |
END { |
| 30 |
rmdir $$; |
| 31 |
} |
| 32 |
|