X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/43b06338a7352a1850e7b7e6294bfb12026353ad..50de2b3a27dc3b906062d35ae0f9733aa106baf3:/lib/filetest.t diff --git a/lib/filetest.t b/lib/filetest.t index c206f51..98a19bd 100644 --- a/lib/filetest.t +++ b/lib/filetest.t @@ -5,6 +5,7 @@ BEGIN { @INC = '../lib'; } +use Config; use Test::More tests => 15; # these two should be kept in sync with the pragma itself @@ -55,29 +56,40 @@ SKIP: { # This works for systems with /usr/bin/chflags (i.e. BSD4.4 systems). my $chflags = "/usr/bin/chflags"; my $tstfile = "filetest.tst"; - skip("No $chflags available", 2) if !-x $chflags; - - SKIP: { - eval { - if (!-e $tstfile) { - open(T, ">$tstfile") or die "Can't create $tstfile: $!"; - close T; - } - system($chflags, "uchg", $tstfile); - die "Can't exec $chflags uchg" if $? != 0; - }; - skip("Errors in test using chflags: $@", 2) if $@; - - { - use filetest 'access'; + skip("No $chflags available", 4) if !-x $chflags; + + my $skip_eff_user_tests = (!$Config{d_setreuid} && !$Config{d_setresuid}) + || + (!$Config{d_setregid} && !$Config{d_setresgid}); + + eval { + if (!-e $tstfile) { + open(T, ">$tstfile") or die "Can't create $tstfile: $!"; + close T; + } + system($chflags, "uchg", $tstfile); + die "Can't exec $chflags uchg" if $? != 0; + }; + skip("Errors in test using chflags: $@", 4) if $@; + + { + use filetest 'access'; + SKIP: { + skip("No tests on effective user id", 1) + if $skip_eff_user_tests; is(-w $tstfile, undef, "$tstfile should not be recognized as writable"); - is(-W $tstfile, undef, "$tstfile should not be recognized as writable"); } - { - no filetest 'access'; + is(-W $tstfile, undef, "$tstfile should not be recognized as writable"); + } + + { + no filetest 'access'; + SKIP: { + skip("No tests on effective user id", 1) + if $skip_eff_user_tests; is(-w $tstfile, 1, "$tstfile should be recognized as writable"); - is(-W $tstfile, 1, "$tstfile should be recognized as writable"); } + is(-W $tstfile, 1, "$tstfile should be recognized as writable"); } # cleanup