diff --git a/bin/tests/system/feature-test.c b/bin/tests/system/feature-test.c index 73d0e73e66..98fb219f2f 100644 --- a/bin/tests/system/feature-test.c +++ b/bin/tests/system/feature-test.c @@ -52,11 +52,9 @@ usage(void) { fprintf(stderr, "\t--have-geoip2\n"); fprintf(stderr, "\t--have-json-c\n"); fprintf(stderr, "\t--have-libxml2\n"); - fprintf(stderr, "\t--ipv6only=no\n"); fprintf(stderr, "\t--md5\n"); fprintf(stderr, "\t--rsasha1\n"); fprintf(stderr, "\t--tsan\n"); - fprintf(stderr, "\t--with-dlz-filesystem\n"); fprintf(stderr, "\t--with-libidn2\n"); fprintf(stderr, "\t--with-lmdb\n"); fprintf(stderr, "\t--with-libnghttp2\n"); @@ -207,25 +205,6 @@ main(int argc, char **argv) { return 0; } - if (strcmp(argv[1], "--ipv6only=no") == 0) { -#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) - int s; - int n = -1; - int v6only = -1; - socklen_t len = sizeof(v6only); - - s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); - if (s >= 0) { - n = getsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, - (void *)&v6only, &len); - close(s); - } - return (n == 0 && v6only == 0) ? 0 : 1; -#else /* defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) */ - return 1; -#endif /* defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) */ - } - if (strcasecmp(argv[1], "--rsasha1") == 0) { if (!dst_algorithm_supported(DST_ALG_RSASHA1)) { return 1; @@ -234,14 +213,6 @@ main(int argc, char **argv) { return 0; } - if (strcmp(argv[1], "--with-dlz-filesystem") == 0) { -#ifdef DLZ_FILESYSTEM - return 0; -#else /* ifdef DLZ_FILESYSTEM */ - return 1; -#endif /* ifdef DLZ_FILESYSTEM */ - } - if (strcmp(argv[1], "--with-libidn2") == 0) { #ifdef HAVE_LIBIDN2 return 0; diff --git a/bin/tests/system/isctest/mark.py b/bin/tests/system/isctest/mark.py index e1b97f8f84..df3b1e540b 100644 --- a/bin/tests/system/isctest/mark.py +++ b/bin/tests/system/isctest/mark.py @@ -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( diff --git a/bin/tests/system/isctest/vars/__init__.py b/bin/tests/system/isctest/vars/__init__.py index 1af9e20767..3ebaf3df5e 100644 --- a/bin/tests/system/isctest/vars/__init__.py +++ b/bin/tests/system/isctest/vars/__init__.py @@ -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"]) diff --git a/bin/tests/system/isctest/vars/all.py b/bin/tests/system/isctest/vars/all.py index 07364df489..9ef81b96aa 100644 --- a/bin/tests/system/isctest/vars/all.py +++ b/bin/tests/system/isctest/vars/all.py @@ -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 index 0000000000..69ecc6786f --- /dev/null +++ b/bin/tests/system/isctest/vars/features.py @@ -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