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

@@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <glob.h>
#include <sys/wait.h>
@@ -63,34 +64,47 @@ static int
diff_one(const char *bin, const char *src)
{
char co[64], wo[64], cmd[2048];
char *bc = NULL, *bw = NULL;
size_t nc = 0, nw = 0;
int rc = -1;
snprintf(co, sizeof co, "/tmp/wwa_%d_c.o", getpid());
snprintf(wo, sizeof wo, "/tmp/wwa_%d_w.o", getpid());
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6a -o %s %s 2>/dev/null", bin, co, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6a_ww FAIL: C w6a errored on %s\n", src);
unlink(co);
return -1;
goto cleanup;
}
snprintf(cmd, sizeof cmd, "timeout 180 %s/w6a_ww -o %s %s 2>/dev/null", bin, wo, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6a_ww FAIL: ww w6a errored on %s\n", src);
unlink(co); unlink(wo);
return -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, "w6a_ww FAIL: cannot read .o for %s\n", src);
rc = -1;
} else if (nc == 0) {
fprintf(stderr, "w6a_ww FAIL: empty .o for %s\n", src);
} else if (nc != nw || memcmp(bc, bw, nc) != 0) {
fprintf(stderr, "w6a_ww FAIL: %s — C %zu vs ww %zu bytes\n",
src, nc, nw);
rc = -1;
}
} else
rc = 0;
cleanup:
free(bc); free(bw);
unlink(co); unlink(wo);
/* co/wo are reused across corpus files; a stale .o left behind
* would be slurped as a later file's output. */
int cleanfail = 0;
if (unlink(co) != 0 && errno != ENOENT) {
perror(co);
cleanfail = 1;
}
if (unlink(wo) != 0 && errno != ENOENT) {
perror(wo);
cleanfail = 1;
}
if (cleanfail && rc == 0)
rc = -1;
return rc;
}
@@ -112,6 +126,9 @@ main(void)
* intentionally contains package main plus legacy file-import packages,
* so it is not a directory-package root. */
char stem[256], cmd[4096];
int fail = 0;
int n = 0;
int gen = 0;
snprintf(stem, sizeof stem, "/tmp/wwa_%d_sh", getpid());
snprintf(cmd, sizeof cmd,
"timeout 400 %s/ww build -o %s "
@@ -120,7 +137,9 @@ main(void)
if (runwait(cmd) != 0) {
fprintf(stderr,
"w6a_ww FAIL: cannot sep-build selfhost/cmd/w6a/main.ww\n");
return 1;
/* a failed build can leave a partial stem/.sepwork tree. */
fail = 1;
goto cleanup;
}
/* hand-written runtime — small, covers MOVQ/LEAQ/CALL/SYSCALL/RET;
@@ -129,8 +148,6 @@ main(void)
"rt/start.s", "rt/syscall.s", "rt/abort.s",
"rt/alloc.s", "rt/streq.s", NULL,
};
int fail = 0;
int n = 0;
for (int i = 0; rtfiles[i]; i++) {
char p[2048];
snprintf(p, sizeof p, "%s/%s", cwd, rtfiles[i]);
@@ -152,17 +169,32 @@ main(void)
if (sz <= 0) continue;
if (diff_one(bin, g.gl_pathv[i]) != 0) fail++;
n++;
gen++;
}
globfree(&g);
}
/* the PASS banner claims generated-asm coverage; an empty glob
* (or all-empty units) must not go green on the rt corpus alone. */
if (gen == 0) {
fprintf(stderr,
"w6a_ww FAIL: no non-empty generated .s under %s.sepwork\n",
stem);
fail++;
}
cleanup:
snprintf(cmd, sizeof cmd, "rm -rf %s.sepwork %s", stem, stem);
if (system(cmd)) {}
int cleanfail = runwait(cmd) != 0;
if (cleanfail)
fprintf(stderr, "w6a_ww: cleanup of %s{,.sepwork} failed\n",
stem);
if (fail) {
fprintf(stderr, "w6a_ww: %d/%d diff(s) failed\n", fail, n);
return 1;
}
if (cleanfail)
return 1;
printf("w6a_ww: byte-identical to C w6a on %d corpus files "
"(rt/*.s + selfhost/cmd/w6a sep-built .s)\n", n);
return 0;