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:
@@ -39,13 +39,14 @@
|
||||
* combined_t16 | {u64,u16} 16B | 24B | recv+field+push| 114
|
||||
* recvpush_t12 | {u32,u32,u32} 12B | 24B | recv + push | 6
|
||||
*
|
||||
* cstage `ww build --sep` + run pins runtime; the wwstage binary is run
|
||||
* cstage `ww build` + run pins runtime; the wwstage binary is run
|
||||
* too (the bug WAS a wrong wwstage runtime value); raw cs.s vs ww.s cmp
|
||||
* over the driver-produced per-package asm pins rule-10 byte-id (the
|
||||
* discriminating net — pre-fix __root.s diverges at the push/recv/field).
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -72,7 +73,9 @@ slurp_eq(const char *a, const char *b)
|
||||
if (ca != cb) { rc = -1; break; }
|
||||
if (ca == EOF) break;
|
||||
}
|
||||
fclose(fa); fclose(fb);
|
||||
if (ferror(fa) || ferror(fb)) rc = -1;
|
||||
if (fclose(fa) != 0) rc = -1;
|
||||
if (fclose(fb) != 0) rc = -1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -201,15 +204,17 @@ run_scenario(const char *cdrv, const char *wdrv, const struct scenario *sc)
|
||||
FILE *f = fopen(path, "wb");
|
||||
if (!f) { fprintf(stderr, "793[%s]: write %s\n", sc->label,
|
||||
sc->files[i].name); rc = -1; goto done; }
|
||||
fputs(sc->files[i].src, f);
|
||||
fclose(f);
|
||||
int bad = fputs(sc->files[i].src, f) == EOF;
|
||||
if (fclose(f) != 0) bad = 1;
|
||||
if (bad) { fprintf(stderr, "793[%s]: write %s\n", sc->label,
|
||||
sc->files[i].name); rc = -1; goto done; }
|
||||
}
|
||||
|
||||
/* cstage --sep build + run pins runtime; pin WW_PKGCACHE under the
|
||||
* scratch dir so out/.pkgcache is untouched. */
|
||||
/* cstage build + run pins runtime; all outputs remain under the
|
||||
* scratch dir. */
|
||||
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);
|
||||
"cd %s && %s build -I %s -o %s/main %s/main.ww",
|
||||
dir, cdrv, dir, dir, dir);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "793[%s]: cstage build failed\n", sc->label);
|
||||
rc = -1; goto done;
|
||||
@@ -222,11 +227,11 @@ run_scenario(const char *cdrv, const char *wdrv, const struct scenario *sc)
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
/* wwstage --sep build + run: the bug WAS a wrong wwstage runtime
|
||||
/* wwstage build + run: the bug WAS a wrong wwstage runtime
|
||||
* value (a dropped/over-copied field), so run the wwstage binary too. */
|
||||
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);
|
||||
"cd %s && %s build -I %s -o %s/mainww %s/main.ww",
|
||||
dir, wdrv, dir, dir, dir);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "793[%s]: ww_ww build failed\n", sc->label);
|
||||
rc = -1; goto done;
|
||||
@@ -245,10 +250,22 @@ run_scenario(const char *cdrv, const char *wdrv, const struct scenario *sc)
|
||||
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)) {}
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cat %s/main.sepwork/*.s > %s 2>/dev/null && test -s %s",
|
||||
dir, cs_s, cs_s);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "793[%s]: cstage asm aggregation failed\n",
|
||||
sc->label);
|
||||
rc = -1; goto done;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cat %s/mainww.sepwork/*.s > %s 2>/dev/null && test -s %s",
|
||||
dir, ws_s, ws_s);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "793[%s]: wwstage asm aggregation failed\n",
|
||||
sc->label);
|
||||
rc = -1; goto done;
|
||||
}
|
||||
if (slurp_eq(cs_s, ws_s) != 0) {
|
||||
fprintf(stderr, "793[%s]: cs.s/ww.s DIFFER (rule-10 byte-id "
|
||||
"violation — #21/#224 regression)\n", sc->label);
|
||||
@@ -256,8 +273,33 @@ run_scenario(const char *cdrv, const char *wdrv, const struct scenario *sc)
|
||||
}
|
||||
|
||||
done:
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", dir);
|
||||
(void)runwait(cmd);
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s/main.sepwork", dir);
|
||||
if (runwait(cmd) != 0) { fprintf(stderr, "793[%s]: cleanup main.sepwork\n",
|
||||
sc->label); rc = -1; }
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s/mainww.sepwork", dir);
|
||||
if (runwait(cmd) != 0) { fprintf(stderr, "793[%s]: cleanup mainww.sepwork\n",
|
||||
sc->label); rc = -1; }
|
||||
for (int i = 0; sc->files[i].name; i++) {
|
||||
snprintf(path, sizeof path, "%s/%s", dir, sc->files[i].name);
|
||||
if (unlink(path) != 0 && errno != ENOENT) {
|
||||
fprintf(stderr, "793[%s]: cleanup %s\n", sc->label,
|
||||
sc->files[i].name);
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
const char *children[] = { "main", "mainww", "all_cs.s", "all_ww.s", NULL };
|
||||
for (int i = 0; children[i]; i++) {
|
||||
snprintf(path, sizeof path, "%s/%s", dir, children[i]);
|
||||
if (unlink(path) != 0 && errno != ENOENT) {
|
||||
fprintf(stderr, "793[%s]: cleanup %s\n", sc->label,
|
||||
children[i]);
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
if (rmdir(dir) != 0) {
|
||||
fprintf(stderr, "793[%s]: cleanup directory\n", sc->label);
|
||||
rc = -1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user