[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#809440: lintian: runtime-test-file-is-not-a-regular-file complains about a symlink to a regular test file



Control: tags -1 + patch

On Wed, 30 Dec 2015 19:14:15 +0100 =?utf-8?q?Rapha=C3=ABl_Hertzog?= <hertzog@debian.org> wrote:
> With python-django 1.9-2 I get those tags:
> I: python-django source: runtime-test-file-is-not-a-regular-file debian/tests/django-admin-py3
> I: python-django source: runtime-test-file-is-not-a-regular-file debian/tests/test-suite-py3
> 
> Both files are symlinks to another script (which is a regular file) in the
> same directory. autopkgtest works perfectly well with such test files...
> thus you should not trigger the tag in this case.
> 
> I'm using a symlink as a way to share a script to be run under two
> different environments. In my case once with Python 2 and once with Python
> 3 (as the -py3 suffix suggests).

I would like to add that I have the same problem with open-iscsi,
where I want to test the package with different init systems, so
I have the regular test (for systemd) and then a symlink with
sysvinit-$name that reboots the test environment after installing
sysvinit before executing the test.

I've attached a patch that allows for relative symlinks. I've
verified that lintian builds successfully (with the full test
suite run, including the new tags) in a clean sid chroot.

Regards,
Christian
From e456103f2dc87fe746b2019fca229e4dd5dbb9d8 Mon Sep 17 00:00:00 2001
From: Christian Seiler <christian@iwakd.de>
Date: Sun, 14 Feb 2016 03:36:43 +0100
Subject: [PATCH] Allow relative symlinks for autopkgtest tests

Relative symbolic links to autopkgtest tests should be allowed as long
as they point to regular files. This adds the following tags for
identifying problematic types of symlinks:

 - runtime-test-file-is-absolute-symlink
 - runtime-test-file-is-self-recursive-symlink
 - runtime-test-file-is-broken-symlink
 - runtime-test-file-is-symlink-to-non-regular-file

Closes: #809440
---
 checks/testsuite.desc                              | 31 +++++++++++++++++++-
 checks/testsuite.pm                                | 33 ++++++++++++++++++++++
 .../testsuite-general/debian/debian/tests/control  |  3 ++
 t/tests/testsuite-general/desc                     |  4 +++
 t/tests/testsuite-general/pre_build                | 11 +++++++-
 t/tests/testsuite-general/tags                     |  6 ++++
 6 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/checks/testsuite.desc b/checks/testsuite.desc
index 1fad72d..8582205 100644
--- a/checks/testsuite.desc
+++ b/checks/testsuite.desc
@@ -68,7 +68,36 @@ Tag: runtime-test-file-is-not-a-regular-file
 Severity: wishlist
 Certainty: certain
 Info: A runtime test listed by debian/tests/control is not a regular
- file.
+ file or a relative symbolic link to a regular file in the source
+ package.
+Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests.rst;hb=HEAD
+
+Tag: runtime-test-file-is-absolute-symlink
+Severity: wishlist
+Certainty: certain
+Info: A runtime test listed by debian/tests/control is a symbolic
+ link that points to an absolute path.
+Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests.rst;hb=HEAD
+
+Tag: runtime-test-file-is-self-recursive-symlink
+Severity: wishlist
+Certainty: certain
+Info: A runtime test listed by debian/tests/control is a symbolic
+ link that recurses onto itself.
+Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests.rst;hb=HEAD
+
+Tag: runtime-test-file-is-broken-symlink
+Severity: wishlist
+Certainty: certain
+Info: A runtime test listed by debian/tests/control is a broken
+ symbolic link.
+Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests.rst;hb=HEAD
+
+Tag: runtime-test-file-is-symlink-to-non-regular-file
+Severity: wishlist
+Certainty: certain
+Info: A runtime test listed by debian/tests/control is a symbolic
+ link that points to something other than a regular file.
 Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests.rst;hb=HEAD
 
 Tag: syntax-error-in-debian-tests-control
diff --git a/checks/testsuite.pm b/checks/testsuite.pm
index a9de939..feaeaad 100644
--- a/checks/testsuite.pm
+++ b/checks/testsuite.pm
@@ -184,6 +184,39 @@ sub check_test_file {
     if (not defined($index)) {
         tag 'missing-runtime-test-file', $path,
           'paragraph starting at line', $line;
+    } elsif ($index->is_symlink) {
+        if ($index->link =~ m{^/}) {
+            tag 'runtime-test-file-is-absolute-symlink', $path;
+        } else {
+            my $target = $index->link_normalized;
+            if ($target eq $path) {
+                tag 'runtime-test-file-is-self-recursive-symlink', $path;
+                return;
+            }
+            my $target_index = $info->index($target);
+            my %targets = ($target => 1);
+            while (defined($target_index) and $target_index->is_symlink) {
+                if ($target_index->link =~ m{^/}) {
+                    tag 'runtime-test-file-is-absolute-symlink', $path,
+                      'via', $target;
+                    return;
+                }
+                $target = $target_index->link_normalized;
+                if (defined($targets{$target})) {
+                    tag 'runtime-test-file-is-self-recursive-symlink', $path,
+                      'via', $target;
+                    return;
+                }
+                $targets{$target} = 1;
+                $target_index = $info->index($target);
+            }
+            if (not defined($target_index)) {
+                tag 'runtime-test-file-is-broken-symlink', $path, 'to',$target;
+            } elsif (not $target_index->is_regular_file) {
+                tag 'runtime-test-file-is-symlink-to-non-regular-file', $path,
+                  'to', $target;
+            }
+        }
     } elsif (not $index->is_regular_file) {
         tag 'runtime-test-file-is-not-a-regular-file', $path;
     }
diff --git a/t/tests/testsuite-general/debian/debian/tests/control b/t/tests/testsuite-general/debian/debian/tests/control
index 6348583..0fef676 100644
--- a/t/tests/testsuite-general/debian/debian/tests/control
+++ b/t/tests/testsuite-general/debian/debian/tests/control
@@ -30,3 +30,6 @@ Depends: @
 
 Tests: test-1, test-2
 Depends: @
+
+Tests: asym, asym1, self, self1, broken, lfifo, working
+Depends: @
diff --git a/t/tests/testsuite-general/desc b/t/tests/testsuite-general/desc
index c483bbf..df5e772 100644
--- a/t/tests/testsuite-general/desc
+++ b/t/tests/testsuite-general/desc
@@ -14,6 +14,10 @@ Test-For:
  missing-runtime-test-file
  missing-runtime-tests-field
  runtime-test-file-is-not-a-regular-file
+ runtime-test-file-is-absolute-symlink
+ runtime-test-file-is-self-recursive-symlink
+ runtime-test-file-is-broken-symlink
+ runtime-test-file-is-symlink-to-non-regular-file
  unknown-runtime-tests-feature
  unknown-runtime-tests-field
  unknown-runtime-tests-restriction
diff --git a/t/tests/testsuite-general/pre_build b/t/tests/testsuite-general/pre_build
index 9302e88..1043be5 100755
--- a/t/tests/testsuite-general/pre_build
+++ b/t/tests/testsuite-general/pre_build
@@ -3,4 +3,13 @@
 set -e
 
 DIR="$1"
-mkfifo "$DIR/debian/tests/fifo"
+mkfifo            "$DIR/debian/tests/fifo"
+ln -s /dev/null   "$DIR/debian/tests/asym"
+ln -s /dev/null   "$DIR/debian/tests/asym2"
+ln -s asym2       "$DIR/debian/tests/asym1"
+ln -s self        "$DIR/debian/tests/self"
+ln -s self2       "$DIR/debian/tests/self2"
+ln -s self2       "$DIR/debian/tests/self1"
+ln -s nonexistent "$DIR/debian/tests/broken"
+ln -s fifo        "$DIR/debian/tests/lfifo"
+ln -s test-1      "$DIR/debian/tests/working"
diff --git a/t/tests/testsuite-general/tags b/t/tests/testsuite-general/tags
index c537b70..15d9e59 100644
--- a/t/tests/testsuite-general/tags
+++ b/t/tests/testsuite-general/tags
@@ -1,4 +1,10 @@
+I: testsuite-general source: runtime-test-file-is-absolute-symlink debian/tests/asym
+I: testsuite-general source: runtime-test-file-is-absolute-symlink debian/tests/asym1 via debian/tests/asym2
+I: testsuite-general source: runtime-test-file-is-broken-symlink debian/tests/broken to debian/tests/nonexistent
 I: testsuite-general source: runtime-test-file-is-not-a-regular-file debian/tests/fifo
+I: testsuite-general source: runtime-test-file-is-self-recursive-symlink debian/tests/self
+I: testsuite-general source: runtime-test-file-is-self-recursive-symlink debian/tests/self1 via debian/tests/self2
+I: testsuite-general source: runtime-test-file-is-symlink-to-non-regular-file debian/tests/lfifo to debian/tests/fifo
 P: testsuite-general source: unknown-runtime-tests-feature unknownfeature paragraph starting at line 24
 P: testsuite-general source: unknown-runtime-tests-field comment paragraph starting at line 1
 P: testsuite-general source: unknown-runtime-tests-restriction unknownrestriction paragraph starting at line 24
-- 
2.1.4

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: