1 |
#!/usr/bin/perl -w |
2 |
use test::helper qw($_point $_loop $_real $_pidfile); |
3 |
use strict; |
4 |
use Test::More tests => 3; |
5 |
|
6 |
sub is_mounted { |
7 |
my $diag = -d '/proc' ? `cat /proc/mounts` : `mount`; |
8 |
return $diag =~ m{ (?:/private)?$_point }; |
9 |
} |
10 |
|
11 |
ok(!is_mounted(),"already mounted"); |
12 |
ok(-f $_loop,"loopback exists"); |
13 |
|
14 |
if(!fork()) { |
15 |
#close(STDIN); |
16 |
close(STDOUT); |
17 |
close(STDERR); |
18 |
mkdir $_point; |
19 |
mkdir $_real; |
20 |
`echo $$ >test/s/mounted.pid`; |
21 |
diag "mounting $_loop to $_point"; |
22 |
open STDOUT, '>', '/tmp/fusemnt.log'; |
23 |
open STDERR, '>&', \*STDOUT; |
24 |
exec("perl -Iblib/lib -Iblib/arch $_loop $_point"); |
25 |
exit(1); |
26 |
} |
27 |
|
28 |
my ($success, $count) = (0,0); |
29 |
while ($count++ < 50 && !$success) { |
30 |
select(undef, undef, undef, 0.1); |
31 |
($success) = is_mounted(); |
32 |
} |
33 |
diag "Mounted in ", $count/10, " secs"; |
34 |
|
35 |
ok($success,"mount succeeded"); |
36 |
system("rm -rf $_real"); |
37 |
unless($success) { |
38 |
kill('INT',`cat $_pidfile`); |
39 |
unlink($_pidfile); |
40 |
} else { |
41 |
mkdir($_real); |
42 |
} |