]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move Perl-module prereq.sh checks to pytest markers
authorNicki Křížek <nicki@isc.org>
Tue, 30 Jun 2026 14:53:10 +0000 (14:53 +0000)
committerNicki Křížek <nicki@isc.org>
Fri, 10 Jul 2026 11:17:41 +0000 (13:17 +0200)
fetchlimit and nsupdate still invoke ungated Perl helpers that
need Net::DNS (ditch.pl, packet.pl); reclimit and serve_stale
still run Perl ans.pl servers needing Net::DNS::Nameserver and
Time::HiRes. Replace the directory-scoped prereq.sh with new
runtime-probing markers applied only to the tests.sh wrappers
that actually run the Perl code -- native pytest modules in the
same directory (e.g. nsupdate) no longer skip when these modules
are absent.

Assisted-by: Claude:claude-opus-4-8
bin/tests/system/fetchlimit/prereq.sh [deleted file]
bin/tests/system/fetchlimit/tests_sh_fetchlimit.py
bin/tests/system/isctest/mark.py
bin/tests/system/nsupdate/prereq.sh [deleted file]
bin/tests/system/nsupdate/tests_sh_nsupdate.py
bin/tests/system/reclimit/prereq.sh [deleted file]
bin/tests/system/reclimit/tests_sh_reclimit.py
bin/tests/system/serve_stale/prereq.sh [deleted file]
bin/tests/system/serve_stale/tests_sh_serve_stale.py

diff --git a/bin/tests/system/fetchlimit/prereq.sh b/bin/tests/system/fetchlimit/prereq.sh
deleted file mode 100644 (file)
index c52be9c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# SPDX-License-Identifier: MPL-2.0
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0.  If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-. ../conf.sh
-
-if ! ${PERL} -MNet::DNS -e ''; then
-  echo_i "perl Net::DNS module is required"
-  exit 1
-fi
-
-exit 0
index dd1dcb0762d346d365b0b996771dd87d64921baa..49133cab9e91da8bc1e66cabec5263b9d89f3834 100644 (file)
@@ -11,7 +11,9 @@
 
 import pytest
 
