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,7 +1,7 @@
/*
* 796_xmod_valglobal_dot_run — project #229, the N_DOT-base read + addr-of
* sibling of #1 (test 795). Runtime + cs==ww byte-id net for the cross-
* module DOTTED value-global miscompile.
* sibling of #1 (test 795). Assembly byte-id net for the cross-module
* DOTTED value-global miscompile.
*
* THE BUG (cgen-only, both stages emit IDENTICAL wrong asm → byte-id was
* BLIND to it): #1 fixed the DATA def-site and the bare-ident load mangle,
@@ -19,15 +19,10 @@
* lhs.str / basenm). The TY_FN branches beside each site already use this
* dotted polarity via mafn/emitfnname; value globals now match.
*
* EACH ROW CARRIES BOTH DIMENSIONS (795 model):
* (a) cstage `ww build` + run, asserting the exit — pins the converged
* asm is runtime-correct.
* (b) w6c vs w6c_ww `.s` cmp — FAILS if the stages diverge. Necessary
* because the bug was byte-id-blind.
* Runtime ownership moved to the matching r796_* fixtures. This carrier
* retains the w6c vs w6c_ww `.s` comparison required by rule 10.
*
* GATE POLARITY: must stay GREEN. A wrong exit means the dotted value-
* global mangle regressed; a byte-id FAIL means the stages diverged
* (rule-10 violation).
* GATE POLARITY: a byte-id failure means the stages diverged.
*/
#include <stdio.h>
#include <stdlib.h>
@@ -109,56 +104,65 @@ main(void)
for (int i = 0; rows[i].src; i++, n++) {
char tmpdir[64];
snprintf(tmpdir, sizeof tmpdir, "/tmp/wwxmvd_%d_d_%d", getpid(), i);
mkdir(tmpdir, 0755);
/* an unowned dir must never be rm -rf'd below */
if (mkdir(tmpdir, 0755) != 0) {
perror(tmpdir);
fail++;
continue;
}
char src[128], outbin[128], cs_s[128], ws_s[128], rmcmd[160];
char src[128], cs_s[128], ws_s[128], rmcmd[160];
snprintf(src, sizeof src, "%s/wwxmvd_%d_%d.ww", tmpdir, getpid(), i);
snprintf(outbin, sizeof outbin, "%s/wwxmvd_%d_%d", tmpdir, getpid(), i);
snprintf(cs_s, sizeof cs_s, "%s/wwxmvd_%d_%d_cs.s", tmpdir, getpid(), i);
snprintf(ws_s, sizeof ws_s, "%s/wwxmvd_%d_%d_ww.s", tmpdir, getpid(), i);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
FILE *f = fopen(src, "wb");
if (f == NULL) { fail++; runwait(rmcmd); continue; }
if (f == NULL) {
fail++;
if (runwait(rmcmd) != 0)
fprintf(stderr, "row[%s]: cleanup failed: %s\n",
rows[i].label, rmcmd);
continue;
}
fputs(rows[i].src, f);
fclose(f);
/* (a) cstage build + run. */
char cmd[2048];
snprintf(cmd, sizeof cmd, "%s/ww build -o %s %s", bin, outbin, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "row[%s]: cstage build failed\n",
rows[i].label);
fail++;
runwait(rmcmd);
continue;
}
int got = runwait(outbin);
if (got != rows[i].want_exit) {
fprintf(stderr, "row[%s]: cstage exit %d, want %d\n",
rows[i].label, got, rows[i].want_exit);
fail++;
}
/* (b) cs==ww byte-id gate. */
/* Runtime ownership is r79_xmod_valglobal_dot_*; retain byte-id. */
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", w6c, cs_s, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "row[%s]: w6c failed\n", rows[i].label);
fail++; runwait(rmcmd); continue;
fail++;
if (runwait(rmcmd) != 0)
fprintf(stderr, "row[%s]: cleanup failed: %s\n",
rows[i].label, rmcmd);
continue;
}
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null",
w6c_ww, ws_s, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "row[%s]: w6c_ww failed\n", rows[i].label);
fail++; runwait(rmcmd); continue;
fail++;
if (runwait(rmcmd) != 0)
fprintf(stderr, "row[%s]: cleanup failed: %s\n",
rows[i].label, rmcmd);
continue;
}
if (slurp_eq(cs_s, ws_s) != 0) {
int rowdiff = slurp_eq(cs_s, ws_s) != 0;
if (rowdiff) {
fprintf(stderr, "row[%s]: cstage/wwstage .s DIFFER "
"(rule-10 byte-id violation)\n", rows[i].label);
fail++;
}
runwait(rmcmd);
/* a leaked tmpdir fails an otherwise-green row without
* masking the byte-id verdict. */
if (runwait(rmcmd) != 0) {
fprintf(stderr, "row[%s]: cleanup failed: %s\n",
rows[i].label, rmcmd);
if (!rowdiff)
fail++;
}
}
if (fail) {
@@ -166,7 +170,7 @@ main(void)
fail, n);
return 1;
}
printf("xmod_valglobal_dot: %d/%d ok (cstage run + cs==ww byte-id)\n",
printf("xmod_valglobal_dot: %d/%d ok (cs==ww byte-id)\n",
n, n);
return 0;
}