mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-27 20:25:55 -04:00
[9.20] new: test: Add FEATURE_* environment variables to system tests
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. Backport of MR !11316 Merge branch 'backport-nicki/featurest-system-test-env-9.20' into 'bind-9.20' See merge request isc-projects/bind9!11345
This commit is contained in:
commit
1987a84de4
5 changed files with 73 additions and 48 deletions
|
|
@ -50,11 +50,9 @@ usage(void) {
|
|||
fprintf(stderr, "\t--have-json-c\n");
|
||||
fprintf(stderr, "\t--have-libxml2\n");
|
||||
fprintf(stderr, "\t--have-openssl-cipher-suites\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");
|
||||
|
|
@ -218,25 +216,6 @@ main(int argc, char **argv) {
|
|||
return answer;
|
||||
}
|
||||
|
||||
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) {
|
||||
int answer;
|
||||
isc_mem_t *mctx = NULL;
|
||||
|
|
@ -248,14 +227,6 @@ main(int argc, char **argv) {
|
|||
return answer;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -30,24 +30,11 @@ 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
|
||||
|
||||
|
||||
DNSRPS_BIN = Path(os.environ["TOP_BUILDDIR"]) / "bin/tests/system/rpz/dnsrps"
|
||||
|
||||
|
||||
def is_dnsrps_available():
|
||||
if not feature_test("--enable-dnsrps"):
|
||||
if os.getenv("FEATURE_DNSRPS") != "1":
|
||||
return False
|
||||
try:
|
||||
subprocess.run([DNSRPS_BIN, "-a"], check=True)
|
||||
|
|
@ -67,24 +54,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"
|
||||
)
|
||||
|
||||
dnsrps_enabled = pytest.mark.skipif(
|
||||
|
|
|
|||
|
|
@ -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"])
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from .autoconf import AC_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
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ class VarLookup(ChainMap):
|
|||
ALL = VarLookup(
|
||||
AC_VARS,
|
||||
BASIC_VARS,
|
||||
FEATURE_VARS,
|
||||
OPENSSL_VARS,
|
||||
PORT_VARS,
|
||||
DIR_VARS,
|
||||
|
|
|
|||
63
bin/tests/system/isctest/vars/features.py
Normal file
63
bin/tests/system/isctest/vars/features.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# 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 = {
|
||||
"DNSRPS": "--enable-dnsrps",
|
||||
"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",
|
||||
"OPENSSL_CIPHER_SUITES": "--have-openssl-cipher-suites",
|
||||
"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
|
||||
Loading…
Reference in a new issue