1 |
#!/usr/bin/perl |
2 |
package test::helper; |
3 |
use strict; |
4 |
use Exporter; |
5 |
use POSIX qw(WEXITSTATUS); |
6 |
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
7 |
@ISA = "Exporter"; |
8 |
@EXPORT_OK = qw($_loop $_point $_pidfile $_real); |
9 |
our($_loop, $_point, $_pidfile, $_real) = ("examples/loopback.pl","/tmp/fusemnt-".$ENV{LOGNAME},"test/s/mounted.pid","/tmp/fusetest-".$ENV{LOGNAME}); |
10 |
if($0 !~ qr|s/u?mount\.t$|) { |
11 |
my ($reject) = 1; |
12 |
if(-f $_pidfile) { |
13 |
unless(POSIX::WEXITSTATUS(system("ps `cat $_pidfile` | grep \"$_loop $_point\" >/dev/null"))) { |
14 |
if(`mount | grep "on $_point"`) { |
15 |
$reject = 0; |
16 |
} else { |
17 |
system("kill `cat $_pidfile`"); |
18 |
} |
19 |
} |
20 |
} |
21 |
system("ls $_point >&/dev/null"); |
22 |
$reject = 1 if (POSIX::WEXITSTATUS($?)); |
23 |
die "not properly mounted\n" if $reject; |
24 |
} |
25 |
1; |