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'; |
8 | } |
9 | |
10 | print "1..10\n"; |
11 | |
12 | print "not " unless -d 'op'; |
13 | print "ok 1\n"; |
14 | |
15 | print "not " unless -f 'TEST'; |
16 | print "ok 2\n"; |
17 | |
18 | print "not " if -f 'op'; |
19 | print "ok 3\n"; |
20 | |
21 | print "not " if -d 'TEST'; |
22 | print "ok 4\n"; |
23 | |
24 | print "not " unless -r 'TEST'; |
25 | print "ok 5\n"; |
26 | |
22c35a8c |
27 | # make sure TEST is r-x |
28 | eval { chmod 0555, 'TEST' }; |
846f25a3 |
29 | $bad_chmod = $@; |
30 | |
31 | $oldeuid = $>; # root can read and write anything |
32 | eval '$> = 1'; # so switch uid (may not be implemented) |
33 | |
34 | print "# oldeuid = $oldeuid, euid = $>\n"; |
35 | |
36 | if ($bad_chmod) { |
37 | print "#[$@]\nok 6 #skipped\n"; |
22c35a8c |
38 | } |
39 | else { |
846f25a3 |
40 | print "not " if -w 'TEST'; |
41 | print "ok 6\n"; |
22c35a8c |
42 | } |
42e55ab1 |
43 | |
846f25a3 |
44 | # Scripts are not -x everywhere so cannot test that. |
42e55ab1 |
45 | |
46 | print "not " unless -r 'op'; |
47 | print "ok 7\n"; |
48 | |
846f25a3 |
49 | eval '$> = $oldeuid'; # switch uid back (may not be implemented) |
50 | |
51 | # this would fail for the euid 1 |
52 | # (unless we have unpacked the source code as uid 1...) |
42e55ab1 |
53 | print "not " unless -w 'op'; |
54 | print "ok 8\n"; |
55 | |
56 | print "not " unless -x 'op'; # Hohum. Are directories -x everywhere? |
57 | print "ok 9\n"; |
58 | |
59 | print "not " unless "@{[grep -r, qw(foo io noo op zoo)]}" eq "io op"; |
60 | print "ok 10\n"; |