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

+7 -1
View File
@@ -23,7 +23,7 @@ struct Run {
* inherited from ctest. */
Run fixture(const std::string& args, const std::string& env = "") {
const std::string cmd = "env -u RAD_TEST_FILTER -u RAD_TEST_STRICT -u RAD_TEST_LEVEL "
"-u RAD_TEST_CPU_BUDGET " + env + " '" RAD_HARNESS_FIXTURE "' " +
"-u RAD_TEST_CPU_BUDGET -u RAD_TEST_CPU_BUDGET_SCALE " + env + " '" RAD_HARNESS_FIXTURE "' " +
args + " 2>&1";
Run r;
FILE* p = popen(cmd.c_str(), "r");
@@ -194,6 +194,12 @@ TEST(a_binary_over_its_cpu_budget_fails) {
CHECK(has(r.out, "slowest: burns_cpu "));
r = fixture("passes_one", "RAD_TEST_CPU_BUDGET=60");
CHECK_EQ(r.status, 0);
/* A slower host scales every budget by one factor. */
r = fixture("burns_cpu passes_one", "RAD_TEST_CPU_BUDGET=0.05 RAD_TEST_CPU_BUDGET_SCALE=2");
CHECK_EQ(r.status, 1);
CHECK(has(r.out, "over its budget of 0.1 s"));
r = fixture("burns_cpu passes_one", "RAD_TEST_CPU_BUDGET=0.05 RAD_TEST_CPU_BUDGET_SCALE=100");
CHECK_EQ(r.status, 0);
}
/* A command line the harness does not understand is refused rather than read as a filter. */