]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Port dnstap test to use isctest utilities
authorPetr Špaček <pspacek@isc.org>
Fri, 23 May 2025 15:27:02 +0000 (17:27 +0200)
committerPetr Špaček <pspacek@isc.org>
Wed, 28 May 2025 10:45:32 +0000 (10:45 +0000)
bin/tests/system/dnstap/tests_dnstap.py

index 6326ef06f877de1519f720f14a184b1ebc70fe92..a5ff505c0f7779be0d4afb321ac09cfb44906ac3 100644 (file)
@@ -13,7 +13,6 @@
 
 import os
 import re
-import subprocess
 
 import isctest
 import pytest
@@ -35,13 +34,13 @@ 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 +58,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 +75,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"):