test: use MESON_TESTTHREADS to determine the number of jobs
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 3 Aug 2021 02:03:23 +0000 (12:03 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 3 Aug 2021 22:14:29 +0000 (22:14 +0000)
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 <peter.hutterer@who-t.net>
.gitlab-ci/meson-build.sh
test/litest.c

index c2ca0a1e4dcd4000fd1d644bdfcc18e6d6d0c4d6..56b1abccf8e7e97484a7be51c838aa6160e227a2 100755 (executable)
@@ -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 "*************************************************"
index 462b9fabf6b07be0069bede19809d194328037ec..54278bfa849dfc11d4df18ea2f4bc0bad006c963 100644 (file)
@@ -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)