Make ioctl implementation BSD-friendly.
[perl-fuse.git] / test / mknod.t
index 2d10c61..c35853a 100644 (file)
@@ -3,12 +3,16 @@ use test::helper qw($_real $_point);
 use Test::More;
 plan tests => 24;
 use English;
+use Unix::Mknod qw(:all);
+use Fcntl qw(S_IFCHR S_IFBLK);
+use POSIX;
 
 my (@stat);
 
 chdir($_point);
-ok(!(system("touch reg"      )>>8),"create normal file");
-ok(!(system("mknod fifo p"   )>>8),"create fifo");
+ok(open($file, '>', 'reg'),"create normal file");
+close($file);
+ok(defined mkfifo($_point.'/fifo', 0600),"create fifo");
 
 chdir($_real);
 ok(-e "reg" ,"normal file exists");
@@ -20,8 +24,8 @@ SKIP: {
        skip('Need root to mknod devices', 8) unless ($UID == 0);
 
        chdir($_point);
-       ok(!(system("mknod chr c 2 3")>>8),"create chrdev");
-       ok(!(system("mknod blk b 2 3")>>8),"create blkdev");
+       ok(!mknod($_point.'/chr', 0600|S_IFCHR, makedev(2,3)),"create chrdev");
+       ok(!mknod($_point.'/blk', 0600|S_IFBLK, makedev(2,3)),"create blkdev");
 
        chdir($_real);
        ok(-e "chr" ,"chrdev exists");
@@ -34,9 +38,9 @@ SKIP: {
        ok(-b "blk" ,"blkdev is blkdev");
 
        @stat = stat("chr");
-       is($stat[6],3+(2<<8),"chrdev has right major,minor");
+       is($stat[6],makedev(2,3),"chrdev has right major,minor");
        @stat = stat("blk");
-       is($stat[6],3+(2<<8),"blkdev has right major,minor");
+       is($stat[6],makedev(2,3),"blkdev has right major,minor");
 }
 
 chdir($_point);
@@ -54,9 +58,9 @@ SKIP: {
        ok(-b "blk" ,"blkdev is blkdev");
 
        @stat = stat("chr");
-       is($stat[6],3+(2<<8),"chrdev has right major,minor");
+       is($stat[6],makedev(2,3),"chrdev has right major,minor");
        @stat = stat("blk");
-       is($stat[6],3+(2<<8),"blkdev has right major,minor");
+       is($stat[6],makedev(2,3),"blkdev has right major,minor");
 }
 
 map { unlink } qw(reg chr blk fifo);