diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index af178aec89..8813dadd08 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -24,6 +24,7 @@ import pytest pytest.register_assert_rewrite("isctest") import isctest +from isctest.vars.dirs import SYSTEM_TEST_DIR_GIT_PATH # Silence warnings caused by passing a pytest fixture to another fixture. @@ -61,7 +62,6 @@ PRIORITY_TESTS = [ "upforwd/", ] PRIORITY_TESTS_RE = re.compile("|".join(PRIORITY_TESTS)) -SYSTEM_TEST_DIR_GIT_PATH = "bin/tests/system" SYSTEM_TEST_NAME_RE = re.compile(f"{SYSTEM_TEST_DIR_GIT_PATH}" + r"/([^/]+)") SYMLINK_REPLACEMENT_RE = re.compile(r"/tests(_.*)\.py") @@ -260,8 +260,6 @@ def control_port(): def env(): """Dictionary containing environment variables for the test.""" env = dict(isctest.vars.ALL) - env["builddir"] = f"{env['TOP_BUILDDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}" - env["srcdir"] = f"{env['TOP_SRCDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}" os.environ.update(env) return env @@ -354,14 +352,13 @@ def system_test_dir( pass # Create a temporary directory with a copy of the original system test dir contents - system_test_root = Path( - f"{isctest.vars.ALL['TOP_BUILDDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}" - ) + system_test_root = Path(os.environ["builddir"]) testdir = Path( tempfile.mkdtemp(prefix=f"{system_test_name}_tmp_", dir=system_test_root) ) shutil.rmtree(testdir) shutil.copytree(system_test_root / system_test_name, testdir) + isctest.vars.dirs.set_system_test_name(testdir.name) # Create a convenience symlink with a stable and predictable name module_name = SYMLINK_REPLACEMENT_RE.sub(r"\1", request.node.name) diff --git a/bin/tests/system/isctest/vars/all.py b/bin/tests/system/isctest/vars/all.py index cc2a7f8836..3e6d49dc74 100644 --- a/bin/tests/system/isctest/vars/all.py +++ b/bin/tests/system/isctest/vars/all.py @@ -16,6 +16,7 @@ from .autoconf import AC_VARS # type: ignore # pylint: enable=import-error from .basic import BASIC_VARS +from .dirs import DIR_VARS from .openssl import OPENSSL_VARS from .ports import PORT_VARS @@ -51,4 +52,4 @@ class VarLookup(ChainMap): return iter(self.keys()) -ALL = VarLookup(AC_VARS, BASIC_VARS, OPENSSL_VARS, PORT_VARS) +ALL = VarLookup(AC_VARS, BASIC_VARS, OPENSSL_VARS, PORT_VARS, DIR_VARS) diff --git a/bin/tests/system/isctest/vars/dirs.py b/bin/tests/system/isctest/vars/dirs.py new file mode 100644 index 0000000000..56f4c55375 --- /dev/null +++ b/bin/tests/system/isctest/vars/dirs.py @@ -0,0 +1,31 @@ +# 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 + +# pylint: disable=import-error +from .autoconf import AC_VARS # type: ignore + +# pylint: enable=import-error + + +SYSTEM_TEST_DIR_GIT_PATH = "bin/tests/system" + +DIR_VARS = { + "builddir": f"{AC_VARS['TOP_BUILDDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}", + "srcdir": f"{AC_VARS['TOP_SRCDIR']}/{SYSTEM_TEST_DIR_GIT_PATH}", + "SYSTESTDIR": None, +} + + +def set_system_test_name(name: str): + DIR_VARS["SYSTESTDIR"] = name + os.environ["SYSTESTDIR"] = name diff --git a/bin/tests/system/legacy/ns6/sign.sh b/bin/tests/system/legacy/ns6/sign.sh index 96ce2855fe..49a44bb91a 100755 --- a/bin/tests/system/legacy/ns6/sign.sh +++ b/bin/tests/system/legacy/ns6/sign.sh @@ -13,8 +13,6 @@ . ../../conf.sh -SYSTESTDIR=legacy - echo_i "sign edns512" zone=edns512 diff --git a/bin/tests/system/legacy/ns7/sign.sh b/bin/tests/system/legacy/ns7/sign.sh index 82c6b7e2f5..9dfa9f6732 100755 --- a/bin/tests/system/legacy/ns7/sign.sh +++ b/bin/tests/system/legacy/ns7/sign.sh @@ -13,8 +13,6 @@ . ../../conf.sh -SYSTESTDIR=legacy - echo_i "sign edns512-notcp" zone=edns512-notcp diff --git a/bin/tests/system/verify/zones/genzones.sh b/bin/tests/system/verify/zones/genzones.sh index 56866f9c79..4c999db98d 100644 --- a/bin/tests/system/verify/zones/genzones.sh +++ b/bin/tests/system/verify/zones/genzones.sh @@ -13,8 +13,6 @@ . ../../conf.sh -SYSTESTDIR=verify - dumpit() { echo_d "${debug}: dumping ${1}" cat "${1}" | cat_d diff --git a/bin/tests/system/wildcard/ns1/sign.sh b/bin/tests/system/wildcard/ns1/sign.sh index d1d86260f7..7af0b83f72 100755 --- a/bin/tests/system/wildcard/ns1/sign.sh +++ b/bin/tests/system/wildcard/ns1/sign.sh @@ -13,8 +13,6 @@ . ../../conf.sh -SYSTESTDIR=wildcard - dssets= # RFC 4592 example zone.