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

@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
@@ -67,22 +68,23 @@ main(void)
* private /tmp stem (NOT next to the tracked example source), then
* link <stem>.sepwork/__root.o — the self-contained single-package
* object the flip emits in place of the old next-to-source .o. */
char cmd[4096], mbstem[256], mbobj[320];
char cmd[4096], mbstem[256], mbobj[320], co[64], wo[64];
snprintf(mbstem, sizeof mbstem, "/tmp/wwld_%d_mb", getpid());
snprintf(mbobj, sizeof mbobj, "%s.sepwork/__root.o", mbstem);
snprintf(co, sizeof co, "/tmp/wwld_%d_c", getpid());
snprintf(wo, sizeof wo, "/tmp/wwld_%d_w", getpid());
int rc = 0;
snprintf(cmd, sizeof cmd,
"cd %s/examples/mandelbrot && %s/ww build "
"-o %s mandelbrot.ww -L /usr/lib -l c >/dev/null 2>&1",
cwd, bin, mbstem);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: cannot build mandelbrot.o via C driver\n");
return 1;
rc = 1;
goto cleanup;
}
char co[64], wo[64];
snprintf(co, sizeof co, "/tmp/wwld_%d_c", getpid());
snprintf(wo, sizeof wo, "/tmp/wwld_%d_w", getpid());
/* C-side w6l with the dynamic flags. */
snprintf(cmd, sizeof cmd,
"%s/w6l -o %s %s -L /usr/lib "
@@ -90,8 +92,8 @@ main(void)
bin, co, mbobj, cwd);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: C w6l errored\n");
unlink(co);
return 1;
rc = 1;
goto cleanup;
}
/* ww-side w6l with the same flags. */
@@ -101,16 +103,18 @@ main(void)
bin, wo, mbobj, cwd);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: ww w6l errored\n");
unlink(co); unlink(wo);
return 1;
rc = 1;
goto cleanup;
}
char *bc = NULL, *bw = NULL;
size_t nc = 0, nw = 0;
int rc = 0;
if (slurp(co, &bc, &nc) < 0 || slurp(wo, &bw, &nw) < 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: cannot read outputs\n");
rc = 1;
} else if (nc == 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: empty outputs\n");
rc = 1;
} else if (nc != nw || memcmp(bc, bw, nc) != 0) {
fprintf(stderr, "w6l_ww-dyn FAIL: C %zu vs ww %zu bytes\n",
nc, nw);
@@ -121,9 +125,24 @@ main(void)
"%zu bytes)\n", nc);
}
free(bc); free(bw);
unlink(co); unlink(wo);
/* #93: the sep scratch + tmpdir-owned outputs. */
snprintf(cmd, sizeof cmd, "rm -rf %s.sepwork %s", mbstem, mbstem);
if (system(cmd)) {}
cleanup:
/* #93: `ww build` retains this exact caller-owned scratch tree. */
snprintf(cmd, sizeof cmd, "rm -rf %s.sepwork", mbstem);
int cleanfail = runwait(cmd) != 0;
if (unlink(co) != 0 && errno != ENOENT) {
perror(co);
cleanfail = 1;
}
if (unlink(wo) != 0 && errno != ENOENT) {
perror(wo);
cleanfail = 1;
}
if (unlink(mbstem) != 0 && errno != ENOENT) {
perror(mbstem);
cleanfail = 1;
}
if (cleanfail && rc == 0)
rc = 1;
return rc;
}