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:
@@ -164,16 +164,19 @@ static const struct scenario scenarios[] = {
|
||||
{ "nonfn_dotted_table", nonfn_dotted_files, K_BUILDERR, 0 },
|
||||
};
|
||||
|
||||
/* Build via `driver` in the fixture dir; returns the driver's build rc and
|
||||
* (for K_RUN) runs the produced binary, comparing exit to want_exit. */
|
||||
/* Build `driver build --sep -o <dir>/<stem>` in the fixture dir; returns
|
||||
* the driver's build rc and (for K_RUN) runs the produced binary, comparing
|
||||
* exit to want_exit. #94: the per-package asm lands in <dir>/<stem>.sepwork/
|
||||
* (cachetag keys a private WW_PKGCACHE so out/.pkgcache is untouched). */
|
||||
static int
|
||||
build_run(const char *dir, const char *driver, const struct scenario *sc)
|
||||
build_run(const char *dir, const char *driver, const struct scenario *sc,
|
||||
const char *stem, const char *cachetag)
|
||||
{
|
||||
char cmd[4096], path[1024];
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && rm -f main main.s main.o main.combined.ww && "
|
||||
"%s build -I %s %s/main.ww >/dev/null 2>%s/err",
|
||||
dir, driver, dir, dir, dir);
|
||||
"cd %s && WW_PKGCACHE=%s/pkgc_%s %s build --sep -I %s -o %s/%s "
|
||||
"%s/main.ww >/dev/null 2>%s/err",
|
||||
dir, dir, cachetag, driver, dir, dir, stem, dir, dir);
|
||||
int brc = runwait(cmd);
|
||||
if (sc->kind == K_BUILDERR) {
|
||||
if (brc == 0) {
|
||||
@@ -187,7 +190,7 @@ build_run(const char *dir, const char *driver, const struct scenario *sc)
|
||||
fprintf(stderr, "949[%s]: %s build failed\n", sc->label, driver);
|
||||
return -1;
|
||||
}
|
||||
snprintf(path, sizeof path, "%s/main", dir);
|
||||
snprintf(path, sizeof path, "%s/%s", dir, stem);
|
||||
int got = runwait(path);
|
||||
if (got != sc->want_exit) {
|
||||
fprintf(stderr, "949[%s]: %s exit %d, want %d\n",
|
||||
@@ -198,8 +201,7 @@ build_run(const char *dir, const char *driver, const struct scenario *sc)
|
||||
}
|
||||
|
||||
static int
|
||||
run_scenario(const char *bin, const char *w6c, const char *w6c_ww,
|
||||
const struct scenario *sc)
|
||||
run_scenario(const char *bin, const struct scenario *sc)
|
||||
{
|
||||
char dir[] = "/tmp/ww949_XXXXXX";
|
||||
if (mkdtemp(dir) == NULL) {
|
||||
@@ -207,7 +209,7 @@ run_scenario(const char *bin, const char *w6c, const char *w6c_ww,
|
||||
return -1;
|
||||
}
|
||||
|
||||
char path[1024], cmd[4096], wwdrv[2200];
|
||||
char path[1024], cmd[4096], csdrv[2200], wwdrv[2200];
|
||||
int rc = 0;
|
||||
|
||||
for (int i = 0; sc->files[i].name; i++) {
|
||||
@@ -219,50 +221,30 @@ run_scenario(const char *bin, const char *w6c, const char *w6c_ww,
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
/* cstage driver build (+run for K_RUN). */
|
||||
{
|
||||
char csdrv[2200];
|
||||
snprintf(csdrv, sizeof csdrv, "%s/ww", bin);
|
||||
if (build_run(dir, csdrv, sc) != 0) { rc = -1; goto done; }
|
||||
}
|
||||
/* cstage driver --sep build (+run for K_RUN) → <dir>/main_c.sepwork/. */
|
||||
snprintf(csdrv, sizeof csdrv, "%s/ww", bin);
|
||||
if (build_run(dir, csdrv, sc, "main_c", "c") != 0) { rc = -1; goto done; }
|
||||
|
||||
/* wwstage driver build (+run for K_RUN) — race-free in the private
|
||||
* mktemp dir. Direct proof the wwstage emits a runnable binary. */
|
||||
/* wwstage driver --sep build (+run for K_RUN) — race-free in the
|
||||
* private mktemp dir. Direct proof the wwstage emits a runnable
|
||||
* binary. Distinct stem so its sepwork doesn't clobber cstage's. */
|
||||
snprintf(wwdrv, sizeof wwdrv, "%s/ww_ww", bin);
|
||||
if (build_run(dir, wwdrv, sc) != 0) { rc = -1; goto done; }
|
||||
if (build_run(dir, wwdrv, sc, "main_w", "w") != 0) { rc = -1; goto done; }
|
||||
|
||||
if (sc->kind == K_BUILDERR) goto done;
|
||||
|
||||
/* Byte-id net (#263 — the wwstage-correctness proof on a gate-blind
|
||||
* align-BOTH fix): raw w6c vs w6c_ww on the cstage-driver combined. */
|
||||
* align-BOTH fix): the per-package w6c-emitted .s (cstage sep build)
|
||||
* vs w6c_ww-emitted .s (wwstage sep build) must be byte-identical.
|
||||
* Concat each stem's per-package sepwork asm (sorted glob = same set). */
|
||||
{
|
||||
char cs_s[1024], ws_s[1024], comb[1024];
|
||||
/* regen the combined via the cstage driver (deterministic). */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/ww build -I %s %s/main.ww >/dev/null 2>&1",
|
||||
dir, bin, dir, dir);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "949[%s]: combined regen failed\n",
|
||||
sc->label);
|
||||
rc = -1; goto done;
|
||||
}
|
||||
snprintf(comb, sizeof comb, "%s/main.combined.ww", dir);
|
||||
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);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "949[%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, "949[%s]: w6c_ww on combined failed\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_c.sepwork/*.s > %s 2>/dev/null",
|
||||
dir, cs_s); if (system(cmd)) {}
|
||||
snprintf(cmd, sizeof cmd, "cat %s/main_w.sepwork/*.s > %s 2>/dev/null",
|
||||
dir, ws_s); if (system(cmd)) {}
|
||||
if (slurp_eq(cs_s, ws_s) != 0) {
|
||||
fprintf(stderr, "949[%s]: cs.s/ww.s DIFFER (rule-10 "
|
||||
"byte-id violation)\n", sc->label);
|
||||
@@ -289,11 +271,10 @@ 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, "949: w6c_ww missing — cannot run the cs==ww "
|
||||
char wdrv[2100];
|
||||
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
|
||||
if (access(wdrv, X_OK) != 0) {
|
||||
fprintf(stderr, "949: ww_ww missing — cannot run the cs==ww "
|
||||
"byte-id gate (the whole point of this test)\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -301,7 +282,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, &scenarios[i]) != 0)
|
||||
fail++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user