]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add FEATURE_* environment variables to system tests
authorNicki Křížek <nicki@isc.org>
Tue, 2 Dec 2025 16:37:31 +0000 (17:37 +0100)
committerNicki Křížek <nicki@isc.org>
Mon, 8 Dec 2025 17:07:41 +0000 (18:07 +0100)
The purpose of these variables is to be able to detect feature support
without calling feature-test. This becomes useful when detecting feature
support in jinja2 templates.

bin/tests/system/isctest/mark.py
bin/tests/system/isctest/vars/__init__.py
bin/tests/system/isctest/vars/all.py
bin/tests/system/isctest/vars/features.py [new file with mode: 0644]

index e1b97f8f840f38bdc3ea12d44d66355e92b722c6..df3b1e540bc962aeb8781157c60cb3cdbc314d00 100644 (file)
@@ -15,7 +15,6 @@ import os
 import platform
 import socket
 import shutil
-import subprocess
 
 import pytest
 
@@ -29,24 +28,13 @@ live_internet_test = pytest.mark.skipif(
 )
 
 
-def feature_test(feature):
-    feature_test_bin = os.environ.get("FEATURETEST")
-    if not feature_test_bin:  # this can be the case when running doctest
-        return False
-    try:
-        subprocess.run([feature_test_bin, feature], check=True)
-    except subprocess.CalledProcessError as exc:
-        if exc.returncode != 1:
-            raise
-        return False
-    return True
-
-
-rsasha1 = pytest.mark.skipif(not feature_test("--rsasha1"), reason="RSASHA1 disabled")
+rsasha1 = pytest.mark.skipif(
+    os.getenv("FEATURE_RSASHA1") != "1", reason="RSASHA1 disabled"
+)
 
 
 extended_ds_digest = pytest.mark.skipif(
-    not feature_test("--extended-ds-digest"),
+    os.getenv("FEATURE_EXTENDED_DS_DIGEST") != "1",
     reason="extended DS digest algorithms disabled",
 )
 
@@ -62,24 +50,24 @@ def with_algorithm(name: str):
 
 
 with_dnstap = pytest.mark.skipif(
-    not feature_test("--enable-dnstap"), reason="DNSTAP support disabled in the build"
+    os.getenv("FEATURE_DNSTAP") != "1", reason="DNSTAP support disabled in the build"
 )
 
 
 without_fips = pytest.mark.skipif(
-    feature_test("--have-fips-mode"), reason="FIPS support enabled in the build"
+    os.getenv("FEATURE_FIPS_MODE") == "1", reason="FIPS support enabled in the build"
 )
 
 with_libxml2 = pytest.mark.skipif(
-    not feature_test("--have-libxml2"), reason="libxml2 support disabled in the build"
+    os.getenv("FEATURE_LIBXML2") != "1", reason="libxml2 support disabled in the build"
 )
 
 with_lmdb = pytest.mark.skipif(
-    not feature_test("--with-lmdb"), reason="LMDB support disabled in the build"
+    os.getenv("FEATURE_LMDB") != "1", reason="LMDB support disabled in the build"
 )
 
 with_json_c = pytest.mark.skipif(
-    not feature_test("--have-json-c"), reason="json-c support disabled in the build"
+    os.getenv("FEATURE_JSON_C") != "1", reason="json-c support disabled in the build"
 )
 
 softhsm2_environment = pytest.mark.skipif(
index 1af9e207670094f8c1ba8edc462220ff05272d41..3ebaf3df5e85b6cd55256342e8e79722cd7562cb 100644 (file)
@@ -13,12 +13,14 @@ import os
 
 from .all import ALL
 from .algorithms import init_crypto_supported, set_algorithm_set
+from .features import init_features
 from .openssl import parse_openssl_config
 from .. import log
 
 
 def init_vars():
     """Initializes the environment variables."""
+    init_features()
     init_crypto_supported()
     set_algorithm_set(os.getenv("ALGORITHM_SET"))
     parse_openssl_config(ALL["OPENSSL_CONF"])
index 07364df4894502ea64ef61e30c931906aad50d8f..9ef81b96aa0e3bec4b80339de0ce6331b10562e8 100644 (file)
@@ -18,6 +18,7 @@ from .build import BUILD_VARS  # type: ignore
 from .algorithms import ALG_VARS, CRYPTO_SUPPORTED_VARS
 from .basic import BASIC_VARS
 from .dirs import DIR_VARS
+from .features import FEATURE_VARS
 from .openssl import OPENSSL_VARS
 from .ports import PORT_VARS
 
@@ -58,6 +59,7 @@ ALL = VarLookup(
     BASIC_VARS,
     CRYPTO_SUPPORTED_VARS,
     DIR_VARS,
+    FEATURE_VARS,
     BUILD_VARS,
     OPENSSL_VARS,
     PORT_VARS,
diff --git a/bin/tests/system/isctest/vars/features.py b/bin/tests/system/isctest/vars/features.py
new file mode 100644 (file)
index 0000000..69ecc67
--- /dev/null
@@ -0,0 +1,61 @@
+# 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.
+
+import os
+import subprocess
+
+from .basic import BASIC_VARS
+
+
+FEATURES = {
+    "DNSTAP": "--enable-dnstap",
+    "EXTENDED_DS_DIGEST": "--extended-ds-digest",
+    "FIPS_DH": "--have-fips-dh",
+    "FIPS_MODE": "--have-fips-mode",
+    "FIPS_PROVIDER": "--fips-provider",
+    "GEOIP2": "--have-geoip2",
+    "GSSAPI": "--gssapi",
+    "JSON_C": "--have-json-c",
+    "LIBIDN2": "--with-libidn2",
+    "LIBNGHTTP2": "--with-libnghttp2",
+    "LIBXML2": "--have-libxml2",
+    "LMDB": "--with-lmdb",
+    "MD5": "--md5",
+    "QUERYTRACE": "--enable-querytrace",
+    "RSASHA1": "--rsasha1",
+    "TSAN": "--tsan",
+    "ZLIB": "--with-zlib",
+}
+
+FEATURE_VARS = {}
+
+
+def feature_test(feature):
+    feature_test_bin = BASIC_VARS["FEATURETEST"]
+    if not feature_test_bin:  # this can be the case when running doctest
+        return False
+    try:
+        subprocess.run([feature_test_bin, feature], check=True)
+    except subprocess.CalledProcessError as exc:
+        if exc.returncode != 1:
+            raise
+        return False
+    return True
+
+
+def init_features():
+    """Initialize the environment variables indicating feature support."""
+    for name, arg in FEATURES.items():
+        supported = feature_test(arg)
+        envvar = f"FEATURE_{name}"
+        val = "1" if supported else "0"
+        FEATURE_VARS[envvar] = val
+        os.environ[envvar] = val