/[fuse.before_github]/perl-llin/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

Annotation of /perl-llin/test/helper.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Sun Mar 20 00:36:05 2005 UTC (19 years, 1 month ago) by dpavlin
Original Path: perl/trunk/test/helper.pm
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 mszeredi 4 #!/usr/bin/perl
2     package test::helper;
3     use strict;
4     use Exporter;
5 dpavlin 10 use POSIX qw(WEXITSTATUS);
6 mszeredi 4 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
7     @ISA = "Exporter";
8     @EXPORT_OK = qw($_loop $_point $_pidfile $_real);
9 dpavlin 10 our($_loop, $_point, $_pidfile, $_real) = ("examples/loopback.pl","/tmp/fusemnt-".$ENV{LOGNAME},"test/s/mounted.pid","/tmp/fusetest-".$ENV{LOGNAME});
10 mszeredi 4 if($0 !~ qr|s/u?mount\.t$|) {
11     my ($reject) = 1;
12     if(-f $_pidfile) {
13 dpavlin 10 unless(POSIX::WEXITSTATUS(system("ps `cat $_pidfile` | grep \"$_loop $_point\" >/dev/null"))) {
14 mszeredi 4 if(`mount | grep "on $_point"`) {
15     $reject = 0;
16     } else {
17     system("kill `cat $_pidfile`");
18     }
19     }
20     }
21 dpavlin 10 system("ls $_point >&/dev/null");
22     $reject = 1 if (POSIX::WEXITSTATUS($?));
23 mszeredi 4 die "not properly mounted\n" if $reject;
24     }
25     1;

  ViewVC Help
Powered by ViewVC 1.1.26