test/wcc: extend carrier ownership to the bootstrap and platform gates

Same contract as the 27 repaired byte/artifact survivors: checked
acquisition, one all-exit cleanup funnel per carrier, ENOENT-tolerant
checked unlinks, exact-path deletion, and cleanup failure fails a
passing carrier without overwriting its diagnostic. Also closes the
vacuous-green channels: empty-artifact pairs no longer byte-compare
equal, capture and staging failures fail their row loudly, 950 requires
a clean checker exit on no-error rows and hard-fails on a missing
wwdump_ww, 992 keys its scratch per invocation so a failed cleanup
cannot leak stale objects into the next tool's compare, and 995 no
longer pre-sweeps a workdir it never created. No assertion is weakened;
990_selfhost is retired in the next commit rather than repaired.
This commit is contained in:
2026-08-07 23:28:49 +09:00
parent a87d931096
commit cdc8bda721
7 changed files with 332 additions and 105 deletions

View File

@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
@@ -68,11 +69,15 @@ slurp(const char *path, char **outbuf, size_t *outlen)
* + reverse-topo .a resolution — a stronger link than the old single
* main.o. */
static int
build_and_diff(const char *bin, const char *cwd, const char *tool)
build_and_diff(const char *bin, const char *cwd, const char *tool, int id)
{
char cstem[256], wstem[256], cmd[4096];
snprintf(cstem, sizeof cstem, "/tmp/wwl_%d_c", getpid());
snprintf(wstem, sizeof wstem, "/tmp/wwl_%d_w", getpid());
snprintf(cstem, sizeof cstem, "/tmp/wwl_%d_%d_c", getpid(), id);
snprintf(wstem, sizeof wstem, "/tmp/wwl_%d_%d_w", getpid(), id);
char *bc = NULL, *bw = NULL;
size_t nc = 0, nw = 0;
int rc = 0;
snprintf(cmd, sizeof cmd,
"timeout 300 %s/ww build -o %s "
@@ -80,7 +85,8 @@ build_and_diff(const char *bin, const char *cwd, const char *tool)
bin, cstem, cwd, tool);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww FAIL: C-link sep-build of %s\n", tool);
return -1;
rc = -1;
goto cleanup;
}
snprintf(cmd, sizeof cmd,
"WW_W6L=%s/w6l_ww timeout 300 %s/ww build "
@@ -88,25 +94,43 @@ build_and_diff(const char *bin, const char *cwd, const char *tool)
bin, bin, wstem, cwd, tool);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww FAIL: ww-link sep-build of %s\n", tool);
snprintf(cmd, sizeof cmd, "rm -rf %s %s.sepwork", cstem, cstem);
if (system(cmd)) {}
return -1;
rc = -1;
goto cleanup;
}
char *bc = NULL, *bw = NULL;
size_t nc = 0, nw = 0;
int rc = 0;
if (slurp(cstem, &bc, &nc) < 0 || slurp(wstem, &bw, &nw) < 0) {
fprintf(stderr, "w6l_ww FAIL: cannot read output for %s\n", tool);
rc = -1;
} else if (nc == 0) {
fprintf(stderr, "w6l_ww FAIL: empty output for %s\n", tool);
rc = -1;
} else if (nc != nw || memcmp(bc, bw, nc) != 0) {
fprintf(stderr, "w6l_ww FAIL: %s — C %zu vs ww %zu bytes\n",
tool, nc, nw);
rc = -1;
}
free(bc); free(bw);
snprintf(cmd, sizeof cmd, "rm -rf %s %s %s.sepwork %s.sepwork",
cstem, wstem, cstem, wstem);
if (system(cmd)) {}
cleanup:
/* `ww build` retains these exact caller-owned scratch trees; a
* never-created pid+id-keyed path is harmless to remove, so one
* funnel covers every exit. */
int cleanfail = 0;
if (unlink(cstem) != 0 && errno != ENOENT) {
perror(cstem);
cleanfail = 1;
}
if (unlink(wstem) != 0 && errno != ENOENT) {
perror(wstem);
cleanfail = 1;
}
snprintf(cmd, sizeof cmd, "rm -rf %s.sepwork %s.sepwork",
cstem, wstem);
if (runwait(cmd) != 0)
cleanfail = 1;
if (cleanfail)
fprintf(stderr, "w6l_ww: cleanup failed for %s\n", tool);
if (cleanfail && rc == 0)
rc = -1;
return rc;
}
@@ -130,7 +154,7 @@ main(void)
int fail = 0;
int n = 0;
for (int i = 0; tools[i]; i++) {
if (build_and_diff(bin, cwd, tools[i]) != 0) fail++;
if (build_and_diff(bin, cwd, tools[i], i) != 0) fail++;
n++;
}
if (fail) {