diff --git a/bin/tests/system/dnstap/prereq.sh b/bin/tests/system/dnstap/prereq.sh deleted file mode 100644 index 747f448982..0000000000 --- a/bin/tests/system/dnstap/prereq.sh +++ /dev/null @@ -1,20 +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 - -$FEATURETEST --enable-dnstap || { - echo_i "This test requires dnstap support." >&2 - exit 255 -} -exit 0 diff --git a/bin/tests/system/dnstap/tests_dnstap.py b/bin/tests/system/dnstap/tests_dnstap.py index 6326ef06f8..258d2b5f89 100644 --- a/bin/tests/system/dnstap/tests_dnstap.py +++ b/bin/tests/system/dnstap/tests_dnstap.py @@ -13,35 +13,38 @@ import os import re -import subprocess import isctest +import isctest.mark import pytest import dns.message pytest.importorskip("dns", minversion="2.0.0") -pytestmark = pytest.mark.extra_artifacts( - [ - "dnstap.out.*", - "ns*/dnstap.out*", - "ns2/example.db", - ] -) +pytestmark = [ + isctest.mark.with_dnstap, + pytest.mark.extra_artifacts( + [ + "dnstap.out.*", + "ns*/dnstap.out*", + "ns2/example.db", + ] + ), +] def run_rndc(server, rndc_command): """ Send the specified 'rndc_command' to 'server' with a timeout of 10 seconds """ - rndc = os.getenv("RNDC") - port = os.getenv("CONTROLPORT") + rndc = isctest.vars.ALL["RNDC"] + port = isctest.vars.ALL["CONTROLPORT"] cmdline = [rndc, "-c", "../_common/rndc.conf", "-p", port, "-s", server] cmdline.extend(rndc_command) - subprocess.check_output(cmdline, stderr=subprocess.STDOUT, timeout=10) + isctest.run.cmd(cmdline, log_stdout=True) def test_dnstap_dispatch_socket_addresses(): @@ -59,8 +62,9 @@ def test_dnstap_dispatch_socket_addresses(): os.rename(os.path.join("ns3", "dnstap.out.0"), "dnstap.out.resolver_addresses") # Read the contents of the dnstap file using dnstap-read. - output = subprocess.check_output( - [os.getenv("DNSTAPREAD"), "dnstap.out.resolver_addresses"], encoding="utf-8" + run = isctest.run.cmd( + [isctest.vars.ALL["DNSTAPREAD"], "dnstap.out.resolver_addresses"], + log_stdout=True, ) # Check whether all frames contain the expected addresses. @@ -75,7 +79,7 @@ def test_dnstap_dispatch_socket_addresses(): bad_frames = [] inspected_frames = 0 addr_regex = r"^10\.53\.0\.[0-9]+:[0-9]{1,5}$" - for line in output.splitlines(): + for line in run.stdout.decode("utf-8").splitlines(): _, _, frame_type, addr1, _, addr2, _ = line.split(" ", 6) # Only inspect RESOLVER_QUERY and RESOLVER_RESPONSE frames. if frame_type not in ("RQ", "RR"): diff --git a/bin/tests/system/dnstap/tests_sh_dnstap.py b/bin/tests/system/dnstap/tests_sh_dnstap.py index 5d4d7a9e9e..10d9a4111b 100644 --- a/bin/tests/system/dnstap/tests_sh_dnstap.py +++ b/bin/tests/system/dnstap/tests_sh_dnstap.py @@ -11,19 +11,24 @@ import pytest -pytestmark = pytest.mark.extra_artifacts( - [ - "dig.out*", - "dnstap.hex*", - "dnstap.out*", - "fstrm_capture.out.*", - "nsupdate.out*", - "ydump.out*", - "ns*/dnstap.out*", - "ns2/example.db", - "ns2/example.db.jnl", - ] -) +import isctest.mark + +pytestmark = [ + isctest.mark.with_dnstap, + pytest.mark.extra_artifacts( + [ + "dig.out*", + "dnstap.hex*", + "dnstap.out*", + "fstrm_capture.out.*", + "nsupdate.out*", + "ydump.out*", + "ns*/dnstap.out*", + "ns2/example.db", + "ns2/example.db.jnl", + ] + ), +] def test_dnstap(run_tests_sh): diff --git a/bin/tests/system/isctest/mark.py b/bin/tests/system/isctest/mark.py index 9b193c8fe5..3bd1e6816e 100644 --- a/bin/tests/system/isctest/mark.py +++ b/bin/tests/system/isctest/mark.py @@ -34,10 +34,6 @@ def feature_test(feature): return True -def with_dnstap(*args): # pylint: disable=unused-argument - return feature_test("--enable-dnstap") - - def with_tsan(*args): # pylint: disable=unused-argument return feature_test("--tsan") @@ -48,6 +44,11 @@ def with_algorithm(name: str): return pytest.mark.skipif(os.getenv(key) != "1", reason=f"{name} is not supported") +with_dnstap = pytest.mark.skipif( + not feature_test("--enable-dnstap"), reason="DNSTAP support disabled in the build" +) + + without_fips = pytest.mark.skipif( feature_test("--have-fips-mode"), reason="FIPS support enabled in the build" )