[shell changes from patch from perl5.003_23 to perl5.003_24]
[p5sagit/p5-mst-13.2.git] / t / io / fs.t
old mode 100644 (file)
new mode 100755 (executable)
index 705523c..dc29fda
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -1,27 +1,27 @@
 #!./perl
 
-# $Header: fs.t,v 4.0 91/03/20 01:50:55 lwall Locked $
+# $RCSfile: fs.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:28 $
 
-print "1..22\n";
+print "1..26\n";
 
 $wd = `pwd`;
 chop($wd);
 
 `rm -f tmp 2>/dev/null; mkdir tmp 2>/dev/null`;
 chdir './tmp';
-`/bin/rm -rf a b c x`;
+`/bin/rm -rf a b c x` if -x '/bin/rm';
 
 umask(022);
 
-if (umask(0) == 022) {print "ok 1\n";} else {print "not ok 1\n";}
+if ((umask(0)&0777) == 022) {print "ok 1\n";} else {print "not ok 1\n";}
 open(fh,'>x') || die "Can't create x";
 close(fh);
 open(fh,'>a') || die "Can't create a";
 close(fh);
 
-if (link('a','b')) {print "ok 2\n";} else {print "not ok 2\n";}
+if (eval {link('a','b')}) {print "ok 2\n";} else {print "not ok 2\n";}
 
-if (link('b','c')) {print "ok 3\n";} else {print "not ok 3\n";}
+if (eval {link('b','c')}) {print "ok 3\n";} else {print "not ok 3\n";}
 
 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
     $blksize,$blocks) = stat('c');
@@ -73,13 +73,39 @@ if ($ino == 0) {print "ok 20\n";} else {print "not ok 20\n";}
 unlink 'c';
 
 chdir $wd || die "Can't cd back to $wd";
+rmdir 'tmp';
 
 unlink 'c';
 if (`ls -l perl 2>/dev/null` =~ /^l.*->/) {  # we have symbolic links
     if (symlink("TEST","c")) {print "ok 21\n";} else {print "not ok 21\n";}
     $foo = `grep perl c`;
     if ($foo) {print "ok 22\n";} else {print "not ok 22\n";}
+    unlink 'c';
 }
 else {
     print "ok 21\nok 22\n";
 }
+
+# truncate (may not be implemented everywhere)
+unlink "Iofs.tmp";
+`echo helloworld > Iofs.tmp`;
+eval { truncate "Iofs.tmp", 5; };
+if ($@ =~ /not implemented/) {
+  print "# truncate not implemented -- skipping tests 23 through 26\n";
+  for (23 .. 26) {
+    print "ok $_\n";
+  }
+}
+else {
+  if (-s "Iofs.tmp" == 5) {print "ok 23\n"} else {print "not ok 23\n"}
+  truncate "Iofs.tmp", 0;
+  if (-z "Iofs.tmp") {print "ok 24\n"} else {print "not ok 24\n"}
+  `echo helloworld > Iofs.tmp`;
+  open(FH, ">Iofs.tmp") or die "Can't create Iofs.tmp";
+  truncate FH, 5;
+  if (-s "Iofs.tmp" == 5) {print "ok 25\n"} else {print "not ok 25\n"}
+  truncate FH, 0;
+  if (-z "Iofs.tmp") {print "ok 26\n"} else {print "not ok 26\n"}
+  close FH;
+}
+unlink "Iofs.tmp";