Bug#705242: libtest-file-perl: symlink_target_{exists, dangles}_ok incorrectly fail on relative symlinks if they're not in the current directory
Axel Beckert
abe at debian.org
Thu Apr 11 19:41:43 UTC 2013
Package: libtest-file-perl
Version: 1.29-1
Version: 1.34-1
Severity: normal
Tags: upstream
The symlink_target_exists_ok and symlink_target_dangles_ok tests
errornously fail if the symlink to test is a relative one and not based
in the current directory.
Example script which fails but shouldn't:
---snip---
#!/usr/bin/perl
use strict;
use Test::File;
use File::Path qw(mkpath);
chdir('/tmp');
mkpath('foo/bar/fnord', {});
my $rc = symlink('fnord', 'foo/bar/blafasel');
my $pwd = `pwd -P`;
chomp($pwd);
print "RC=$rc; CWD=$pwd\n";
system('ls -ld foo/bar/*');
symlink_target_exists_ok( 'foo/bar/blafasel' );
---snap---
Output here:
RC=0; CWD=/tmp
lrwxrwxrwx 1 abe abe 5 Apr 11 21:21 foo/bar/blafasel -> fnord
drwxr-xr-x 2 abe abe 4096 Apr 11 21:16 foo/bar/fnord
# Symlink [foo/bar/blafasel] points to non-existent target [fnord]!
not ok 1 - foo/bar/blafasel is a symlink
# Failed test 'foo/bar/blafasel is a symlink'
# at /tmp/testfile.pl line 14.
# Tests were run but no plan was declared and done_testing() was not seen.
In the source code of symlink_target_exists_ok there is nothing which
takes care about links being relative to their parent directory. The
link target is taken as relative to the current directory instead of the
symlink's parent directory:
[...]
my $dest = shift || readlink( $file );
[...]
unless( -e $dest ) {
[...]
symlink_target_dangles_ok has the same bug, too:
[...]
my $dest = readlink( $file );
[...]
if( -e $dest ) {
[...]
The bug is present in at least Debian Squeeze (1.29-1) and Debian
Wheezy/Sid (1.34-1).
-- System Information:
Debian Release: 6.0.7
APT prefers stable
APT policy: (990, 'stable'), (500, 'stable-updates'), (101, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-xen-amd64 (SMP w/6 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages libtest-file-perl depends on:
ii perl 5.10.1-17squeeze6 Larry Wall's Practical Extraction
libtest-file-perl recommends no packages.
libtest-file-perl suggests no packages.
-- no debconf information
More information about the pkg-perl-maintainers
mailing list