From 107d31cc01400a41e4e036af6b7c60a2e5d0463a Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Thu, 18 Jun 2026 17:39:27 +0900 Subject: [PATCH] test: re-express 989_enumcap_run enumeratedir-cap gate to sep .sepwork layout (M4 E3, #94) 94c, the last C-mig piece. The #65 enumeratedir-cap gate built a 300-file bigmod dir (past the old 256 cap) and byte-compared cstage vs wwstage .combined.ww to prove both enumerate the complete file set. The flip deletes combined.ww, so the comparison now targets each stage's .sepwork/bigmod.unit.ww (one `package bigmod;` clause per enrolled file). count_pkgs asserts the full nfiles count and `cmp` byte-compares the two stages' unit, so a silent cap-drop on either side reddens both paths. >cap fixture unchanged. Test-only; all 5 binary pins HOLD. --- test/wcc/989_enumcap_run.c | 61 +++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/test/wcc/989_enumcap_run.c b/test/wcc/989_enumcap_run.c index 59f20eb9..7785e5c2 100644 --- a/test/wcc/989_enumcap_run.c +++ b/test/wcc/989_enumcap_run.c @@ -2,23 +2,37 @@ * 989_enumcap_run (#65, F13 c3) — the driver's directory enumerator must * bundle EVERY eligible *.ww source, not silently cap at 256. * - * THE BUG (wwstage driver only, cat-A silent wrong combined.ww under rc=0): + * THE BUG (wwstage driver only, cat-A silent wrong unit under rc=0): * enumeratedir (selfhost/cmd/ww/main.ww) capped at maxnames=256 and the * `if (n < maxnames)` guard silently discarded every further eligible file — * no diagnostic. cstage enumerate_dir_ww (cmd/ww/main.c:209) grows via * realloc doubling, unbounded. A module dir with >256 sources bundled all of - * them under cstage vs 256 under wwstage, a silently divergent combined.ww + * them under cstage vs 256 under wwstage, a silently divergent package unit * (and binary) under rc=0 — invisible to the byte-id gates (no in-tree * module nears 256 files). THE FIX (CAP-SEMANTICS rule: the cstage twin grows, * so grow-dynamic): mirror the realloc-doubling growth in enumeratedir. * + * #94 sep layout: the flip stops emitting a single .combined.ww; under + * `--sep` each package is enumerated into its OWN .sepwork/.unit.ww + * (the bigmod dir → bigmod.unit.ww, holding one `package bigmod;` clause per + * enumerated source file — the exact set the combined.ww used to hold for that + * package). So the gate now drives `ww build --sep` / `ww_ww build --sep` and + * re-targets the enumeration check onto bigmod.unit.ww: each stage must enroll + * `nfiles` package clauses, and the two stages' bigmod.unit.ww must be byte- + * identical. A cap-drop on one side shrinks that stage's bigmod.unit.ww — the + * count check AND the cs/ww byte-compare both redden (the cap can't pass blind). + * * row | files | result (cs==ww) * --------+-------+------------------------------------------ - * big_300 | 300 | both bundle 300, combined.ww byte-id - * small_5 | 5 | both bundle 5, combined.ww byte-id (control) + * big_300 | 300 | both enroll 300, bigmod.unit.ww byte-id + * small_5 | 5 | both enroll 5, bigmod.unit.ww byte-id (control) * - * big_300 was RED pre-c3 (ww bundled 256, cs 300 — divergent combined.ww). + * big_300 was RED pre-c3 (ww enrolled 256, cs 300 — divergent unit). * small_5 pins the common ≤cap path stays byte-identical. + * + * All intermediates redirect under each stage's -o stem and WW_PKGCACHE is + * pinned to the /tmp scratch, so out/.pkgcache and the source tree stay clean + * and the gate runs parallel-safe. */ #include #include @@ -50,14 +64,15 @@ count_pkgs(const char *path) return n; } -/* Returns 0 if both drivers produced a combined.ww with `nfiles` package - * lines AND byte-identical content; non-zero (and prints) otherwise. */ +/* Returns 0 if both --sep driver builds enrolled `nfiles` package clauses into + * their bigmod.unit.ww AND the two units are byte-identical; non-zero + * (and prints) otherwise. */ static int one_row(const char *label, const char *cdrv, const char *wdrv, int nfiles, int have_ww) { char dir[64], main_ww[128], cstem[128], wstem[128]; - char ccomb[160], wcomb[160], cmd[1024], fn[160]; + char cunit[192], wunit[192], cmd[1024], fn[160]; snprintf(dir, sizeof dir, "/tmp/encap_%d_%s", getpid(), label); snprintf(cmd, sizeof cmd, "rm -rf %s && mkdir -p %s/bigmod", dir, dir); system(cmd); @@ -78,40 +93,44 @@ one_row(const char *label, const char *cdrv, const char *wdrv, int nfiles, snprintf(cstem, sizeof cstem, "%s/X_c", dir); snprintf(wstem, sizeof wstem, "%s/X_w", dir); - snprintf(ccomb, sizeof ccomb, "%s.combined.ww", cstem); - snprintf(wcomb, sizeof wcomb, "%s.combined.ww", wstem); + /* the bigmod dir enumerates into its own per-package sep unit */ + snprintf(cunit, sizeof cunit, "%s.sepwork/bigmod.unit.ww", cstem); + snprintf(wunit, sizeof wunit, "%s.sepwork/bigmod.unit.ww", wstem); int fail = 0; - snprintf(cmd, sizeof cmd, "%s build -o %s %s 2>/dev/null", - cdrv, cstem, main_ww); + snprintf(cmd, sizeof cmd, + "WW_PKGCACHE=%s/pc %s build --sep -o %s %s 2>/dev/null", + dir, cdrv, cstem, main_ww); if (runwait(cmd) != 0) { fprintf(stderr, "enumcap[cstage][%s]: build failed\n", label); fail++; } - int cn = count_pkgs(ccomb); + int cn = count_pkgs(cunit); if (cn != nfiles) { - fprintf(stderr, "enumcap[cstage][%s]: bundled %d want %d\n", + fprintf(stderr, "enumcap[cstage][%s]: enrolled %d want %d\n", label, cn, nfiles); fail++; } if (have_ww) { - snprintf(cmd, sizeof cmd, "%s build -o %s %s 2>/dev/null", - wdrv, wstem, main_ww); + snprintf(cmd, sizeof cmd, + "WW_PKGCACHE=%s/pw %s build --sep -o %s %s 2>/dev/null", + dir, wdrv, wstem, main_ww); if (runwait(cmd) != 0) { fprintf(stderr, "enumcap[wwstage][%s]: build failed\n", label); fail++; } - int wn = count_pkgs(wcomb); + int wn = count_pkgs(wunit); if (wn != nfiles) { - fprintf(stderr, "enumcap[wwstage][%s]: bundled %d want %d " + fprintf(stderr, "enumcap[wwstage][%s]: enrolled %d want %d " "(silent enumeratedir cap — #65)\n", label, wn, nfiles); fail++; } - /* the decisive rule-10 assertion: identical combined.ww */ - snprintf(cmd, sizeof cmd, "cmp -s %s %s", ccomb, wcomb); + /* the decisive rule-10 assertion: identical per-package unit — + * a cap-drop on either side shrinks its bigmod.unit.ww */ + snprintf(cmd, sizeof cmd, "cmp -s %s %s", cunit, wunit); if (runwait(cmd) != 0) { - fprintf(stderr, "enumcap[%s]: cs/ww combined.ww differ (#65)\n", + fprintf(stderr, "enumcap[%s]: cs/ww bigmod.unit.ww differ (#65)\n", label); fail++; }