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