/[fuse.before_github]/perl/trunk/test/helper.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /perl/trunk/test/helper.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations)
Sun Mar 20 00:36:05 2005 UTC (17 years, 8 months ago) by dpavlin
File size: 772 byte(s)
From: Richard Dawe <rich(at)phekda(dot)gotadsl(dot)co(dot)uk>

Please find attached a patch that allows Fuse.pm's test suite to run as a
non-root user. It will skip all the tests that require root priveleges (giving
away ownership using chown, mknod of character and block devices). The patch
creates a test root and mount point per user.

The patch also uses POSIX::WEXITSTATUS instead of the less portable "$? >> 8"
idiom.

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;

  ViewVC Help
Powered by ViewVC 1.1.26