avoid cpan indexing of test::helper
[perl-fuse.git] / test / s / mount.t
index affd658..c56fdc1 100644 (file)
@@ -1,26 +1,32 @@
 #!/usr/bin/perl -w
-use test::helper qw($_point $_loop $_real $_pidfile);
+use test::helper qw($_point $_loop $_opts $_real $_pidfile);
 use strict;
+use Errno qw(:POSIX);
 use Test::More tests => 3;
-ok(!(scalar grep(/ on $_point /,`cat /proc/mounts`)),"already mounted");
-ok(-f $_loop,"loopback exists");
 
-if(!fork()) {
-       #close(STDIN);
-       close(STDOUT);
-       close(STDERR);
-       mkdir $_point;
-       mkdir $_real;
-       `echo $$ >test/s/mounted.pid`;
-       diag "mounting $_loop to $_point";
-       exec("perl -Iblib/lib -Iblib/arch $_loop $_point");
-       exit(1);
+sub is_mounted {
+       my $diag = -e '/proc/mounts' ? `cat /proc/mounts` : ($^O eq 'linux' ? `/bin/mount` : `/sbin/mount`);
+       return $diag =~ m{ (?:/private)?$_point };
 }
 
+ok(!is_mounted(),"already mounted");
+ok(-f $_loop,"loopback exists");
+
+mkdir $_point;
+mkdir $_real;
+diag "mounting $_loop to $_point";
+open REALSTDOUT, '>&STDOUT';
+open REALSTDERR, '>&STDERR';
+open STDOUT, '>', '/tmp/fusemnt.log';
+open STDERR, '>&', \*STDOUT;
+system("perl -Iblib/lib -Iblib/arch $_loop $_opts $_point");
+open STDOUT, '>&', \*REALSTDOUT;
+open STDERR, '>&', \*REALSTDERR;
+
 my ($success, $count) = (0,0);
 while ($count++ < 50 && !$success) {
        select(undef, undef, undef, 0.1);
-    ($success) = `cat /proc/mounts` =~ / $_point /;
+       ($success) = is_mounted();
 }
 diag "Mounted in ", $count/10, " secs";