# HG changeset patch # User Maxim Dounin # Date 1329162803 -14400 # Node ID 067b6cb4793d307467f320faf40119f59f0e8ca0 # Parent fc297a64142edf0d3dcfb36c49e32c5f65beb69b Tests: cleanup disable_symlinks tests. In particular, make it correcly skip tests if run under symbolic link. diff --git a/http_disable_symlinks.t b/http_disable_symlinks.t --- a/http_disable_symlinks.t +++ b/http_disable_symlinks.t @@ -11,6 +11,7 @@ use strict; use Test::More; use POSIX; +use Cwd qw/ realpath /; BEGIN { use FindBin; chdir($FindBin::Bin); } @@ -112,25 +113,19 @@ eval { plan(skip_all => 'no disable_symlinks') if $@; my $uid = getuid(); - -my @extfiles = ('/etc/resolv.conf', '/etc/protocols', '/etc/host.conf'); -my $extfile = undef; +my ($extfile) = grep { -f "$_" && $uid != (stat($_))[4] } + ('/etc/resolv.conf', '/etc/protocols', '/etc/host.conf'); -foreach (@extfiles) { - if (-f "$_" && $uid != (stat($_))[4]) { - $extfile = $_; - last; - } -} - -if (defined($extfile)) { - $t->plan(17); -} else { - plan(skip_all => 'external suitable object not found'); -} +plan(skip_all => 'no external file found') + if !defined $extfile; my $d = $t->testdir(); +plan(skip_all => 'cannot test under symlink') + if $d ne realpath($d); + +$t->plan(17); + mkdir("$d/on"); mkdir("$d/not_owner"); mkdir("$d/try_on"); @@ -199,15 +194,15 @@ like(http_get_host('s1', '/if_not_owner/ 'if (if_not_owner, other uid)'); like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, - 'open_file_cache (pass #1)'); + 'open_file_cache (pass 1)'); like(http_get_host('s2', '/cached-on/link'), qr!403 Forbidden!, - 'open_file_cache (pass #2)'); + 'open_file_cache (pass 2)'); like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, - 'open_file_cache (pass #3)'); + 'open_file_cache (pass 3)'); like(http_get_host('s2', '/cached-if-not-owner/link'), qr!403 Forbidden!, - 'open_file_cache (pass #4)'); + 'open_file_cache (pass 4)'); like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, - 'open_file_cache (pass #5)'); + 'open_file_cache (pass 5)'); ###############################################################################