This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Track SVs for destruction when -DPURIFY
[perl5.git] / t / io / fs.t
CommitLineData
8d063cd8
LW
1#!./perl
2
79072805 3# $RCSfile: fs.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:28 $
8d063cd8 4
378cc40b 5print "1..22\n";
8d063cd8 6
378cc40b
LW
7$wd = `pwd`;
8chop($wd);
9
10`rm -f tmp 2>/dev/null; mkdir tmp 2>/dev/null`;
11chdir './tmp';
b8440792 12`/bin/rm -rf a b c x` if -x '/bin/rm';
8d063cd8
LW
13
14umask(022);
15
e334a159 16if ((umask(0)&0777) == 022) {print "ok 1\n";} else {print "not ok 1\n";}
8d063cd8
LW
17open(fh,'>x') || die "Can't create x";
18close(fh);
19open(fh,'>a') || die "Can't create a";
20close(fh);
21
b8440792 22if (eval {link('a','b')}) {print "ok 2\n";} else {print "not ok 2\n";}
8d063cd8 23
b8440792 24if (eval {link('b','c')}) {print "ok 3\n";} else {print "not ok 3\n";}
8d063cd8
LW
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
LW
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";}
6eb13c3b
LW
64if (($atime == 500000000 && $mtime == 500000001) || $wd =~ m#/afs/#)
65 {print "ok 18\n";}
66else
67 {print "not ok 18 $atime $mtime\n";}
8d063cd8 68
378cc40b 69if ((unlink 'b') == 1) {print "ok 19\n";} else {print "not ok 19\n";}
8d063cd8
LW
70($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
71 $blksize,$blocks) = stat('b');
378cc40b
LW
72if ($ino == 0) {print "ok 20\n";} else {print "not ok 20\n";}
73unlink 'c';
74
75chdir $wd || die "Can't cd back to $wd";
76
8d063cd8 77unlink 'c';
378cc40b
LW
78if (`ls -l perl 2>/dev/null` =~ /^l.*->/) { # we have symbolic links
79 if (symlink("TEST","c")) {print "ok 21\n";} else {print "not ok 21\n";}
80 $foo = `grep perl c`;
81 if ($foo) {print "ok 22\n";} else {print "not ok 22\n";}
82}
83else {
84 print "ok 21\nok 22\n";
85}