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

@@ -135,20 +135,23 @@ static const struct row rows[] = {
0 },
};
/* Compile the combined.ww (left next to the source by `ww build`) with
* both compilers and assert byte-identical asm. Returns 0 ok, 1 differ,
* -1 harness error. */
/* #94 sep layout: concat the per-package asm the cstage sep build emitted
* (<dir>/gsret_c_<i>.sepwork) and the wwstage sep build emitted
* (<dir>/gsret_w_<i>.sepwork), then assert byte-identical. Returns 0 ok,
* 1 differ, -1 harness error. */
static int
byteid(const char *bin, const char *combined, const char *dir, int i)
byteid(const char *dir, int i)
{
char cs[256], ws[256], cmd[1024];
snprintf(cs, sizeof cs, "%s/bid_cs_%d.s", dir, i);
snprintf(ws, sizeof ws, "%s/bid_ww_%d.s", dir, i);
snprintf(cmd, sizeof cmd, "%s/w6c %s > %s", bin, combined, cs);
if (runwait(cmd) != 0) return -1;
snprintf(cmd, sizeof cmd, "%s/w6c_ww %s > %s", bin, combined, ws);
if (runwait(cmd) != 0) return -1;
snprintf(cmd, sizeof cmd, "cat %s/gsret_c_%d.sepwork/*.s > %s 2>/dev/null",
dir, i, cs);
if (system(cmd)) {}
snprintf(cmd, sizeof cmd, "cat %s/gsret_w_%d.sepwork/*.s > %s 2>/dev/null",
dir, i, ws);
if (system(cmd)) {}
snprintf(cmd, sizeof cmd, "cmp -s %s %s", cs, ws);
int rc = runwait(cmd);
@@ -156,12 +159,12 @@ byteid(const char *bin, const char *combined, const char *dir, int i)
return rc == 0 ? 0 : 1;
}
/* Build `r` with `driver` in `dir`, run the binary, return its exit
* code (or -1 on build failure). `combined_out` receives the path of
* the generated <stem>.combined.ww. */
/* Build `r` with `driver` via `--sep -o <dir>/<stem>` (per-package asm in
* <dir>/<stem>.sepwork/), run the binary, return its exit code (or -1 on
* build failure). `cachetag` keys a private WW_PKGCACHE. */
static int
run_driver(const char *driver, const struct row *r, const char *dir,
int i, char *combined_out, size_t combined_sz)
int i, const char *stem, const char *cachetag)
{
char src[256], cmd[1024];
snprintf(src, sizeof src, "%s/gsret_%d.ww", dir, i);
@@ -171,7 +174,9 @@ run_driver(const char *driver, const struct row *r, const char *dir,
fputs(r->src, f);
fclose(f);
snprintf(cmd, sizeof cmd, "cd %s && %s build %s", dir, driver, src);
snprintf(cmd, sizeof cmd,
"cd %s && WW_PKGCACHE=%s/pkgc_%s %s build --sep -o %s/%s %s",
dir, dir, cachetag, driver, dir, stem, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "row[%s]: build via %s failed\n",
r->label, driver);
@@ -179,10 +184,7 @@ run_driver(const char *driver, const struct row *r, const char *dir,
}
char outbin[256];
snprintf(outbin, sizeof outbin, "%s/gsret_%d", dir, i);
if (combined_out)
snprintf(combined_out, combined_sz,
"%s/gsret_%d.combined.ww", dir, i);
snprintf(outbin, sizeof outbin, "%s/%s", dir, stem);
return runwait(outbin);
}
@@ -217,12 +219,8 @@ main(void)
int total = 0, fail = 0;
for (int i = 0; i < n; i++) {
char combined[300];
combined[0] = '\0';
/* cstage: build + run + capture combined.ww path. */
int gc = run_driver(cdrv, &rows[i], dir, i,
combined, sizeof combined);
/* cstage: --sep build + run → <dir>/gsret_c_<i>.sepwork/. */
int gc = run_driver(cdrv, &rows[i], dir, i, "gsret_c", "c");
total++;
if (gc != rows[i].want) {
fprintf(stderr, "global_sret_run[cstage][%s]: "
@@ -231,21 +229,9 @@ main(void)
fail++;
}
/* byte-id (rule 10): cs.s == ww.s on the same combined.ww. */
if (have_wwc && combined[0]) {
total++;
int bid = byteid(bin, combined, dir, i);
if (bid != 0) {
fprintf(stderr, "global_sret_run[byteid][%s]: "
"%s\n", rows[i].label,
bid == 1 ? "cs.s != ww.s" : "harness error");
fail++;
}
}
/* wwstage: build + run. */
/* wwstage: --sep build + run → <dir>/gsret_w_<i>.sepwork/. */
if (have_ww) {
int gw = run_driver(wdrv, &rows[i], dir, i, NULL, 0);
int gw = run_driver(wdrv, &rows[i], dir, i, "gsret_w", "w");
total++;
if (gw != rows[i].want) {
fprintf(stderr, "global_sret_run[wwstage][%s]: "
@@ -253,14 +239,29 @@ main(void)
rows[i].want);
fail++;
}
/* byte-id (rule 10): the per-package w6c asm (cstage sep
* build) == the w6c_ww asm (wwstage sep build). */
if (have_wwc) {
total++;
int bid = byteid(dir, i);
if (bid != 0) {
fprintf(stderr, "global_sret_run[byteid][%s]: "
"%s\n", rows[i].label,
bid == 1 ? "cs.s != ww.s"
: "harness error");
fail++;
}
}
}
char p[256];
char p[640];
snprintf(p, sizeof p, "%s/gsret_%d.ww", dir, i); unlink(p);
snprintf(p, sizeof p, "%s/gsret_%d", dir, i); unlink(p);
snprintf(p, sizeof p, "%s/gsret_%d.combined.ww", dir, i); unlink(p);
snprintf(p, sizeof p, "%s/gsret_%d.s", dir, i); unlink(p);
snprintf(p, sizeof p, "%s/gsret_%d.o", dir, i); unlink(p);
snprintf(p, sizeof p, "rm -rf %s/gsret_c_%d.sepwork "
"%s/gsret_w_%d.sepwork %s/gsret_c_%d %s/gsret_w_%d "
"%s/pkgc_c %s/pkgc_w", dir, i, dir, i, dir, i, dir, i,
dir, dir);
if (system(p)) {}
}
rmdir(dir);