Commit | Line | Data |
42e55ab1 |
1 | #!./perl |
2 | |
3 | # There are few filetest operators that are portable enough to test. |
4 | # See pod/perlport.pod for details. |
5 | |
6 | BEGIN { |
7 | chdir 't' if -d 't'; |
20822f61 |
8 | @INC = '../lib'; |
42e55ab1 |
9 | } |
10 | |
eb57363f |
11 | use Config; |
42e55ab1 |
12 | print "1..10\n"; |
13 | |
14 | print "not " unless -d 'op'; |
15 | print "ok 1\n"; |
16 | |
17 | print "not " unless -f 'TEST'; |
18 | print "ok 2\n"; |
19 | |
20 | print "not " if -f 'op'; |
21 | print "ok 3\n"; |
22 | |
23 | print "not " if -d 'TEST'; |
24 | print "ok 4\n"; |
25 | |
26 | print "not " unless -r 'TEST'; |
27 | print "ok 5\n"; |
28 | |
22c35a8c |
29 | # make sure TEST is r-x |
30 | eval { chmod 0555, 'TEST' }; |
846f25a3 |
31 | $bad_chmod = $@; |
32 | |
33 | $oldeuid = $>; # root can read and write anything |
34 | eval '$> = 1'; # so switch uid (may not be implemented) |
35 | |
36 | print "# oldeuid = $oldeuid, euid = $>\n"; |
37 | |
644a2880 |
38 | if (!$Config{d_seteuid}) { |
39 | print "ok 6 #skipped, no seteuid\n"; |
235effa7 |
40 | } |
41 | elsif ($Config{config_args} =~/Dmksymlinks/) { |
42 | print "ok 6 #skipped, we cannot chmod symlinks\n"; |
644a2880 |
43 | } |
44 | elsif ($bad_chmod) { |
846f25a3 |
45 | print "#[$@]\nok 6 #skipped\n"; |
22c35a8c |
46 | } |
47 | else { |
846f25a3 |
48 | print "not " if -w 'TEST'; |
49 | print "ok 6\n"; |
22c35a8c |
50 | } |
42e55ab1 |
51 | |
846f25a3 |
52 | # Scripts are not -x everywhere so cannot test that. |
42e55ab1 |
53 | |
fd1e013e |
54 | eval '$> = $oldeuid'; # switch uid back (may not be implemented) |
55 | |
56 | # this would fail for the euid 1 |
57 | # (unless we have unpacked the source code as uid 1...) |
42e55ab1 |
58 | print "not " unless -r 'op'; |
59 | print "ok 7\n"; |
60 | |
846f25a3 |
61 | # this would fail for the euid 1 |
62 | # (unless we have unpacked the source code as uid 1...) |
3eeba6fb |
63 | if ($Config{d_seteuid}) { |
64 | print "not " unless -w 'op'; |
65 | print "ok 8\n"; |
66 | } else { |
67 | print "ok 8 #skipped, no seteuid\n"; |
68 | } |
42e55ab1 |
69 | |
70 | print "not " unless -x 'op'; # Hohum. Are directories -x everywhere? |
71 | print "ok 9\n"; |
72 | |
73 | print "not " unless "@{[grep -r, qw(foo io noo op zoo)]}" eq "io op"; |
74 | print "ok 10\n"; |