Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
79072805 |
3 | # $RCSfile: fs.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:28 $ |
8d063cd8 |
4 | |
ea368a7c |
5 | BEGIN { |
6 | chdir 't' if -d 't'; |
7 | @INC = '../lib'; |
8 | } |
9 | |
10 | use Config; |
11 | |
f783569b |
12 | print "1..26\n"; |
8d063cd8 |
13 | |
378cc40b |
14 | $wd = `pwd`; |
15 | chop($wd); |
16 | |
17 | `rm -f tmp 2>/dev/null; mkdir tmp 2>/dev/null`; |
18 | chdir './tmp'; |
b8440792 |
19 | `/bin/rm -rf a b c x` if -x '/bin/rm'; |
8d063cd8 |
20 | |
21 | umask(022); |
22 | |
e334a159 |
23 | if ((umask(0)&0777) == 022) {print "ok 1\n";} else {print "not ok 1\n";} |
8d063cd8 |
24 | open(fh,'>x') || die "Can't create x"; |
25 | close(fh); |
26 | open(fh,'>a') || die "Can't create a"; |
27 | close(fh); |
28 | |
b8440792 |
29 | if (eval {link('a','b')}) {print "ok 2\n";} else {print "not ok 2\n";} |
8d063cd8 |
30 | |
b8440792 |
31 | if (eval {link('b','c')}) {print "ok 3\n";} else {print "not ok 3\n";} |
8d063cd8 |
32 | |
33 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
34 | $blksize,$blocks) = stat('c'); |
35 | |
ea368a7c |
36 | if ($Config{dont_use_nlink} || $nlink == 3) |
37 | {print "ok 4\n";} else {print "not ok 4\n";} |
38 | |
b971f6e4 |
39 | if (($mode & 0777) == 0666 || $^O eq 'amigaos') |
40 | {print "ok 5\n";} else {print "not ok 5\n";} |
8d063cd8 |
41 | |
42 | if ((chmod 0777,'a') == 1) {print "ok 6\n";} else {print "not ok 6\n";} |
43 | |
44 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
45 | $blksize,$blocks) = stat('c'); |
46 | if (($mode & 0777) == 0777) {print "ok 7\n";} else {print "not ok 7\n";} |
47 | |
48 | if ((chmod 0700,'c','x') == 2) {print "ok 8\n";} else {print "not ok 8\n";} |
49 | |
50 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
51 | $blksize,$blocks) = stat('c'); |
52 | if (($mode & 0777) == 0700) {print "ok 9\n";} else {print "not ok 9\n";} |
53 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
54 | $blksize,$blocks) = stat('x'); |
55 | if (($mode & 0777) == 0700) {print "ok 10\n";} else {print "not ok 10\n";} |
56 | |
57 | if ((unlink 'b','x') == 2) {print "ok 11\n";} else {print "not ok 11\n";} |
58 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
59 | $blksize,$blocks) = stat('b'); |
60 | if ($ino == 0) {print "ok 12\n";} else {print "not ok 12\n";} |
61 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
62 | $blksize,$blocks) = stat('x'); |
63 | if ($ino == 0) {print "ok 13\n";} else {print "not ok 13\n";} |
64 | |
65 | if (rename('a','b')) {print "ok 14\n";} else {print "not ok 14\n";} |
66 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
67 | $blksize,$blocks) = stat('a'); |
68 | if ($ino == 0) {print "ok 15\n";} else {print "not ok 15\n";} |
a687059c |
69 | $foo = (utime 500000000,500000001,'b'); |
378cc40b |
70 | if ($foo == 1) {print "ok 16\n";} else {print "not ok 16 $foo\n";} |
8d063cd8 |
71 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
72 | $blksize,$blocks) = stat('b'); |
378cc40b |
73 | if ($ino) {print "ok 17\n";} else {print "not ok 17\n";} |
b971f6e4 |
74 | if (($atime == 500000000 && $mtime == 500000001) |
75 | || $wd =~ m#/afs/# || $^O eq 'amigaos') |
6eb13c3b |
76 | {print "ok 18\n";} |
77 | else |
78 | {print "not ok 18 $atime $mtime\n";} |
8d063cd8 |
79 | |
378cc40b |
80 | if ((unlink 'b') == 1) {print "ok 19\n";} else {print "not ok 19\n";} |
8d063cd8 |
81 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, |
82 | $blksize,$blocks) = stat('b'); |
378cc40b |
83 | if ($ino == 0) {print "ok 20\n";} else {print "not ok 20\n";} |
84 | unlink 'c'; |
85 | |
86 | chdir $wd || die "Can't cd back to $wd"; |
44a8e56a |
87 | rmdir 'tmp'; |
378cc40b |
88 | |
8d063cd8 |
89 | unlink 'c'; |
378cc40b |
90 | if (`ls -l perl 2>/dev/null` =~ /^l.*->/) { # we have symbolic links |
91 | if (symlink("TEST","c")) {print "ok 21\n";} else {print "not ok 21\n";} |
92 | $foo = `grep perl c`; |
93 | if ($foo) {print "ok 22\n";} else {print "not ok 22\n";} |
44a8e56a |
94 | unlink 'c'; |
378cc40b |
95 | } |
96 | else { |
97 | print "ok 21\nok 22\n"; |
98 | } |
f783569b |
99 | |
100 | # truncate (may not be implemented everywhere) |
101 | unlink "Iofs.tmp"; |
102 | `echo helloworld > Iofs.tmp`; |
103 | eval { truncate "Iofs.tmp", 5; }; |
104 | if ($@ =~ /not implemented/) { |
105 | print "# truncate not implemented -- skipping tests 23 through 26\n"; |
106 | for (23 .. 26) { |
107 | print "ok $_\n"; |
108 | } |
109 | } |
110 | else { |
111 | if (-s "Iofs.tmp" == 5) {print "ok 23\n"} else {print "not ok 23\n"} |
112 | truncate "Iofs.tmp", 0; |
113 | if (-z "Iofs.tmp") {print "ok 24\n"} else {print "not ok 24\n"} |
114 | `echo helloworld > Iofs.tmp`; |
115 | open(FH, ">Iofs.tmp") or die "Can't create Iofs.tmp"; |
116 | truncate FH, 5; |
117 | if (-s "Iofs.tmp" == 5) {print "ok 25\n"} else {print "not ok 25\n"} |
118 | truncate FH, 0; |
119 | if (-z "Iofs.tmp") {print "ok 26\n"} else {print "not ok 26\n"} |
120 | close FH; |
121 | } |
122 | unlink "Iofs.tmp"; |