osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40449?usp=email )
Change subject: testenv: move ttcn3_hacks_dir to __init__.py ...................................................................... testenv: move ttcn3_hacks_dir to __init__.py Move testenv.testsuite.ttcn3_hacks_dir to testenv.ttcn3_hacks_dir. It makes more sense there as the path to osmo-ttcn3-hacks is used by many modules, not just the testenv.testsuite module, and it prevents a cyclic import with future patches when testenv.testsuite will import testenv.testenv_cfg. Change-Id: I4280009da419e6f5b533805732656ec4cc05d5ac --- M _testenv/testenv/__init__.py M _testenv/testenv/cmd.py M _testenv/testenv/requirements.py M _testenv/testenv/testdir.py M _testenv/testenv/testenv_cfg.py M _testenv/testenv/testsuite.py 6 files changed, 17 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/49/40449/1 diff --git a/_testenv/testenv/__init__.py b/_testenv/testenv/__init__.py index 9b5e944..cb4a02c 100644 --- a/_testenv/testenv/__init__.py +++ b/_testenv/testenv/__init__.py @@ -11,6 +11,7 @@ args = None +ttcn3_hacks_dir = os.path.realpath(f"{__file__}/../../..") src_dir = os.environ.get("TESTENV_SRC_DIR", os.path.realpath(f"{__file__}/../../../..")) data_dir = os.path.join(os.path.realpath(f"{__file__}/../.."), "data") custom_kernel_path = os.path.join(os.path.realpath(f"{__file__}/../../.."), ".linux") @@ -214,8 +215,7 @@ ) raise NoTraceException(f"For --kernel-custom, put a symlink or copy of your kernel to: {custom_kernel_path}") - ttcn3_hacks_dir_src = os.path.realpath(f"{__file__}/../../..") - testsuite_dir = os.path.join(ttcn3_hacks_dir_src, args.testsuite) + testsuite_dir = os.path.join(ttcn3_hacks_dir, args.testsuite) if not os.path.exists(testsuite_dir): raise NoTraceException(f"testsuite dir not found: {testsuite_dir}") diff --git a/_testenv/testenv/cmd.py b/_testenv/testenv/cmd.py index e65f777..d4a1e9a 100644 --- a/_testenv/testenv/cmd.py +++ b/_testenv/testenv/cmd.py @@ -79,8 +79,8 @@ ret = dict(env_extra) path = os.path.join(testenv.data_dir, "scripts") path += f":{os.path.join(testenv.data_dir, 'scripts/qemu')}" - if testenv.args.action == "run" and testenv.testsuite.ttcn3_hacks_dir: - path += f":{os.path.join(testenv.testsuite.ttcn3_hacks_dir, testenv.args.testsuite)}" + if testenv.args.action == "run" and testenv.ttcn3_hacks_dir: + path += f":{os.path.join(testenv.ttcn3_hacks_dir, testenv.args.testsuite)}" if install_dir and install_dir != "/": path += f":{os.path.join(install_dir, 'bin')}" diff --git a/_testenv/testenv/requirements.py b/_testenv/testenv/requirements.py index 5ab61ad..6e7c32c 100644 --- a/_testenv/testenv/requirements.py +++ b/_testenv/testenv/requirements.py @@ -101,7 +101,7 @@ "-q", "fftranscode", os.path.join( - testenv.testsuite.ttcn3_hacks_dir, + testenv.ttcn3_hacks_dir, testenv.args.testsuite, "regen_makefile.sh", ), diff --git a/_testenv/testenv/testdir.py b/_testenv/testenv/testdir.py index 929d19c..927ce69 100644 --- a/_testenv/testenv/testdir.py +++ b/_testenv/testenv/testdir.py @@ -66,7 +66,7 @@ testdir = os.path.join(topdir, cfg_name.replace("testenv_", "").replace(".cfg", "")) logging.info(f"Preparing testdir: {testdir}") - testsuite_dir = os.path.join(testenv.testsuite.ttcn3_hacks_dir, testenv.args.testsuite) + testsuite_dir = os.path.join(testenv.ttcn3_hacks_dir, testenv.args.testsuite) atexit.register(clean_run_scripts) @@ -96,13 +96,13 @@ # Referenced in testsuite cfgs: Common.cfg common_cfg = os.path.join(testdir, "testsuite", "Common.cfg") - path = os.path.join(testenv.testsuite.ttcn3_hacks_dir, "Common.cfg") + path = os.path.join(testenv.ttcn3_hacks_dir, "Common.cfg") testenv.cmd.run(["install", "-Dm644", path, common_cfg]) testenv.cmd.run( [ "sed", "-i", - f's#TTCN3_HACKS_PATH := .*#TTCN3_HACKS_PATH := "{testenv.testsuite.ttcn3_hacks_dir}"#', + f's#TTCN3_HACKS_PATH := .*#TTCN3_HACKS_PATH := "{testenv.ttcn3_hacks_dir}"#', common_cfg, ] ) diff --git a/_testenv/testenv/testenv_cfg.py b/_testenv/testenv/testenv_cfg.py index e224815..5b1d32f 100644 --- a/_testenv/testenv/testenv_cfg.py +++ b/_testenv/testenv/testenv_cfg.py @@ -7,7 +7,6 @@ import os.path import sys import testenv -import testenv.testsuite cfgs = {} current = None @@ -30,7 +29,7 @@ def exit_error_readme(): - readme = os.path.join(testenv.testsuite.ttcn3_hacks_dir, "_testenv/README.md") + readme = os.path.join(testenv.ttcn3_hacks_dir, "_testenv/README.md") logging.error(f"More information: {readme}") sys.exit(1) @@ -215,7 +214,7 @@ def find_configs(): - dir_testsuite = os.path.join(testenv.testsuite.ttcn3_hacks_dir, testenv.args.testsuite) + dir_testsuite = os.path.join(testenv.ttcn3_hacks_dir, testenv.args.testsuite) pattern = os.path.join(dir_testsuite, "testenv*.cfg") ret = sorted(glob.glob(pattern)) diff --git a/_testenv/testenv/testsuite.py b/_testenv/testenv/testsuite.py index 6d0335e..753773f 100644 --- a/_testenv/testenv/testsuite.py +++ b/_testenv/testenv/testsuite.py @@ -13,18 +13,17 @@ import testenv.cmd import time -ttcn3_hacks_dir = os.path.realpath(f"{__file__}/../../..") builddir_env = {} testsuite_proc = None def update_deps(): logging.info("Updating osmo-ttcn3-hacks/deps") - testenv.cmd.run(["make", "deps"], cwd=ttcn3_hacks_dir) + testenv.cmd.run(["make", "deps"], cwd=testenv.ttcn3_hacks_dir) def prepare_testsuite_dir(): - testsuite_dir = f"{ttcn3_hacks_dir}/{testenv.args.testsuite}" + testsuite_dir = f"{testenv.ttcn3_hacks_dir}/{testenv.args.testsuite}" logging.info(f"Generating links and Makefile for {testenv.args.testsuite}") testenv.cmd.run(["./gen_links.sh"], cwd=testsuite_dir, env=builddir_env) testenv.cmd.run("USE_CCACHE=1 ./regen_makefile.sh", cwd=testsuite_dir, env=builddir_env) @@ -50,7 +49,7 @@ if testenv.args.jobs: env["PARALLEL_MAKE"] = f"-j{testenv.args.jobs}" - testenv.cmd.run(["make", testenv.args.testsuite], cwd=ttcn3_hacks_dir, env=env) + testenv.cmd.run(["make", testenv.args.testsuite], cwd=testenv.ttcn3_hacks_dir, env=env) def is_running(pid): @@ -70,7 +69,7 @@ cwd = os.path.join(testenv.testdir.testdir, "testsuite") logging.info("Merging log files") - log_merge = os.path.join(ttcn3_hacks_dir, "log_merge.sh") + log_merge = os.path.join(testenv.ttcn3_hacks_dir, "log_merge.sh") # stdout of this script is very verbose, making it harder to see the output # that matters (tests failed or not), so redirect it to /dev/null cmd = f"{shlex.quote(log_merge)} {shlex.quote(section_data['program'])} --rm >/dev/null" @@ -128,9 +127,9 @@ section_data = cfg["testsuite"] cwd = os.path.join(testenv.testdir.testdir, "testsuite") - start_testsuite = os.path.join(ttcn3_hacks_dir, "start-testsuite.sh") - suite = os.path.join(ttcn3_hacks_dir, testenv.args.testsuite, section_data["program"]) - suite = os.path.relpath(suite, ttcn3_hacks_dir) + start_testsuite = os.path.join(testenv.ttcn3_hacks_dir, "start-testsuite.sh") + suite = os.path.join(testenv.ttcn3_hacks_dir, testenv.args.testsuite, section_data["program"]) + suite = os.path.relpath(suite, testenv.ttcn3_hacks_dir) env = copy.copy(builddir_env) env["TTCN3_PCAP_PATH"] = os.path.join(testenv.testdir.testdir, "testsuite") -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40449?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I4280009da419e6f5b533805732656ec4cc05d5ac Gerrit-Change-Number: 40449 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osm...@sysmocom.de>