docker: the test stage's parallelism and CPU budgets apart from the compile (build.sh -J, -B)

The per-binary CPU budgets are set on a fast machine. A VM on an EPYC 7302 spends 4.6x the quoted
CPU time on tokenizer_test's reference pass, so the image's test stage failed there on a correct
tree, and -j sized for the compile also sized the tests: twelve at once on a 24-thread host put
tests on busy SMT siblings, which costs CPU seconds too.

RAD_TEST_CPU_BUDGET_SCALE multiplies the budget where rad_test.h reads it, at run time, so a
direct ctest takes it as well and the build layer is untouched by it. The stage takes it as
TEST_CPU_BUDGET_SCALE (build.sh -B) and its parallelism as TEST_JOBS (build.sh -J), each empty by
default, which is the stage as before. harness_test checks the factor and keeps it out of its
fixture's environment; docs/DOCKER.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Opus 5.5 committed 2026-10-19 13:37:01 +02:00
1 parent 44aecb0ab8
commit 748f63637e
5 files changed
+33 -6

No files matched your search

+5 -1
View File
@@ -14,6 +14,8 @@
* RAD_TEST_TMPDIR where tmpdir() is made, before $TMPDIR and /tmp
* RAD_TEST_CPU_BUDGET seconds of process CPU time the binary may spend; over it, it fails
* tests/CMakeLists.txt sets the last three for every ctest entry.
* RAD_TEST_CPU_BUDGET_SCALE a factor on that budget, for a host slower per thread than the
* one the budgets were set on; unset or 0 is 1
*
* Exit status: 1 when a check failed (an exception escaping a case is a failed check), 77 when
* nothing failed and no check ran, 2 for a command line it does not understand, else 0. 77 is
@@ -288,7 +290,9 @@ inline int run_all(int argc, char** argv) {
* so a slow case or a spinning thread pool is caught when it lands. CPU time rather than wall
* time, so a loaded machine does not fail a correct binary. */
if (const char* b = std::getenv("RAD_TEST_CPU_BUDGET")) {
const double budget = std::atof(b);
double budget = std::atof(b);
if (const char* s = std::getenv("RAD_TEST_CPU_BUDGET_SCALE"); s && std::atof(s) > 0)
budget *= std::atof(s);
if (budget > 0 && cpu > budget && rc != 1) {
fprintf(stderr, " FAIL the binary spent %.2f s of CPU, over its budget of %g s "
"(RAD_TEST_CPU_BUDGET)\n", cpu, budget);