From: Nicki Křížek Date: Tue, 30 Jun 2026 14:53:10 +0000 (+0000) Subject: Move Perl-module prereq.sh checks to pytest markers X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=8ba4fb846012f0766bbb8887867640e499eaa1b7;p=thirdparty%2Fbind9.git Move Perl-module prereq.sh checks to pytest markers 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 --- diff --git a/bin/tests/system/fetchlimit/prereq.sh b/bin/tests/system/fetchlimit/prereq.sh deleted file mode 100644 index c52be9c97a9..00000000000 --- a/bin/tests/system/fetchlimit/prereq.sh +++ /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 diff --git a/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py b/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py index dd1dcb0762d..49133cab9e9 100644 --- a/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py +++ b/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py @@ -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() diff --git a/bin/tests/system/isctest/mark.py b/bin/tests/system/isctest/mark.py index ac3984a58ac..fd9e2233701 100644 --- a/bin/tests/system/isctest/mark.py +++ b/bin/tests/system/isctest/mark.py @@ -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 index c52be9c97a9..00000000000 --- a/bin/tests/system/nsupdate/prereq.sh +++ /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 diff --git a/bin/tests/system/nsupdate/tests_sh_nsupdate.py b/bin/tests/system/nsupdate/tests_sh_nsupdate.py index 2812b86b881..0765a90d718 100644 --- a/bin/tests/system/nsupdate/tests_sh_nsupdate.py +++ b/bin/tests/system/nsupdate/tests_sh_nsupdate.py @@ -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 index 0d6e2b45d41..00000000000 --- a/bin/tests/system/reclimit/prereq.sh +++ /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 diff --git a/bin/tests/system/reclimit/tests_sh_reclimit.py b/bin/tests/system/reclimit/tests_sh_reclimit.py index d22d10a5238..3d88c511fe5 100644 --- a/bin/tests/system/reclimit/tests_sh_reclimit.py +++ b/bin/tests/system/reclimit/tests_sh_reclimit.py @@ -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 index 7411c8afb62..00000000000 --- a/bin/tests/system/serve_stale/prereq.sh +++ /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 diff --git a/bin/tests/system/serve_stale/tests_sh_serve_stale.py b/bin/tests/system/serve_stale/tests_sh_serve_stale.py index b7bb320a5e2..754f537cc49 100644 --- a/bin/tests/system/serve_stale/tests_sh_serve_stale.py +++ b/bin/tests/system/serve_stale/tests_sh_serve_stale.py @@ -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):