test: retarget Pattern-A combined-feed gates to sep .sepwork layout (M4 E3, #94)

94a of the C-mig2 split (rob rule-11): 13 Pattern-A gates that fed a
.combined.ww to w6c/w6c_ww now drive two --sep builds (ww / ww_ww) and
byte-diff the concatenated per-package .sepwork/*.s, mirroring #93's
convention. Lands pre-flip while combined.ww still exists as the
reversible safety net. Test-only; all 5 binary pins HOLD.

989_enumcap_run deferred to 94b (its decisive assertion is a combined.ww
content diff, not a .s diff).
This commit is contained in:
2026-06-18 16:44:41 +09:00
parent 7b6f24adea
commit bbd2ad390a
14 changed files with 377 additions and 391 deletions

View File

@@ -223,9 +223,10 @@ static const struct scenario scenarios[] = {
};
static int
run_scenario(const char *bin, const char *w6c, const char *w6c_ww,
run_scenario(const char *bin, const char *cdrv, const char *wdrv,
const struct scenario *sc)
{
(void)bin;
char dir[] = "/tmp/ww787_XXXXXX";
if (mkdtemp(dir) == NULL) {
fprintf(stderr, "787[%s]: mkdtemp failed\n", sc->label);
@@ -244,48 +245,37 @@ run_scenario(const char *bin, const char *w6c, const char *w6c_ww,
fclose(f);
}
char comb[1024];
snprintf(comb, sizeof comb, "%s/main.combined.ww", dir);
if (sc->expect_reject) {
/* The driver build MUST fail (cstage's checker rejects the
* foreign-qualifier variant), but expand() still writes the
* combined unit before the checker runs — so re-check it with
* BOTH backends and require BOTH to reject. w6c_ww accepting
/* #94 sep layout: there is no combined unit to re-check. The
* checker reject now fires inside each driver's --sep w6c pass,
* so BOTH driver builds MUST fail. w6c_ww (via ww_ww) accepting
* here is the #13 false-ACCEPT regression. */
char xs[1024];
snprintf(xs, sizeof xs, "%s/x.s", dir);
snprintf(cmd, sizeof cmd,
"cd %s && %s/ww build -I %s %s/main.ww >/dev/null 2>&1",
dir, bin, dir, dir);
"cd %s && WW_PKGCACHE=%s/pkgc_c %s build --sep -I %s "
"-o %s/main %s/main.ww >/dev/null 2>&1",
dir, dir, cdrv, dir, dir, dir);
if (runwait(cmd) == 0) {
fprintf(stderr, "787[%s]: cstage build SUCCEEDED, "
"expected reject\n", sc->label);
rc = -1; goto done;
}
if (access(comb, 0) != 0) {
fprintf(stderr, "787[%s]: no combined.ww to re-check\n",
sc->label);
rc = -1; goto done;
}
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", w6c, xs, comb);
snprintf(cmd, sizeof cmd,
"cd %s && WW_PKGCACHE=%s/pkgc_w %s build --sep -I %s "
"-o %s/mainww %s/main.ww >/dev/null 2>&1",
dir, dir, wdrv, dir, dir, dir);
if (runwait(cmd) == 0) {
fprintf(stderr, "787[%s]: w6c ACCEPTED foreign variant, "
"expected reject\n", sc->label);
rc = -1; goto done;
}
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", w6c_ww, xs, comb);
if (runwait(cmd) == 0) {
fprintf(stderr, "787[%s]: w6c_ww ACCEPTED foreign variant "
fprintf(stderr, "787[%s]: ww_ww ACCEPTED foreign variant "
"(#13 false-accept), expected reject\n", sc->label);
rc = -1; goto done;
}
goto done;
}
/* cstage driver build + run: pins runtime routing. */
snprintf(cmd, sizeof cmd, "cd %s && %s/ww build -I %s %s/main.ww",
dir, bin, dir, dir);
/* cstage driver --sep build + run: pins runtime routing. Pin
* WW_PKGCACHE under the scratch dir so out/.pkgcache is untouched. */
snprintf(cmd, sizeof cmd,
"cd %s && WW_PKGCACHE=%s/pkgc_c %s build --sep -I %s -o %s/main %s/main.ww",
dir, dir, cdrv, dir, dir, dir);
if (runwait(cmd) != 0) {
fprintf(stderr, "787[%s]: cstage build failed\n", sc->label);
rc = -1; goto done;
@@ -298,24 +288,27 @@ run_scenario(const char *bin, const char *w6c, const char *w6c_ww,
rc = -1;
}
/* The #13 discriminator: raw w6c_ww on the driver-produced
* combined.ww. Pre-fix the wwstage checker REJECTED the
* cross-module variant arms (non-zero exit here). Post-fix it
* accepts AND is byte-id with cstage's w6c. */
char cs_s[1024], ws_s[1024];
snprintf(cs_s, sizeof cs_s, "%s/cs.s", dir);
snprintf(ws_s, sizeof ws_s, "%s/ww.s", dir);
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", w6c, cs_s, comb);
/* The #13 discriminator: the wwstage driver's --sep build runs the
* wwstage checker over the same units. Pre-fix it REJECTED the
* cross-module variant arms (build fails); post-fix it accepts AND
* its per-package w6c_ww asm is byte-id with cstage's. The root +
* each imported pkg compile to separate <stem>.sepwork/<pkg>.s;
* concat (sorted glob, identical set both stages) for the compare. */
snprintf(cmd, sizeof cmd,
"cd %s && WW_PKGCACHE=%s/pkgc_w %s build --sep -I %s -o %s/mainww %s/main.ww",
dir, dir, wdrv, dir, dir, dir);
if (runwait(cmd) != 0) {
fprintf(stderr, "787[%s]: w6c on combined failed\n", sc->label);
rc = -1; goto done;
}
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", w6c_ww, ws_s, comb);
if (runwait(cmd) != 0) {
fprintf(stderr, "787[%s]: w6c_ww on combined failed "
fprintf(stderr, "787[%s]: ww_ww build failed "
"(#13 cross-module variant reject?)\n", sc->label);
rc = -1; goto done;
}
char cs_s[1024], ws_s[1024];
snprintf(cs_s, sizeof cs_s, "%s/all_cs.s", dir);
snprintf(ws_s, sizeof ws_s, "%s/all_ww.s", dir);
snprintf(cmd, sizeof cmd, "cat %s/main.sepwork/*.s > %s 2>/dev/null",
dir, cs_s); if (system(cmd)) {}
snprintf(cmd, sizeof cmd, "cat %s/mainww.sepwork/*.s > %s 2>/dev/null",
dir, ws_s); if (system(cmd)) {}
if (slurp_eq(cs_s, ws_s) != 0) {
fprintf(stderr, "787[%s]: cs.s/ww.s DIFFER (rule-10 byte-id "
"violation)\n", sc->label);
@@ -341,11 +334,11 @@ main(void)
bin = absbin;
}
char w6c[2100], w6c_ww[2100];
snprintf(w6c, sizeof w6c, "%s/w6c", bin);
snprintf(w6c_ww, sizeof w6c_ww, "%s/w6c_ww", bin);
if (access(w6c_ww, X_OK) != 0) {
fprintf(stderr, "787: w6c_ww missing — cannot run the cs==ww "
char cdrv[2100], wdrv[2100];
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
if (access(wdrv, X_OK) != 0) {
fprintf(stderr, "787: ww_ww missing — cannot run the cs==ww "
"byte-id gate (the whole point of this test)\n");
return 1;
}
@@ -353,7 +346,7 @@ main(void)
int n = (int)(sizeof scenarios / sizeof scenarios[0]);
int fail = 0;
for (int i = 0; i < n; i++) {
if (run_scenario(bin, w6c, w6c_ww, &scenarios[i]) != 0)
if (run_scenario(bin, cdrv, wdrv, &scenarios[i]) != 0)
fail++;
}