/[fuse.before_github]/perl/trunk/test/mknod.t
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/mknod.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations)
Sun Mar 20 00:36:05 2005 UTC (19 years, 1 month ago) by dpavlin
File MIME type: application/x-troff
File size: 1450 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 use test::helper qw($_real $_point);
3 use Test::More;
4 plan tests => 24;
5 use English;
6
7 my (@stat);
8
9 chdir($_point);
10 ok(!(system("touch reg" )>>8),"create normal file");
11 ok(!(system("mknod fifo p" )>>8),"create fifo");
12
13 chdir($_real);
14 ok(-e "reg" ,"normal file exists");
15 ok(-e "fifo","fifo exists");
16 ok(-f "reg" ,"normal file is normal file");
17 ok(-p "fifo","fifo is fifo");
18
19 SKIP: {
20 skip('Need root to mknod devices', 8) unless ($UID == 0);
21
22 chdir($_point);
23 ok(!(system("mknod chr c 2 3")>>8),"create chrdev");
24 ok(!(system("mknod blk b 2 3")>>8),"create blkdev");
25
26 chdir($_real);
27 ok(-e "chr" ,"chrdev exists");
28 ok(-e "blk" ,"blkdev exists");
29 ok(-c "chr" ,"chrdev is chrdev");
30 ok(-b "blk" ,"blkdev is blkdev");
31
32 @stat = stat("chr");
33 is($stat[6],3+(2<<8),"chrdev has right major,minor");
34 @stat = stat("blk");
35 is($stat[6],3+(2<<8),"blkdev has right major,minor");
36 }
37
38 chdir($_point);
39 ok(-e "reg" ,"normal file exists");
40 ok(-e "fifo","fifo exists");
41 ok(-f "reg" ,"normal file is normal file");
42 ok(-p "fifo","fifo is fifo");
43
44 SKIP: {
45 skip('Need root to mknod devices', 6) unless ($UID == 0);
46
47 ok(-e "chr" ,"chrdev exists");
48 ok(-e "blk" ,"blkdev exists");
49 ok(-c "chr" ,"chrdev is chrdev");
50 ok(-b "blk" ,"blkdev is blkdev");
51
52 @stat = stat("chr");
53 is($stat[6],3+(2<<8),"chrdev has right major,minor");
54 @stat = stat("blk");
55 is($stat[6],3+(2<<8),"blkdev has right major,minor");
56 }
57
58 map { unlink } qw(reg chr blk fifo);

  ViewVC Help
Powered by ViewVC 1.1.26