-pytestmark = pytest.mark.extra_artifacts(
+import isctest.mark
+
+EXTRA_ARTIFACTS = pytest.mark.extra_artifacts(
     [
         "dig.out.*",
         "wait_for_message.*",
@@ -22,6 +24,11 @@ pytestmark = pytest.mark.extra_artifacts(
     ]
 )
 
+pytestmark = [
+    isctest.mark.requires_net_dns,
+    EXTRA_ARTIFACTS,
+]
+
 
 def test_fetchlimit(run_tests_sh):
     run_tests_sh()
index ac3984a58ac0ff7e4ee0b5395a4c11744356270b..fd9e22337019e628786d02d47e11ea873a4d6288 100644 (file)
@@ -15,6 +15,7 @@ import os
 import platform
 import shutil
 import socket
+import subprocess
 
 import pytest
 
@@ -39,6 +40,36 @@ extended_ds_digest = pytest.mark.skipif(
 )
 
 
+def _perl_module_available(module: str) -> bool:
+    perl = os.environ.get("PERL", "perl")
+    try:
+        subprocess.run(
+            [perl, f"-M{module}", "-e", ""],
+            check=True,
+            stdout=subprocess.DEVNULL,
+            stderr=subprocess.DEVNULL,
+        )
+    except (subprocess.CalledProcessError, FileNotFoundError):
+        return False
+    return True
+
+
+requires_net_dns = pytest.mark.skipif(
+    not _perl_module_available("Net::DNS"),
+    reason="Perl Net::DNS module is required",
+)
+
+requires_net_dns_nameserver = pytest.mark.skipif(
+    not _perl_module_available("Net::DNS::Nameserver"),
+    reason="Perl Net::DNS::Nameserver module is required",
+)
+
+requires_time_hires = pytest.mark.skipif(
+    not _perl_module_available("Time::HiRes"),
+    reason="Perl Time::HiRes module is required",
+)
+
+
 def is_host_freebsd(*_):
     return platform.system() == "FreeBSD"
 
diff --git a/bin/tests/system/nsupdate/prereq.sh b/bin/tests/system/nsupdate/prereq.sh
deleted file mode 100644 (file)
index c52be9c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# SPDX-License-Identifier: MPL-2.0
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0.  If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-. ../conf.sh
-
-if ! ${PERL} -MNet::DNS -e ''; then
-  echo_i "perl Net::DNS module is required"
-  exit 1
-fi
-
-exit 0
index 2812b86b881b0aeed0f5f6c82671a52a581f956e..0765a90d718f4b296aafe1ec8454efaaa2edc5af 100644 (file)
@@ -13,7 +13,9 @@ import platform
 
 import pytest
 
-pytestmark = pytest.mark.extra_artifacts(
+import isctest.mark
+
+EXTRA_ARTIFACTS = pytest.mark.extra_artifacts(
     [
         "Kxxx*",
         "dig.out.*",
@@ -77,6 +79,11 @@ pytestmark = pytest.mark.extra_artifacts(
     ]
 )
 
+pytestmark = [
+    isctest.mark.requires_net_dns,
+    EXTRA_ARTIFACTS,
+]
+
 
 MAX_RUNS = 2 if platform.system() == "FreeBSD" else 1  # GL#3846
 
diff --git a/bin/tests/system/reclimit/prereq.sh b/bin/tests/system/reclimit/prereq.sh
deleted file mode 100644 (file)
index 0d6e2b4..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# SPDX-License-Identifier: MPL-2.0
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0.  If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-. ../conf.sh
-
-if ! ${PERL} -MNet::DNS -e ''; then
-  echo_i "perl Net::DNS module is required"
-  exit 1
-fi
-
-if ! ${PERL} -MNet::DNS::Nameserver -e ''; then
-  echo_i "perl Net::DNS::Nameserver module is required"
-  exit 1
-fi
-
-exit 0
index d22d10a523809f2ed4df1961ad47df6262318b5e..3d88c511fe5a0c23bbaf16ae56bb2c59dc06cf20 100644 (file)
@@ -11,7 +11,9 @@
 
 import pytest
 
-pytestmark = pytest.mark.extra_artifacts(
+import isctest.mark
+
+EXTRA_ARTIFACTS = pytest.mark.extra_artifacts(
     [
         "dig.out.*",
         "dsset-signed.",
@@ -23,6 +25,12 @@ pytestmark = pytest.mark.extra_artifacts(
     ]
 )
 
+pytestmark = [
+    isctest.mark.requires_net_dns,
+    isctest.mark.requires_net_dns_nameserver,
+    EXTRA_ARTIFACTS,
+]
+
 
 # The reclimit is known to be quite unstable. GL #1587
 @pytest.mark.flaky(max_runs=2)
diff --git a/bin/tests/system/serve_stale/prereq.sh b/bin/tests/system/serve_stale/prereq.sh
deleted file mode 100644 (file)
index 7411c8a..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# SPDX-License-Identifier: MPL-2.0
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0.  If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-. ../conf.sh
-
-if ! ${PERL} -MTime::HiRes -e ''; then
-  echo_i "perl Time::HiRes module is required"
-  exit 1
-fi
-
-exit 0
index b7bb320a5e27fc2b48fe1c84fcff4cc614ce1e17..754f537cc4955b34c7aa4804577b7d35371bd842 100644 (file)
@@ -11,7 +11,9 @@
 
 import pytest
 
-pytestmark = pytest.mark.extra_artifacts(
+import isctest.mark
+
+EXTRA_ARTIFACTS = pytest.mark.extra_artifacts(
     [
         "dig.out.*",
         "expired.test*",
@@ -26,6 +28,12 @@ pytestmark = pytest.mark.extra_artifacts(
     ]
 )
 
+pytestmark = [
+    isctest.mark.requires_net_dns,
+    isctest.mark.requires_time_hires,
+    EXTRA_ARTIFACTS,
+]
+
 
 @pytest.mark.flaky(max_runs=2)
 def test_serve_stale(run_tests_sh):