From b925b55634cd1c8cc0365c9fc6894f243b627b5e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 3 Aug 2021 12:03:23 +1000 Subject: [PATCH] test: use MESON_TESTTHREADS to determine the number of jobs meson uses MESON_TESTTHREADS to determine the number of parallel test jobs. Since our main test suite cannot be run in parallel anyway, use that same variable in litest to determine how many jobs we should fork off. In the CI pipeline, we can use FDO_CI_CONCURRENT to pass that down so we don't end up running a billion jobs on a test runner. Signed-off-by: Peter Hutterer --- .gitlab-ci/meson-build.sh | 3 ++- test/litest.c | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci/meson-build.sh b/.gitlab-ci/meson-build.sh index c2ca0a1..56b1abc 100755 --- a/.gitlab-ci/meson-build.sh +++ b/.gitlab-ci/meson-build.sh @@ -22,7 +22,8 @@ if [[ -z "$CI_JOB_ID" ]] || [[ -z "$CI_JOB_NAME" ]]; then fi if [[ -n "$FDO_CI_CONCURRENT" ]]; then - NINJA_ARGS="-j${FDO_CI_CONCURRENT} $NINJA_ARGS" + NINJA_ARGS="-j$FDO_CI_CONCURRENT $NINJA_ARGS" + MESON_TESTTHREADS="$FDO_CI_CONCURRENT" fi echo "*************************************************" diff --git a/test/litest.c b/test/litest.c index 462b9fa..54278bf 100644 --- a/test/litest.c +++ b/test/litest.c @@ -4627,14 +4627,18 @@ main(int argc, char **argv) int tty_mode = -1; int failed_tests; int rc; + const char *meson_testthreads; in_debugger = is_debugger_attached(); if (in_debugger || RUNNING_ON_VALGRIND) setenv("CK_FORK", "no", 0); - jobs = get_nprocs(); - if (!RUNNING_ON_VALGRIND) - jobs *= 2; + if ((meson_testthreads = getenv("MESON_TESTTHREADS")) == NULL || + !safe_atoi(meson_testthreads, &jobs)) { + jobs = get_nprocs(); + if (!RUNNING_ON_VALGRIND) + jobs *= 2; + } mode = litest_parse_argv(argc, argv); if (mode == LITEST_MODE_ERROR) -- 2.7.4