osmith has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38262?usp=email )
Change subject: testenv: copy=: support copying directories too
......................................................................
testenv: copy=: support copying directories too
In preparation for adding the inital testenv.cfgs for ggsn, allow
copying full directories with copy= too. This will make the ggsn
testenv.cfg files easier to maintain.
Change-Id: I8e680fbd93516030614c015d7c3b5bdb153ec487
---
M _testenv/README.md
M _testenv/testenv/testdir.py
2 files changed, 16 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/62/38262/1
diff --git a/_testenv/README.md b/_testenv/README.md
index 09b12e8..7db3e24 100644
--- a/_testenv/README.md
+++ b/_testenv/README.md
@@ -65,8 +65,9 @@
* `program=`: executable for starting a test component, may contain arguments.
See below for `PATH` and `PWD`.
-* `copy=`: file(s) to copy from the testsuite directory to the test directory,
- like `.cfg` and `.confmerge` files. Multiple values are separated by spaces.
+* `copy=`: optionally copy a space separated list of files or directories from
+ the testsuite directory to the test directory, like `.cfg` and `.confmerge`
+ files.
* `make=`: osmo-dev make target for building from source, if running without
`--binary-repo`. This is usually the name of the git repository, but could
diff --git a/_testenv/testenv/testdir.py b/_testenv/testenv/testdir.py
index 55f04d2..ee698fff 100644
--- a/_testenv/testenv/testdir.py
+++ b/_testenv/testenv/testdir.py
@@ -80,11 +80,19 @@
testenv.cmd.run(["install", "-Dm644", path, path_dest])
if "copy" in section_data:
- for file in section_data["copy"].split(" "):
- path = os.path.join(testsuite_dir, file)
- path_dest = os.path.join(section_dir, file)
- mode = 755 if os.access(path, os.X_OK) else 644
- testenv.cmd.run(["install", f"-Dm{mode}", path,
path_dest])
+ for copy_entry in section_data["copy"].split(" "):
+ path = os.path.join(testsuite_dir, copy_entry)
+ if os.path.isdir(path):
+ pattern = os.path.join(path, "**")
+ paths = glob.glob(pattern, recursive=True)
+ else:
+ paths = [path]
+ for path in paths:
+ if os.path.isdir(path):
+ continue
+ path_dest = os.path.join(section_dir, os.path.relpath(path,
testsuite_dir))
+ mode = 755 if os.access(path, os.X_OK) else 644
+ testenv.cmd.run(["install", f"-Dm{mode}", path,
path_dest])
if "clean" in section_data:
logging.info(f"Running {section} clean script (reason: prepare)")
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38262?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: I8e680fbd93516030614c015d7c3b5bdb153ec487
Gerrit-Change-Number: 38262
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>