test: parallelize test/run via xargs -P; 180s per-tool timeout

test/run fans test/wcc/*.c across $(nproc) workers via xargs -0 -n2 -P
$JOBS; each worker writes <prefix>.status and an optional <prefix>.fail
sentinel into a mktemp results dir. The driver collects in glob order so
output stays deterministic across runs.

Wraps every ww/w6c/w6a/w6l/wwdump invocation in 990-995 with
`timeout 180`, bounding orphan compilers under 8-way contention. The
direct runwait(exe) calls for fresh-built test binaries get the same
treatment via a "timeout 180 %s" snprintf hop. Motivation: pid 2101 was
a w6c_ww that ran 42h on /tmp/wcas_asm_1326_15.ww until we killed it
during this session; timeout makes that impossible.

993's /tmp/ww_d_hello.ww is now pid-keyed (snprintf %d getpid); without
it concurrent runs (or future shards of 993 itself) would race on the
staging file.

Wall: 9m59s → 4m31s on 8 cores. Same 132/132 status.
This commit is contained in:
2026-05-21 16:32:27 +09:00
parent 0715ec9662
commit 65a6cac6a0
7 changed files with 104 additions and 76 deletions

View File

@@ -79,7 +79,7 @@ probe_codegen(const char *bin)
for (int i = 0; files[i]; i++) {
char cmd[2048];
snprintf(cmd, sizeof cmd,
"%s/w6c %s/%s > /dev/null 2>&1", bin, cwd, files[i]);
"timeout 180 %s/w6c %s/%s > /dev/null 2>&1", bin, cwd, files[i]);
if (runwait(cmd) != 0) {
fprintf(stderr, "codegen FAIL: %s\n", files[i]);
fail++;
@@ -99,15 +99,16 @@ probe_smoke(const char *bin)
mkdir(tmpdir, 0755);
char cmd[2048];
snprintf(cmd, sizeof cmd,
"cd %s && %s/ww build %s/selfhost/test/smoke.ww >/dev/null 2>&1",
"cd %s && timeout 180 %s/ww build %s/selfhost/test/smoke.ww >/dev/null 2>&1",
tmpdir, bin, cwd);
if (runwait(cmd) != 0) {
fprintf(stderr, "smoke FAIL: ww build did not succeed\n");
return -1;
}
char outbin[256];
char outbin[256], runcmd[512];
snprintf(outbin, sizeof outbin, "%s/smoke", tmpdir);
int rc = runwait(outbin);
snprintf(runcmd, sizeof runcmd, "timeout 180 %s", outbin);
int rc = runwait(runcmd);
unlink(outbin);
char tmp[1024];
snprintf(tmp, sizeof tmp, "%s/smoke.s", tmpdir); unlink(tmp);
@@ -139,10 +140,10 @@ probe_dump_diff_mode(const char *bin, const char *flag, const char **inputs)
char a[256], b[256], cmd[2048];
snprintf(a, sizeof a, "/tmp/wwd_diff_%d_c", getpid());
snprintf(b, sizeof b, "/tmp/wwd_diff_%d_w", getpid());
snprintf(cmd, sizeof cmd, "%s/wwdump %s %s/%s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/wwdump %s %s/%s > %s 2>/dev/null",
bin, flag, cwd, inputs[i], a);
runwait(cmd);
snprintf(cmd, sizeof cmd, "%s/wwdump_ww %s %s/%s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/wwdump_ww %s %s/%s > %s 2>/dev/null",
bin, flag, cwd, inputs[i], b);
runwait(cmd);
char *ba = NULL, *bb = NULL;
@@ -472,13 +473,13 @@ probe_ww_compile(const char *bin)
fputs(progs[i].src, f);
fclose(f);
snprintf(cmd, sizeof cmd, "%s/wwdump_ww -c %s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/wwdump_ww -c %s > %s 2>/dev/null",
bin, src, wws);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-compile prog %d: wwdump_ww -c errored\n", i);
fail++; goto cleanup;
}
snprintf(cmd, sizeof cmd, "%s/w6c %s > %s 2>/dev/null", bin, src, cs);
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6c %s > %s 2>/dev/null", bin, src, cs);
runwait(cmd);
char *bw = NULL, *bc = NULL;
@@ -492,18 +493,19 @@ probe_ww_compile(const char *bin)
}
free(bw); free(bc);
snprintf(cmd, sizeof cmd, "%s/w6a -o %s %s 2>/dev/null", bin, obj, wws);
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6a -o %s %s 2>/dev/null", bin, obj, wws);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-compile prog %d: w6a failed\n", i);
fail++; goto cleanup;
}
snprintf(cmd, sizeof cmd, "%s/w6l -o %s %s %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6l -o %s %s %s 2>/dev/null",
bin, exe, obj, rt);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-compile prog %d: w6l failed\n", i);
fail++; goto cleanup;
}
int rc = runwait(exe);
snprintf(cmd, sizeof cmd, "timeout 180 %s", exe);
int rc = runwait(cmd);
if (rc != progs[i].want_exit) {
fprintf(stderr, "ww-compile prog %d: exit=%d, want %d\n",
i, rc, progs[i].want_exit);
@@ -536,7 +538,7 @@ probe_resolve(const char *bin)
for (int i = 0; complete[i]; i++) {
char a[256], cmd[2048];
snprintf(a, sizeof a, "/tmp/wwd_r_%d", getpid());
snprintf(cmd, sizeof cmd, "%s/wwdump_ww -r %s/%s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/wwdump_ww -r %s/%s > %s 2>/dev/null",
bin, cwd, complete[i], a);
int rc = runwait(cmd);
if (rc != 0) {
@@ -568,7 +570,7 @@ probe_dump_stable(const char *bin)
snprintf(a, sizeof a, "/tmp/wwd_%d_a", getpid());
snprintf(b, sizeof b, "/tmp/wwd_%d_b", getpid());
char cmd[2048];
snprintf(cmd, sizeof cmd, "%s/wwdump %s %s/%s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/wwdump %s %s/%s > %s 2>/dev/null",
bin, modes[m], cwd, inputs[i], a);
if (runwait(cmd) != 0) {
fprintf(stderr, "wwdump FAIL: %s %s\n", modes[m], inputs[i]);
@@ -576,7 +578,7 @@ probe_dump_stable(const char *bin)
fail++;
continue;
}
snprintf(cmd, sizeof cmd, "%s/wwdump %s %s/%s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/wwdump %s %s/%s > %s 2>/dev/null",
bin, modes[m], cwd, inputs[i], b);
runwait(cmd);
char *ba = NULL, *bb = NULL;
@@ -629,21 +631,21 @@ probe_bootstrap_fixed_point(const char *bin)
int fail = 0;
/* ww1 -> ww2 */
snprintf(cmd, sizeof cmd,
"%s/wwdump_ww -c %s/selfhost/cmd/wwdump/main.combined.ww > %s 2>/dev/null",
"timeout 180 %s/wwdump_ww -c %s/selfhost/cmd/wwdump/main.combined.ww > %s 2>/dev/null",
bin, cwd, ww2s);
if (runwait(cmd) != 0) { fprintf(stderr, "fp FAIL: ww1 self-compile\n"); fail++; goto cleanup; }
snprintf(cmd, sizeof cmd, "%s/w6a -o %s %s 2>/dev/null", bin, ww2o, ww2s);
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6a -o %s %s 2>/dev/null", bin, ww2o, ww2s);
if (runwait(cmd) != 0) { fprintf(stderr, "fp FAIL: w6a ww2.s\n"); fail++; goto cleanup; }
snprintf(cmd, sizeof cmd, "%s/w6l -o %s %s %s 2>/dev/null", bin, ww2e, ww2o, rt);
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6l -o %s %s %s 2>/dev/null", bin, ww2e, ww2o, rt);
if (runwait(cmd) != 0) { fprintf(stderr, "fp FAIL: w6l ww2\n"); fail++; goto cleanup; }
/* ww2 -> ww3 */
snprintf(cmd, sizeof cmd,
"%s -c %s/selfhost/cmd/wwdump/main.combined.ww > %s 2>/dev/null",
"timeout 180 %s -c %s/selfhost/cmd/wwdump/main.combined.ww > %s 2>/dev/null",
ww2e, cwd, ww3s);
if (runwait(cmd) != 0) { fprintf(stderr, "fp FAIL: ww2 self-compile\n"); fail++; goto cleanup; }
snprintf(cmd, sizeof cmd, "%s/w6a -o %s %s 2>/dev/null", bin, ww3o, ww3s);
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6a -o %s %s 2>/dev/null", bin, ww3o, ww3s);
if (runwait(cmd) != 0) { fprintf(stderr, "fp FAIL: w6a ww3.s\n"); fail++; goto cleanup; }
snprintf(cmd, sizeof cmd, "%s/w6l -o %s %s %s 2>/dev/null", bin, ww3e, ww3o, rt);
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6l -o %s %s %s 2>/dev/null", bin, ww3e, ww3o, rt);
if (runwait(cmd) != 0) { fprintf(stderr, "fp FAIL: w6l ww3\n"); fail++; goto cleanup; }
/* The fixed-point check: ww2.s == ww3.s, ww2 == ww3. */
snprintf(cmd, sizeof cmd, "cmp -s %s %s", ww2s, ww3s);
@@ -677,14 +679,14 @@ probe_ww1_to_ww2(const char *bin)
snprintf(exe_p, sizeof exe_p, "%s/ww2", tmpdir);
int fail = 0;
snprintf(cmd, sizeof cmd,
"%s/wwdump_ww -c %s/selfhost/cmd/wwdump/main.combined.ww > %s 2>/dev/null",
"timeout 180 %s/wwdump_ww -c %s/selfhost/cmd/wwdump/main.combined.ww > %s 2>/dev/null",
bin, cwd, asm_p);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww1->ww2 FAIL: wwdump_ww segfaulted on its own source\n");
fail++;
goto cleanup;
}
snprintf(cmd, sizeof cmd, "%s/w6a -o %s %s 2>/dev/null", bin, obj_p, asm_p);
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6a -o %s %s 2>/dev/null", bin, obj_p, asm_p);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww1->ww2 FAIL: w6a errored on ww1 output\n");
fail++;
@@ -692,7 +694,7 @@ probe_ww1_to_ww2(const char *bin)
}
char rt[1024];
snprintf(rt, sizeof rt, "%s/../lib/libwwrt.a", bin);
snprintf(cmd, sizeof cmd, "%s/w6l -o %s %s %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6l -o %s %s %s 2>/dev/null",
bin, exe_p, obj_p, rt);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww1->ww2 FAIL: w6l errored\n");
@@ -748,7 +750,7 @@ probe_ww_links(const char *bin)
runwait(cmd);
/* ww build to get the .combined.ww as a side effect. */
snprintf(cmd, sizeof cmd,
"cd %s && %s/ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse -I %s/selfhost/cmd/wcc %s >/dev/null 2>&1",
"cd %s && timeout 180 %s/ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse -I %s/selfhost/cmd/wcc %s >/dev/null 2>&1",
tmpdir, bin, cwd, cwd, cwd, cwd, tmpsrc);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-links FAIL: ww build %s\n", fix);
@@ -762,13 +764,13 @@ probe_ww_links(const char *bin)
snprintf(wop, sizeof wop, "%s_w.o", stem);
snprintf(wexep, sizeof wexep, "%s_w", stem);
snprintf(cmd, sizeof cmd,
"%s/wwdump_ww -c %s > %s 2>/dev/null", bin, combinedp, wsp);
"timeout 180 %s/wwdump_ww -c %s > %s 2>/dev/null", bin, combinedp, wsp);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-links FAIL: wwdump_ww -c %s\n", fix);
fail++;
goto cleanup;
}
snprintf(cmd, sizeof cmd, "%s/w6a -o %s %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6a -o %s %s 2>/dev/null",
bin, wop, wsp);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-links FAIL: w6a %s\n", fix);
@@ -777,14 +779,15 @@ probe_ww_links(const char *bin)
}
char rt[1024];
snprintf(rt, sizeof rt, "%s/../lib/libwwrt.a", bin);
snprintf(cmd, sizeof cmd, "%s/w6l -o %s %s %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6l -o %s %s %s 2>/dev/null",
bin, wexep, wop, rt);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-links FAIL: w6l %s\n", fix);
fail++;
goto cleanup;
}
int rc = runwait(wexep);
snprintf(cmd, sizeof cmd, "timeout 180 %s", wexep);
int rc = runwait(cmd);
if (rc != want) {
fprintf(stderr, "ww-links FAIL: %s exit=%d want=%d\n",
fix, rc, want);
@@ -819,10 +822,10 @@ probe_cgen_match(const char *bin)
char a[256], b[256], cmd[2048];
snprintf(a, sizeof a, "/tmp/wwd_cm_%d_c", getpid());
snprintf(b, sizeof b, "/tmp/wwd_cm_%d_w", getpid());
snprintf(cmd, sizeof cmd, "%s/w6c %s/%s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6c %s/%s > %s 2>/dev/null",
bin, cwd, files[i], a);
runwait(cmd);
snprintf(cmd, sizeof cmd, "%s/wwdump_ww -c %s/%s > %s 2>/dev/null",
snprintf(cmd, sizeof cmd, "timeout 180 %s/wwdump_ww -c %s/%s > %s 2>/dev/null",
bin, cwd, files[i], b);
runwait(cmd);
char *bc = NULL, *bw = NULL;