X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=test%2Fhelper.pm;h=ca75dc355315909fb13411132e1e744281a18085;hb=77b8ae12839c2799580ab9cfcaa08a3bf2c463e5;hp=817b146e3c1c59787a8cb2ea7666d04b0ff7dd7d;hpb=9861a89831605d25668432a6bb1bff6adad08de1;p=perl-fuse.git diff --git a/test/helper.pm b/test/helper.pm index 817b146..ca75dc3 100644 --- a/test/helper.pm +++ b/test/helper.pm @@ -6,21 +6,25 @@ use Config; use POSIX qw(WEXITSTATUS); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); @ISA = "Exporter"; -@EXPORT_OK = qw($_loop $_point $_pidfile $_real); -our($_loop, $_point, $_pidfile, $_real) = ("","/tmp/fusemnt-".$ENV{LOGNAME},"test/s/mounted.pid","/tmp/fusetest-".$ENV{LOGNAME}); -$_loop = $Config{useithreads} ? "examples/loopback_t.pl" : "examples/loopback.pl"; +@EXPORT_OK = qw($_loop $_opts $_point $_pidfile $_real); +my $tmp = -d '/private' ? '/private/tmp' : '/tmp'; +our($_loop, $_point, $_pidfile, $_real, $_opts) = ('examples/loopback.pl',"$tmp/fusemnt-".$ENV{LOGNAME},$ENV{'PWD'} . "/test/s/mounted.pid","$tmp/fusetest-".$ENV{LOGNAME}, ''); +$_opts = '--pidfile ' . $_pidfile; +$_opts .= $Config{useithreads} ? ' --use-threads' : ''; if($0 !~ qr|s/u?mount\.t$|) { my ($reject) = 1; - if(-f $_pidfile) { - unless(POSIX::WEXITSTATUS(system("ps `cat $_pidfile` | grep \"$_loop $_point\" >/dev/null"))) { - if(`mount | grep "on $_point"`) { + if(open my $fh, '<', $_pidfile) { + my $pid = do {local $/ = undef; <$fh>}; + close $fh; + if(kill 0, $pid) { + if(`mount` =~ m{on (?:/private)?$_point }) { $reject = 0; } else { - system("kill `cat $_pidfile`"); + kill 1, $pid; } } } - system("ls $_point >&/dev/null"); + system("ls $_point >/dev/null"); $reject = 1 if (POSIX::WEXITSTATUS($?)); die "not properly mounted\n" if $reject; }