perl 3.0 patch #22 patch #19, continued
[p5sagit/p5-mst-13.2.git] / t / io.fs
CommitLineData
8d063cd8 1#!./perl
2
a687059c 3# $Header: io.fs,v 3.0 89/10/18 15:26:20 lwall Locked $
8d063cd8 4
378cc40b 5print "1..22\n";
8d063cd8 6
378cc40b 7$wd = `pwd`;
8chop($wd);
9
10`rm -f tmp 2>/dev/null; mkdir tmp 2>/dev/null`;
11chdir './tmp';
8d063cd8 12`/bin/rm -rf a b c x`;
13
14umask(022);
15
16if (umask(0) == 022) {print "ok 1\n";} else {print "not ok 1\n";}
17open(fh,'>x') || die "Can't create x";
18close(fh);
19open(fh,'>a') || die "Can't create a";
20close(fh);
21
22if (link('a','b')) {print "ok 2\n";} else {print "not ok 2\n";}
23
24if (link('b','c')) {print "ok 3\n";} else {print "not ok 3\n";}
25
26($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
27 $blksize,$blocks) = stat('c');
28
29if ($nlink == 3) {print "ok 4\n";} else {print "not ok 4\n";}
30if (($mode & 0777) == 0666) {print "ok 5\n";} else {print "not ok 5\n";}
31
32if ((chmod 0777,'a') == 1) {print "ok 6\n";} else {print "not ok 6\n";}
33
34($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
35 $blksize,$blocks) = stat('c');
36if (($mode & 0777) == 0777) {print "ok 7\n";} else {print "not ok 7\n";}
37
38if ((chmod 0700,'c','x') == 2) {print "ok 8\n";} else {print "not ok 8\n";}
39
40($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
41 $blksize,$blocks) = stat('c');
42if (($mode & 0777) == 0700) {print "ok 9\n";} else {print "not ok 9\n";}
43($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
44 $blksize,$blocks) = stat('x');
45if (($mode & 0777) == 0700) {print "ok 10\n";} else {print "not ok 10\n";}
46
47if ((unlink 'b','x') == 2) {print "ok 11\n";} else {print "not ok 11\n";}
48($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
49 $blksize,$blocks) = stat('b');
50if ($ino == 0) {print "ok 12\n";} else {print "not ok 12\n";}
51($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
52 $blksize,$blocks) = stat('x');
53if ($ino == 0) {print "ok 13\n";} else {print "not ok 13\n";}
54
55if (rename('a','b')) {print "ok 14\n";} else {print "not ok 14\n";}
56($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
57 $blksize,$blocks) = stat('a');
58if ($ino == 0) {print "ok 15\n";} else {print "not ok 15\n";}
a687059c 59$foo = (utime 500000000,500000001,'b');
378cc40b 60if ($foo == 1) {print "ok 16\n";} else {print "not ok 16 $foo\n";}
8d063cd8 61($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
62 $blksize,$blocks) = stat('b');
378cc40b 63if ($ino) {print "ok 17\n";} else {print "not ok 17\n";}
a687059c 64if ($atime == 500000000 && $mtime == 500000001)
65 {print "ok 18\n";} else {print "not ok 18 $atime $mtime\n";}
8d063cd8 66
378cc40b 67if ((unlink 'b') == 1) {print "ok 19\n";} else {print "not ok 19\n";}
8d063cd8 68($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
69 $blksize,$blocks) = stat('b');
378cc40b 70if ($ino == 0) {print "ok 20\n";} else {print "not ok 20\n";}
71unlink 'c';
72
73chdir $wd || die "Can't cd back to $wd";
74
8d063cd8 75unlink 'c';
378cc40b 76if (`ls -l perl 2>/dev/null` =~ /^l.*->/) { # we have symbolic links
77 if (symlink("TEST","c")) {print "ok 21\n";} else {print "not ok 21\n";}
78 $foo = `grep perl c`;
79 if ($foo) {print "ok 22\n";} else {print "not ok 22\n";}
80}
81else {
82 print "ok 21\nok 22\n";
83}