Don't override the include path if empty.
[perl-fuse.git] / test / mknod.t
1 #!/usr/bin/perl
2 use test::helper qw($_real $_point);
3 use Test::More;
4 plan tests => 24;
5 use English;
6 use Unix::Mknod qw(:all);
7 use Fcntl qw(S_IFCHR S_IFBLK);
8 use POSIX;
9
10 my (@stat);
11
12 chdir($_point);
13 ok(open($file, '>', 'reg'),"create normal file");
14 close($file);
15 ok(defined mkfifo($_point.'/fifo', 0600),"create fifo");
16
17 chdir($_real);
18 ok(-e "reg" ,"normal file exists");
19 ok(-e "fifo","fifo exists");
20 ok(-f "reg" ,"normal file is normal file");
21 ok(-p "fifo","fifo is fifo");
22
23 SKIP: {
24         skip('Need root to mknod devices', 8) unless ($UID == 0);
25
26         chdir($_point);
27         ok(!mknod($_point.'/chr', 0600|S_IFCHR, makedev(2,3)),"create chrdev");
28         ok(!mknod($_point.'/blk', 0600|S_IFBLK, makedev(2,3)),"create blkdev");
29
30         chdir($_real);
31         ok(-e "chr" ,"chrdev exists");
32         ok(-e "blk" ,"blkdev exists");
33         
34         skip('mknod() is just pretend under fakeroot(1)', 4)
35           if exists $ENV{FAKEROOTKEY};
36
37         ok(-c "chr" ,"chrdev is chrdev");
38         ok(-b "blk" ,"blkdev is blkdev");
39
40         @stat = stat("chr");
41         is($stat[6],makedev(2,3),"chrdev has right major,minor");
42         @stat = stat("blk");
43         is($stat[6],makedev(2,3),"blkdev has right major,minor");
44 }
45
46 chdir($_point);
47 ok(-e "reg" ,"normal file exists");
48 ok(-e "fifo","fifo exists");
49 ok(-f "reg" ,"normal file is normal file");
50 ok(-p "fifo","fifo is fifo");
51
52 SKIP: {
53         skip('Need root to mknod devices', 6) unless ($UID == 0);
54
55         ok(-e "chr" ,"chrdev exists");
56         ok(-e "blk" ,"blkdev exists");
57         ok(-c "chr" ,"chrdev is chrdev");
58         ok(-b "blk" ,"blkdev is blkdev");
59
60         @stat = stat("chr");
61         is($stat[6],makedev(2,3),"chrdev has right major,minor");
62         @stat = stat("blk");
63         is($stat[6],makedev(2,3),"blkdev has right major,minor");
64 }
65
66 map { unlink } qw(reg chr blk fifo);