From e7ba126ad3523a5b794fc0e87f12046849127278 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Mon, 17 Aug 2026 10:27:17 -0700 Subject: [PATCH] gnu tests: limit make jobs to nproc output run-gnu-test.sh put the nproc executable path after a bare -j. GNU make treated -j as unlimited parallelism and the path as another target, oversubscribing the test runner. Resolve and execute nproc, reject a missing command or invalid output, and attach the resulting count to -j. --- util/run-gnu-test.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/util/run-gnu-test.sh b/util/run-gnu-test.sh index b562002dbfc..737fdf71d3a 100755 --- a/util/run-gnu-test.sh +++ b/util/run-gnu-test.sh @@ -28,9 +28,21 @@ echo "path_UUTILS='${path_UUTILS}'" echo "path_GNU='${path_GNU}'" # Use GNU nproc for *BSD -NPROC=$(command -v ${path_GNU}/src/nproc||command -v nproc) -MAKEFLAGS="${MAKEFLAGS} -j ${NPROC}" +NPROC_COMMAND=$(command -v "${path_GNU}/src/nproc" || command -v nproc || :) +if [ -z "${NPROC_COMMAND}" ] || [ ! -x "${NPROC_COMMAND}" ]; then + echo "Error: unable to find an executable nproc command at '${path_GNU}/src/nproc' or in PATH" >&2 + exit 1 +fi +JOBS=$("${NPROC_COMMAND}") +case "${JOBS}" in + '' | 0 | *[!0-9]*) + echo "Error: '${NPROC_COMMAND}' returned an invalid job count: '${JOBS}'" >&2 + exit 1 + ;; +esac +MAKEFLAGS="${MAKEFLAGS:+${MAKEFLAGS} }-j${JOBS}" export MAKEFLAGS +echo "GNU test make job count: ${JOBS}" ### cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"