osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40371?usp=email )
Change subject: testenv: add -j/--jobs parameter to run action ......................................................................
testenv: add -j/--jobs parameter to run action
Allow building with less than all CPU cores. This may be desirable because the NGAP asn1 files are huge and building with -j$(NPROC) eats all the memory on some systems.
Suggested-by: Pau Espin Pedrol pespin@sysmocom.de Change-Id: I191291cabd40e23983d29a350e587c1e11a52c0d --- M _testenv/testenv/__init__.py M _testenv/testenv/osmo_dev.py M _testenv/testenv/podman_install.py M _testenv/testenv/testsuite.py 4 files changed, 19 insertions(+), 2 deletions(-)
Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/_testenv/testenv/__init__.py b/_testenv/testenv/__init__.py index 07880cc..6118b65 100644 --- a/_testenv/testenv/__init__.py +++ b/_testenv/testenv/__init__.py @@ -94,6 +94,12 @@ metavar="OBS_PROJECT", help="use binary packages from this Osmocom OBS project instead (e.g. osmocom:nightly)", ) + group.add_argument( + "-j", + "--jobs", + help="number of jobs to run simultaneously (default: nproc)", + type=int, + )
group = sub_run.add_argument_group("exit options", "When and how testenv should exit when done.") group = group.add_mutually_exclusive_group() diff --git a/_testenv/testenv/osmo_dev.py b/_testenv/testenv/osmo_dev.py index 1e94cf1..02fe2e8 100644 --- a/_testenv/testenv/osmo_dev.py +++ b/_testenv/testenv/osmo_dev.py @@ -73,6 +73,9 @@ os.path.join(testenv.args.cache, "host/usr"), ]
+ if testenv.args.jobs: + extra_opts += [f"-j{testenv.args.jobs}"] + # Make dirs created without passing --autoreconf-in-src-copy to # gen_makefile.py (as previous versions of testenv did) are incompatible. # Add the "2" to avoid potential conflicts. diff --git a/_testenv/testenv/podman_install.py b/_testenv/testenv/podman_install.py index 130085c..adc2d70 100644 --- a/_testenv/testenv/podman_install.py +++ b/_testenv/testenv/podman_install.py @@ -26,7 +26,10 @@ # errors. git_dir = os.path.join(testenv.args.cache, "git", f"build_against_{testenv.args.binary_repo}".replace(":", "_"))
- jobs = multiprocessing.cpu_count() + 1 + if testenv.args.jobs: + jobs = testenv.args.jobs + else: + jobs = multiprocessing.cpu_count()
os.makedirs(git_dir, exist_ok=True)
diff --git a/_testenv/testenv/testsuite.py b/_testenv/testenv/testsuite.py index 149e47f..5ddbf3e 100644 --- a/_testenv/testenv/testsuite.py +++ b/_testenv/testenv/testsuite.py @@ -51,7 +51,12 @@
def build(): logging.info("Building testsuite") - testenv.cmd.run(["make", testenv.args.testsuite], cwd=ttcn3_hacks_dir, env=builddir_env) + + env = copy.copy(builddir_env) + 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)
def is_running(pid):