summaryrefslogtreecommitdiffstats
path: root/t/dh_link
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:15:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:15:44 +0000
commit1a42a93b11c48e696446250f2a1f1ca71b350e9b (patch)
tree900e3702d59f6d7cae8f7def94ed5194602f6846 /t/dh_link
parentInitial commit. (diff)
downloaddebhelper-1a42a93b11c48e696446250f2a1f1ca71b350e9b.tar.xz
debhelper-1a42a93b11c48e696446250f2a1f1ca71b350e9b.zip
Adding upstream version 13.3.4.upstream/13.3.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/dh_link')
-rwxr-xr-xt/dh_link/01-basic.t50
-rwxr-xr-xt/dh_link/02-346405.t29
-rwxr-xr-xt/dh_link/03-894229.t55
3 files changed, 134 insertions, 0 deletions
diff --git a/t/dh_link/01-basic.t b/t/dh_link/01-basic.t
new file mode 100755
index 0000000..88c8e49
--- /dev/null
+++ b/t/dh_link/01-basic.t
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+plan(tests => 1);
+
+use File::Path qw(remove_tree);
+use File::Basename qw(dirname);
+use lib dirname(dirname(__FILE__));
+use Test::DH;
+
+each_compat_subtest {
+
+ remove_tree('debian/debhelper');
+
+ # It used to not make absolute links in this situation, and it should.
+ # #37774
+ ok(run_dh_tool('dh_link', 'etc/foo', 'usr/lib/bar'));
+ ok(readlink("debian/debhelper/usr/lib/bar"), "/etc/foo");
+
+
+ # let's make sure it makes simple relative links ok.
+ ok(run_dh_tool('dh_link', 'usr/bin/foo', 'usr/bin/bar'));
+ ok(readlink("debian/debhelper/usr/bin/bar"), "foo");
+ ok(run_dh_tool('dh_link', 'sbin/foo', 'sbin/bar'));
+ ok(readlink("debian/debhelper/sbin/bar"), "foo");
+
+ # ok, more complex relative links.
+ ok(run_dh_tool('dh_link', 'usr/lib/1', 'usr/bin/2'));
+ ok(readlink("debian/debhelper/usr/bin/2"),"../lib/1");
+
+ # Check conversion of relative symlink to different top-level directory
+ # into absolute symlink. (#244157)
+ system("mkdir -p debian/debhelper/usr/lib; mkdir -p debian/debhelper/lib; touch debian/debhelper/lib/libm.so; cd debian/debhelper/usr/lib; ln -sf ../../lib/libm.so");
+ ok(run_dh_tool('dh_link'));
+ ok(readlink("debian/debhelper/usr/lib/libm.so"), "/lib/libm.so");
+
+ # Link to self.
+ ok(run_dh_tool({ 'quiet' => 1 }, 'dh_link', 'usr/lib/foo', 'usr/lib/foo'));
+ ok(! -l "debian/debhelper/usr/lib/foo");
+
+ # Make sure the link conversion didn't change any of the
+ # previously made links.
+ ok(readlink("debian/debhelper/usr/lib/bar"), "/etc/foo");
+ ok(readlink("debian/debhelper/usr/bin/bar"), "foo");
+ ok(readlink("debian/debhelper/usr/bin/2"),"../lib/1");
+};
+
diff --git a/t/dh_link/02-346405.t b/t/dh_link/02-346405.t
new file mode 100755
index 0000000..95053ca
--- /dev/null
+++ b/t/dh_link/02-346405.t
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+plan(tests => 1);
+
+use File::Path qw(remove_tree);
+use File::Basename qw(dirname);
+use lib dirname(dirname(__FILE__));
+use Test::DH;
+
+each_compat_subtest {
+
+ remove_tree('debian/debhelper');
+
+ # Check links to the current directory and below, they used to be
+ # unnecessarily long (#346405).
+ ok(run_dh_tool('dh_link', 'usr/lib/geant4', 'usr/lib/geant4/a'));
+ ok(readlink("debian/debhelper/usr/lib/geant4/a"), ".");
+ ok(run_dh_tool('dh_link', 'usr/lib', 'usr/lib/geant4/b'));
+ ok(readlink("debian/debhelper/usr/lib/geant4/b"), "..");
+ ok(run_dh_tool('dh_link', 'usr', 'usr/lib/geant4/c'));
+ ok(readlink("debian/debhelper/usr/lib/geant4/c"), "../..");
+ ok(run_dh_tool('dh_link', '/', 'usr/lib/geant4/d'));
+ ok(readlink("debian/debhelper/usr/lib/geant4/d"), "/");
+};
+
diff --git a/t/dh_link/03-894229.t b/t/dh_link/03-894229.t
new file mode 100755
index 0000000..10542f4
--- /dev/null
+++ b/t/dh_link/03-894229.t
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+plan(tests => 1);
+
+use File::Path qw(remove_tree);
+use File::Basename qw(dirname);
+use lib dirname(dirname(__FILE__));
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+use Test::DH;
+
+
+sub test_tricky {
+ my ($link_name, $denoted_dest, $expected_link_target) = @_;
+ my $tmpdir = 'debian/debhelper';
+ my $link_path = "${tmpdir}/${link_name}";
+
+ make_symlink($link_name, $denoted_dest, $tmpdir);
+ if (ok(-l $link_path, 'Link made in correct directory')) {
+ my $target = readlink($link_path);
+ is($target, $expected_link_target, 'Link points correctly')
+ or diag("Expected ${expected_link_target}, actual ${target}");
+ rm_files($link_path);
+ }
+ return;
+}
+
+sub test_invalid {
+ my ($link_name, $denoted_dest) = @_;
+ eval {
+ make_symlink($link_name, $denoted_dest);
+ };
+ like($@, qr{^(?:\S*:(?: error:)?\s*)?Invalid destination/link name});
+}
+
+each_compat_subtest {
+
+ remove_tree('debian/debhelper/a/b/c');
+
+ install_dir('debian/debhelper/a/b/c');
+
+ test_invalid('../../wow', 'a');
+ # This is a can be made valid but at the moment we do not support
+ # it.
+ test_invalid('a/b/../link21', 'a');
+
+
+ test_tricky('//a/b/link03', 'a/b/c', 'c');
+ test_tricky('./a/link18', 'a', '.');
+ test_tricky('a/./b/link19', 'a/b', '.');
+};
+