]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move dir env var handling to isctest.vars.dirs
authorTom Krizek <tkrizek@isc.org>
Wed, 28 Feb 2024 15:49:22 +0000 (16:49 +0100)
committerNicki Křížek <nicki@isc.org>
Thu, 9 May 2024 15:08:10 +0000 (17:08 +0200)
bin/tests/system/conftest.py
bin/tests/system/isctest/vars/all.py
bin/tests/system/isctest/vars/dirs.py [new file with mode: 0644]
bin/tests/system/legacy/ns6/sign.sh
bin/tests/system/legacy/ns7/sign.sh
bin/tests/system/verify/zones/genzones.sh
bin/tests/system/wildcard/ns1/sign.sh

index af178aec8954a7ba8a568a4830607e09ccfc3b21..8813dadd086898ab42f3c55cb57c4207a31b1e63 100644 (file)
@@ -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)
index cc2a7f88362bdaee64c58caba1090b4a756182e6..3e6d49dc749f237f58f076ed41f997fd20969dee 100644 (file)
@@ -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 (file)
index 0000000..56f4c55
--- /dev/null
@@ -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
index 96ce2855fe32efed6f3b5f583d8d7b3174ab20ec..49a44bb91a37af4a754fc1f5bcf064507f81539a 100755 (executable)
@@ -13,8 +13,6 @@
 
 . ../../conf.sh
 
-SYSTESTDIR=legacy
-
 echo_i "sign edns512"
 
 zone=edns512
index 82c6b7e2f589062075aeafe7eb128b7c6f5d4d9e..9dfa9f6732fc5bfb98270de1db545cc60ce4248f 100755 (executable)
@@ -13,8 +13,6 @@
 
 . ../../conf.sh
 
-SYSTESTDIR=legacy
-
 echo_i "sign edns512-notcp"
 
 zone=edns512-notcp
index 56866f9c796159e9321bee735223b57b1b74693d..4c999db98dd18af29b57ac3104df3b5ae56b142c 100644 (file)
@@ -13,8 +13,6 @@
 
 . ../../conf.sh
 
-SYSTESTDIR=verify
-
 dumpit() {
   echo_d "${debug}: dumping ${1}"
   cat "${1}" | cat_d
index d1d86260f7c89a49370366a3e7c1b460c5343ada..7af0b83f7218b5e4bd147b3f50629b8d291f76d6 100755 (executable)
@@ -13,8 +13,6 @@
 
 . ../../conf.sh
 
-SYSTESTDIR=wildcard
-
 dssets=
 
 # RFC 4592 example zone.