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:
@@ -1,32 +1,27 @@
|
||||
/*
|
||||
* 989_c6soak_run — M3-tail commit-6 dual-path soak gate, phase-1 leg
|
||||
* 989_c6soak_run — M3-tail commit-6 separate-compilation soak gate
|
||||
* (#46 c6, rob-c6-spec.md Tier-A/B + §3 collision).
|
||||
*
|
||||
* The STANDING regression-gate for M4: separate-compilation must be
|
||||
* behaviorally equivalent to the combined (embed-everything) build on
|
||||
* real, multi-package code. The oracle is OBSERVABLE OUTPUT, not binary
|
||||
* identity — a sep-linked binary and a combined-linked binary differ in
|
||||
* symbol order/layout (rob-c6-spec §2 ★), so we run both and compare
|
||||
* exit codes, never `cmp` the executables.
|
||||
* The standing real-code regression gate for separate compilation. The
|
||||
* oracle is observable output plus byte-identical per-package compiler
|
||||
* artifacts across the C and WW driver stages.
|
||||
*
|
||||
* Targets (real lib chains, cheap → phase-1):
|
||||
* Targets (real library chains):
|
||||
* - utf8 : encoding.utf8 (DOTTED-path #57) + strings → decode + count
|
||||
* runes ("héllo" = 5). Exercises the multi-component import
|
||||
* the combined build resolves by leaf and sep must resolve
|
||||
* by the full dotted path.
|
||||
* resolution by the full dotted path.
|
||||
* - collide: strings.contains AND bytes.contains — the SAME leaf `contains`
|
||||
* exported by two packages (rob-c6-spec §3, the #48/#49 class
|
||||
* on real code). sep path-qualifies them to DISTINCT symbols;
|
||||
* the program prints both correct results; the §3 non-vacuity
|
||||
* on real code). The driver path-qualifies them to DISTINCT
|
||||
* symbols;
|
||||
* the program computes both correct results; the §3 non-vacuity
|
||||
* check below greps the per-pkg .s to prove the two labels are
|
||||
* genuinely distinct (disambiguation is real, not luck).
|
||||
*
|
||||
* Asserts per target (all COLD — fresh per-stage WW_PKGCACHE, scratch
|
||||
* wiped each run):
|
||||
* 1. DUAL-PATH OUTPUT EQUIVALENCE (the teeth): combined-build run-exit ==
|
||||
* sep-build run-exit == expected, for BOTH driver stages. This is the
|
||||
* M4 behavioral proof: sep emits a program that behaves identically to
|
||||
* the combined one.
|
||||
* Asserts per target (direct per-stage builds use fresh output stems under
|
||||
* an invocation-owned root; retained scratch is inspected, then removed by
|
||||
* final carrier cleanup):
|
||||
* 1. RUN-EXIT: both driver stages build and run to the expected result.
|
||||
* 2. cs==ww (rule 10): the cstage `ww` and wwstage `ww_ww` sep-drivers emit
|
||||
* byte-identical per-package .s and .wwi (the .wwi enters the compare
|
||||
* set — rob-c6-spec). Both also link to a binary that runs to `expect`.
|
||||
@@ -39,14 +34,14 @@
|
||||
* equivalence) is FOLDED into the 990-997 bootstrap oracle (994_w6c_ww),
|
||||
* not bolted on here (rob-c6-spec §2 / amendment-B).
|
||||
*
|
||||
* Light wwstage-driver test (CLAUDE.md rule 14): all intermediates are
|
||||
* `-o`-redirected to /tmp, so it is phase-1 parallel-safe. Models
|
||||
* All intermediates are `-o`-redirected to /tmp for isolation. Models
|
||||
* 989_sepbuild_run.c / 989_sepdotpath_run.c conventions; 989 prefix per
|
||||
* the sep-gate precedent.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -220,35 +215,25 @@ main(void)
|
||||
snprintf(inc, sizeof inc, "-I %s/lib -I %s/lib/ww -I %s/selfhost/cmd/wcc",
|
||||
cwd, cwd, cwd);
|
||||
|
||||
char td[64], cmd[8192];
|
||||
char td[] = "/tmp/wwc6soak_XXXXXX";
|
||||
char cmd[8192];
|
||||
int fail = 0;
|
||||
snprintf(td, sizeof td, "/tmp/wwc6soak_%d", getpid());
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
|
||||
runwait(cmd);
|
||||
mkdir(td, 0755);
|
||||
int source_created[2] = { 0, 0 };
|
||||
int stage_started[2][2] = { { 0, 0 }, { 0, 0 } };
|
||||
if (mkdtemp(td) == NULL) {
|
||||
perror("wwc6soak: mkdtemp");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i = 0; roots[i].label; i++) {
|
||||
struct root *r = &roots[i];
|
||||
char rootww[1024];
|
||||
snprintf(rootww, sizeof rootww, "%s/%s.ww", td, r->label);
|
||||
if (write_file(rootww, r->src)) { fail++; continue; }
|
||||
source_created[i] = 1;
|
||||
|
||||
/* 1. combined build (cstage driver) → run. */
|
||||
char comb[1024];
|
||||
snprintf(comb, sizeof comb, "%s/%s.comb", td, r->label);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"timeout 240 %s/ww build %s -o %s %s >/dev/null 2>&1",
|
||||
bin, inc, comb, rootww);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "c6soak FAIL: %s combined build\n", r->label);
|
||||
fail++;
|
||||
continue;
|
||||
}
|
||||
int comb_rc = runwait(comb);
|
||||
|
||||
/* sep build both stages, fresh per-stage WW_PKGCACHE so every
|
||||
* package compiles COLD (a warm shared cache would skip the
|
||||
* per-pkg .s/.wwi this gate inspects — mirrors 989_pkgcache). */
|
||||
/* Both stages produce every per-package
|
||||
* .s/.wwi artifact this gate inspects. */
|
||||
struct { const char *drv, *tag; char prog[1024]; int rc; }
|
||||
stg[] = { { "ww", "cs", {0}, -1 }, { "ww_ww", "ww", {0}, -1 } };
|
||||
int built = 1;
|
||||
@@ -257,16 +242,14 @@ main(void)
|
||||
* `<label>.ww` SOURCE (else the build clobbers its own input). */
|
||||
snprintf(stg[s].prog, sizeof stg[s].prog, "%s/%s.%s.bin",
|
||||
td, r->label, stg[s].tag);
|
||||
/* Cache keyed per (root,stage): a cache shared across roots
|
||||
* would warm-hit a common package (strings) from an earlier
|
||||
* root and skip emitting its .s into THIS root's sepwork. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"WW_PKGCACHE='%s/cache.%s.%s' timeout 240 %s/%s build --sep "
|
||||
"timeout 240 %s/%s build "
|
||||
"%s -o %s %s >/dev/null 2>&1",
|
||||
td, r->label, stg[s].tag, bin, stg[s].drv, inc,
|
||||
bin, stg[s].drv, inc,
|
||||
stg[s].prog, rootww);
|
||||
stage_started[i][s] = 1;
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "c6soak FAIL: %s %s build --sep\n",
|
||||
fprintf(stderr, "c6soak FAIL: %s %s build\n",
|
||||
r->label, stg[s].drv);
|
||||
fail++;
|
||||
built = 0;
|
||||
@@ -276,12 +259,11 @@ main(void)
|
||||
}
|
||||
if (!built) continue;
|
||||
|
||||
/* 1. dual-path OUTPUT equivalence: combined == sep (both stages). */
|
||||
if (comb_rc != r->expect || stg[0].rc != r->expect ||
|
||||
stg[1].rc != r->expect) {
|
||||
fprintf(stderr, "c6soak FAIL: %s exits comb=%d sep-cs=%d "
|
||||
"sep-ww=%d (expected %d)\n", r->label, comb_rc,
|
||||
stg[0].rc, stg[1].rc, r->expect);
|
||||
/* 1. Runtime behavior agrees across both stages. */
|
||||
if (stg[0].rc != r->expect || stg[1].rc != r->expect) {
|
||||
fprintf(stderr, "c6soak FAIL: %s exits cs=%d ww=%d "
|
||||
"(expected %d)\n", r->label, stg[0].rc, stg[1].rc,
|
||||
r->expect);
|
||||
fail++;
|
||||
}
|
||||
|
||||
@@ -311,13 +293,38 @@ main(void)
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", td);
|
||||
runwait(cmd);
|
||||
{
|
||||
int cleanfail = 0;
|
||||
char path[1024];
|
||||
const char *labels[] = { "utf8", "collide" };
|
||||
const char *tags[] = { "cs", "ww" };
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int s = 0; s < 2; s++) {
|
||||
if (!stage_started[i][s]) continue;
|
||||
snprintf(path, sizeof path, "%s/%s.%s.bin.sepwork",
|
||||
td, labels[i], tags[s]);
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", path);
|
||||
if (runwait(cmd) != 0) cleanfail = 1;
|
||||
snprintf(path, sizeof path, "%s/%s.%s.bin",
|
||||
td, labels[i], tags[s]);
|
||||
if (unlink(path) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
}
|
||||
if (source_created[i]) {
|
||||
snprintf(path, sizeof path, "%s/%s.ww", td, labels[i]);
|
||||
if (unlink(path) != 0 && errno != ENOENT) cleanfail = 1;
|
||||
}
|
||||
}
|
||||
if (rmdir(td) != 0) cleanfail = 1;
|
||||
if (cleanfail) {
|
||||
fprintf(stderr, "c6soak FAIL: temporary cleanup failed\n");
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
if (fail) {
|
||||
fprintf(stderr, "c6soak: %d check(s) failed\n", fail);
|
||||
return 1;
|
||||
}
|
||||
printf("c6soak: dual-path combined==sep run-equivalence on real chains "
|
||||
printf("c6soak: separate-compilation behavior on real chains "
|
||||
"(encoding.utf8 dotted + strings/bytes same-leaf `contains`) — "
|
||||
"cs==ww per-pkg .s/.wwi + §3 distinct labels\n");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user