3 # $RCSfile: fs.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:28 $
14 # avoid win32 (for now)
15 do { print "1..0\n"; exit(0); } if $^O eq 'MSWin32';
19 $wd = (($^O eq 'MSWin32') ? `cd` : `pwd`);
22 if ($^O eq 'MSWin32') { `del tmp`; `mkdir tmp`; }
23 else { `rm -f tmp 2>/dev/null; mkdir tmp 2>/dev/null`; }
25 `/bin/rm -rf a b c x` if -x '/bin/rm';
29 if ((umask(0)&0777) == 022) {print "ok 1\n";} else {print "not ok 1\n";}
30 open(fh,'>x') || die "Can't create x";
32 open(fh,'>a') || die "Can't create a";
35 if (eval {link('a','b')} || $Is_Dos) {print "ok 2\n";} else {print "not ok 2\n";}
37 if (eval {link('b','c')} || $Is_Dos) {print "ok 3\n";} else {print "not ok 3\n";}
39 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
40 $blksize,$blocks) = stat('c');
42 if ($Config{dont_use_nlink} || $nlink == 3 || $Is_Dos)
43 {print "ok 4\n";} else {print "not ok 4\n";}
45 if (($mode & 0777) == 0666 || $^O eq 'amigaos' || $Is_Dos)
46 {print "ok 5\n";} else {print "not ok 5\n";}
48 if ((chmod 0777,'a') == 1) {print "ok 6\n";} else {print "not ok 6\n";}
50 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
51 $blksize,$blocks) = stat('c');
52 if (($mode & 0777) == 0777 || $Is_Dos) {print "ok 7\n";} else {print "not ok 7\n";}
54 if ((chmod 0700,'c','x') == 2 || $Is_Dos) {print "ok 8\n";} else {print "not ok 8\n";}
56 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
57 $blksize,$blocks) = stat('c');
58 if (($mode & 0777) == 0700 || $Is_Dos) {print "ok 9\n";} else {print "not ok 9\n";}
59 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
60 $blksize,$blocks) = stat('x');
61 if (($mode & 0777) == 0700 || $Is_Dos) {print "ok 10\n";} else {print "not ok 10\n";}
63 if ((unlink 'b','x') == 2 || $Is_Dos) {print "ok 11\n";} else {print "not ok 11\n";}
64 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
65 $blksize,$blocks) = stat('b');
66 if ($ino == 0) {print "ok 12\n";} else {print "not ok 12\n";}
67 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
68 $blksize,$blocks) = stat('x');
69 if ($ino == 0) {print "ok 13\n";} else {print "not ok 13\n";}
71 if (rename('a','b')) {print "ok 14\n";} else {print "not ok 14\n";}
72 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
73 $blksize,$blocks) = stat('a');
74 if ($ino == 0) {print "ok 15\n";} else {print "not ok 15\n";}
75 $foo = (utime 500000000,500000001,'b');
76 if ($foo == 1) {print "ok 16\n";} else {print "not ok 16 $foo\n";}
77 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
78 $blksize,$blocks) = stat('b');
79 if ($ino) {print "ok 17\n";} else {print "not ok 17\n";}
80 if (($atime == 500000000 && $mtime == 500000001)
81 || $wd =~ m#/afs/# || $^O eq 'amigaos' || $Is_Dos)
84 {print "not ok 18 $atime $mtime\n";}
86 if ((unlink 'b') == 1) {print "ok 19\n";} else {print "not ok 19\n";}
87 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
88 $blksize,$blocks) = stat('b');
89 if ($ino == 0) {print "ok 20\n";} else {print "not ok 20\n";}
92 chdir $wd || die "Can't cd back to $wd";
96 if ($^O ne 'MSWin32' and `ls -l perl 2>/dev/null` =~ /^l.*->/) {
97 # we have symbolic links
98 if (symlink("TEST","c")) {print "ok 21\n";} else {print "not ok 21\n";}
100 if ($foo) {print "ok 22\n";} else {print "not ok 22\n";}
104 print "ok 21\nok 22\n";
107 # truncate (may not be implemented everywhere)
109 `echo helloworld > Iofs.tmp`;
110 eval { truncate "Iofs.tmp", 5; };
111 if ($@ =~ /not implemented/) {
112 print "# truncate not implemented -- skipping tests 23 through 26\n";
118 if (-s "Iofs.tmp" == 5) {print "ok 23\n"} else {print "not ok 23\n"}
119 truncate "Iofs.tmp", 0;
120 if (-z "Iofs.tmp") {print "ok 24\n"} else {print "not ok 24\n"}
121 open(FH, ">Iofs.tmp") or die "Can't create Iofs.tmp";
122 { select FH; $| = 1; select STDOUT }
123 print FH "helloworld\n";
126 close (FH); open (FH, ">>Iofs.tmp") or die "Can't reopen Iofs.tmp";
128 if (-s "Iofs.tmp" == 5) {print "ok 25\n"} else {print "not ok 25\n"}
131 close (FH); open (FH, ">>Iofs.tmp") or die "Can't reopen Iofs.tmp";
133 if (-z "Iofs.tmp") {print "ok 26\n"} else {print "not ok 26\n"}