3 # $RCSfile: fs.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:28 $
7 unshift @INC, '../lib';
12 $Is_Dosish = ($^O eq 'MSWin32' or $^O eq 'dos' or
13 $^O eq 'os2' or $^O eq 'mint');
17 $wd = (($^O eq 'MSWin32') ? `cd` : `pwd`);
20 if ($^O eq 'MSWin32') { `del tmp 2>nul`; `mkdir tmp`; }
21 else { `rm -f tmp 2>/dev/null; mkdir tmp 2>/dev/null`; }
23 `/bin/rm -rf a b c x` if -x '/bin/rm';
27 if ($^O eq 'MSWin32') { print "ok 1 # skipped: bogus umask()\n"; }
28 elsif ((umask(0)&0777) == 022) {print "ok 1\n";} else {print "not ok 1\n";}
29 open(fh,'>x') || die "Can't create x";
31 open(fh,'>a') || die "Can't create a";
34 if ($Is_Dosish) {print "ok 2 # skipped: no link\n";}
35 elsif (eval {link('a','b')}) {print "ok 2\n";}
36 else {print "not ok 2\n";}
38 if ($Is_Dosish) {print "ok 3 # skipped: no link\n";}
39 elsif (eval {link('b','c')}) {print "ok 3\n";}
40 else {print "not ok 3\n";}
42 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
43 $blksize,$blocks) = stat('c');
45 if ($Config{dont_use_nlink} || $Is_Dosish)
46 {print "ok 4 # skipped: no link\n";}
49 else {print "not ok 4\n";}
51 if ($^O eq 'amigaos' || $Is_Dosish)
52 {print "ok 5 # skipped: no link\n";}
53 elsif (($mode & 0777) == 0666)
55 else {print "not ok 5\n";}
57 if ((chmod 0777,'a') == 1) {print "ok 6\n";} else {print "not ok 6\n";}
59 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
60 $blksize,$blocks) = stat('c');
61 if ($Is_Dosish) {print "ok 7 # skipped: no link\n";}
62 elsif (($mode & 0777) == 0777) {print "ok 7\n";}
63 else {print "not ok 7\n";}
65 if ($Is_Dosish) {print "ok 8 # skipped: no link\n";}
66 elsif ((chmod 0700,'c','x') == 2) {print "ok 8\n";}
67 else {print "not ok 8\n";}
69 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
70 $blksize,$blocks) = stat('c');
71 if ($Is_Dosish) {print "ok 9 # skipped: no link\n";}
72 elsif (($mode & 0777) == 0700) {print "ok 9\n";}
73 else {print "not ok 9\n";}
75 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
76 $blksize,$blocks) = stat('x');
77 if ($Is_Dosish) {print "ok 10 # skipped: no link\n";}
78 elsif (($mode & 0777) == 0700) {print "ok 10\n";}
79 else {print "not ok 10\n";}
81 if ($Is_Dosish) {print "ok 11 # skipped: no link\n"; unlink 'b','x'; }
82 elsif ((unlink 'b','x') == 2) {print "ok 11\n";}
83 else {print "not ok 11\n";}
84 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
85 $blksize,$blocks) = stat('b');
86 if ($ino == 0) {print "ok 12\n";} else {print "not ok 12\n";}
87 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
88 $blksize,$blocks) = stat('x');
89 if ($ino == 0) {print "ok 13\n";} else {print "not ok 13\n";}
91 if (rename('a','b')) {print "ok 14\n";} else {print "not ok 14\n";}
92 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
93 $blksize,$blocks) = stat('a');
94 if ($ino == 0) {print "ok 15\n";} else {print "not ok 15\n";}
95 $delta = $Is_Dosish ? 2 : 1; # Granularity of time on the filesystem
96 $foo = (utime 500000000,500000000 + $delta,'b');
97 if ($foo == 1) {print "ok 16\n";} else {print "not ok 16 $foo\n";}
98 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
99 $blksize,$blocks) = stat('b');
100 if ($^O eq 'MSWin32') { print "ok 17 # skipped: bogus (stat)[1]\n"; }
101 elsif ($ino) {print "ok 17\n";} else {print "not ok 17\n";}
102 if ($wd =~ m#/afs/# || $^O eq 'amigaos' || $^O eq 'dos' || $^O eq 'MSWin32')
103 {print "ok 18 # skipped: granularity of the filetime\n";}
104 elsif ($atime == 500000000 && $mtime == 500000000 + $delta)
107 {print "not ok 18 $atime $mtime\n";}
109 if ((unlink 'b') == 1) {print "ok 19\n";} else {print "not ok 19\n";}
110 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
111 $blksize,$blocks) = stat('b');
112 if ($ino == 0) {print "ok 20\n";} else {print "not ok 20\n";}
115 chdir $wd || die "Can't cd back to $wd";
118 if ($^O ne 'MSWin32' and `ls -l perl 2>/dev/null` =~ /^l.*->/) {
119 # we have symbolic links
120 if (symlink("TEST","c")) {print "ok 21\n";} else {print "not ok 21\n";}
121 $foo = `grep perl c`;
122 if ($foo) {print "ok 22\n";} else {print "not ok 22\n";}
126 print "ok 21\nok 22\n";
129 # truncate (may not be implemented everywhere)
131 `echo helloworld > Iofs.tmp`;
132 eval { truncate "Iofs.tmp", 5; };
133 if ($@ =~ /not implemented/) {
134 print "# truncate not implemented -- skipping tests 23 through 26\n";
140 if (-s "Iofs.tmp" == 5) {print "ok 23\n"} else {print "not ok 23\n"}
141 truncate "Iofs.tmp", 0;
142 if (-z "Iofs.tmp") {print "ok 24\n"} else {print "not ok 24\n"}
143 open(FH, ">Iofs.tmp") or die "Can't create Iofs.tmp";
144 { select FH; $| = 1; select STDOUT }
147 print FH "helloworld\n";
151 # Not needed on HPFS, but needed on HPFS386 ?!
154 close (FH); open (FH, ">>Iofs.tmp") or die "Can't reopen Iofs.tmp";
156 if (-s "Iofs.tmp" == 5) {print "ok 25\n"} else {print "not ok 25\n"}
159 # Not needed on HPFS, but needed on HPFS386 ?!
162 close (FH); open (FH, ">>Iofs.tmp") or die "Can't reopen Iofs.tmp";
164 if (-z "Iofs.tmp") {print "ok 26\n"} else {print "not ok 26\n"}
168 # check if rename() works on directories
169 rename 'tmp', 'tmp1' or print "not ";
171 -d 'tmp1' or print "not ";
174 END { rmdir 'tmp1'; unlink "Iofs.tmp"; }