import platform
import socket
import shutil
-import subprocess
import pytest
)
-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",
)
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(
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"])
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
BASIC_VARS,
CRYPTO_SUPPORTED_VARS,
DIR_VARS,
+ FEATURE_VARS,
BUILD_VARS,
OPENSSL_VARS,
PORT_VARS,
--- /dev/null
+# 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