test/wcc: carrier ownership repair and driver-contract adaptation

Every surviving carrier now owns its artifacts: checked mkdir/mkdtemp/
fopen acquisition, one all-exit cleanup funnel per carrier, ENOENT-
tolerant checked unlinks, exact-path deletion (rm -rf only for an
owned pid-keyed dir or a .sepwork beneath one), and cleanup failure
fails a passing carrier without overwriting its diagnostic. In the
same pass the carriers adapt to the driver contract this branch lands:
--sep and WW_PKGCACHE are gone, -S and the /tmp/ww_run_<pid> scratch
contract are asserted, and rows whose runtime or reject coverage moved
to test/wcc/data fixtures or test/lang @test owners are trimmed to the
byte/artifact/diagnostic observations only they can make.

Repair and adaptation ride together because most files interleave both
in the same hunks; splitting would manufacture intermediate carrier
states that never existed and cannot run against either driver.
This commit is contained in:
2026-08-07 23:02:47 +09:00
parent b2899dd8d3
commit a95a7a316b
132 changed files with 7573 additions and 6172 deletions

View File

@@ -1,5 +1,5 @@
/*
* 992_w6l_ww — phase-10 marker for the ww-side w6l port.
* 992_w6l_ww — explicit bootstrap gate for the ww-side w6l port.
*
* Diffs the C-built `w6l` against the ww-built `w6l_ww` on a corpus of
* link inputs. Both must produce byte-identical static ELF binaries.
@@ -60,32 +60,32 @@ slurp(const char *path, char **outbuf, size_t *outlen)
* the linkable unit is now the per-package .o + reverse-topo .a set the
* sep driver assembles (a raw `w6l <root>.o *.a libwwrt.a` from the test
* side fails — `undefined reference` — because it can't reproduce the
* driver's topo order). So isolate the LINKER by driving the sep build's
* own link step twice over identical .o inputs (a shared pkgcache makes
* the second build's package objects a cache hit → only the final link
* re-runs): once with the default C w6l, once with WW_W6L=w6l_ww. Diff
* driver's topo order). The tools are legacy inline-package directories,
* so their explicit main.ww files remain the compatibility roots. Drive
* the full sep build twice; both compile directly and differ only in the
* linker: once with the default C w6l, once with WW_W6L=w6l_ww. Diff
* the two real tool binaries. Exercises the full archive two-pass loader
* + reverse-topo .a resolution — a stronger link than the old single
* main.o. Flip-invariant: --sep is live on trunk, default post-flip. */
* main.o. */
static int
build_and_diff(const char *bin, const char *cwd, const char *tool,
const char *cache)
build_and_diff(const char *bin, const char *cwd, const char *tool)
{
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(cmd, sizeof cmd,
"WW_PKGCACHE=%s timeout 300 %s/ww build --sep -o %s "
"%s/selfhost/cmd/%s >/dev/null 2>&1", cache, bin, cstem, cwd, tool);
"timeout 300 %s/ww build -o %s "
"%s/selfhost/cmd/%s/main.ww >/dev/null 2>&1",
bin, cstem, cwd, tool);
if (runwait(cmd) != 0) {
fprintf(stderr, "w6l_ww FAIL: C-link sep-build of %s\n", tool);
return -1;
}
snprintf(cmd, sizeof cmd,
"WW_W6L=%s/w6l_ww WW_PKGCACHE=%s timeout 300 %s/ww build --sep "
"-o %s %s/selfhost/cmd/%s >/dev/null 2>&1",
bin, cache, bin, wstem, cwd, tool);
"WW_W6L=%s/w6l_ww timeout 300 %s/ww build "
"-o %s %s/selfhost/cmd/%s/main.ww >/dev/null 2>&1",
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);
@@ -120,25 +120,19 @@ main(void)
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
/* Real bootstrap-style links: each selfhost tool's full sep build
* (root .o + reverse-topo dep .a set + libwwrt.a). One shared
* pkgcache across all builds so each tool's second (w6l_ww) build
* re-links only. (wwdump is excluded — it imports the compiler-
* internal cmd packages syntax/check/cgen, which don't resolve
* (root .o + reverse-topo dep .a set + libwwrt.a). Both builds compile
* directly and differ only in the selected linker. (wwdump is excluded —
* it imports the compiler-internal cmd packages syntax/check/cgen, which don't resolve
* under the lib-path sep dep scan; w6a/w6l are self-contained
* lib-only tools.) */
const char *tools[] = { "w6a", "w6l", NULL };
char cache[256];
snprintf(cache, sizeof cache, "/tmp/wwl_%d_pkgc", getpid());
int fail = 0;
int n = 0;
for (int i = 0; tools[i]; i++) {
if (build_and_diff(bin, cwd, tools[i], cache) != 0) fail++;
if (build_and_diff(bin, cwd, tools[i]) != 0) fail++;
n++;
}
char rmc[320];
snprintf(rmc, sizeof rmc, "rm -rf %s", cache);
if (system(rmc)) {}
if (fail) {
fprintf(stderr, "w6l_ww: %d/%d diff(s) failed\n", fail, n);
return 1;