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:
@@ -51,6 +51,7 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -119,18 +120,20 @@ main(void)
|
||||
FILE *f = fopen(path, "wb");
|
||||
if (!f) { fprintf(stderr, "794: write %s\n", files[i].name);
|
||||
rc = 1; goto done; }
|
||||
fputs(files[i].src, f);
|
||||
fclose(f);
|
||||
int bad = fputs(files[i].src, f) == EOF;
|
||||
if (fclose(f) != 0) bad = 1;
|
||||
if (bad) { fprintf(stderr, "794: write %s\n", files[i].name);
|
||||
rc = 1; goto done; }
|
||||
}
|
||||
|
||||
/* #94 sep layout: cstage's --sep build (prefer is correct) compiles
|
||||
* the units and links the binary; pin WW_PKGCACHE under the scratch
|
||||
* dir so out/.pkgcache is untouched. NO cs==ww byte-id here — the #55
|
||||
/* #94 sep layout: cstage's build (prefer is correct) compiles
|
||||
* the units and links the binary under the scratch dir. NO cs==ww
|
||||
* byte-id here — the #55
|
||||
* checker fix has an open cgen-side bare-leaf sibling that diverges the
|
||||
* asm independently; the sound discriminator is the wwstage ACCEPT. */
|
||||
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, "794: cstage build failed\n");
|
||||
rc = 1; goto done;
|
||||
@@ -143,14 +146,14 @@ main(void)
|
||||
rc = 1; goto done;
|
||||
}
|
||||
|
||||
/* The #55 discriminator: the wwstage driver's --sep build runs the
|
||||
/* The #55 discriminator: the wwstage driver's build runs the
|
||||
* wwstage checker over the same units and must ACCEPT. PRE-fix it
|
||||
* rejected (bare `v` -> main.v: i64 -> return mismatch); POST-fix it
|
||||
* prefers curmod=aa -> aa.v: i32 and accepts. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && WW_PKGCACHE=%s/pkgc_w %s build --sep -I %s -o %s/mainww %s/main.ww "
|
||||
"cd %s && %s build -I %s -o %s/mainww %s/main.ww "
|
||||
">/dev/null 2>&1",
|
||||
dir, dir, wdrv, dir, dir, dir);
|
||||
dir, wdrv, dir, dir, dir);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "794: ww_ww REJECTED the units (#55: bare "
|
||||
"value-ident resolved the wrong module's same-leaf symbol)\n");
|
||||
@@ -158,8 +161,31 @@ main(void)
|
||||
}
|
||||
|
||||
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, "794: cleanup main.sepwork\n");
|
||||
rc = 1; }
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s/mainww.sepwork", dir);
|
||||
if (runwait(cmd) != 0) { fprintf(stderr, "794: cleanup mainww.sepwork\n");
|
||||
rc = 1; }
|
||||
for (int i = 0; files[i].name; i++) {
|
||||
snprintf(path, sizeof path, "%s/%s", dir, files[i].name);
|
||||
if (unlink(path) != 0 && errno != ENOENT) {
|
||||
fprintf(stderr, "794: cleanup %s\n", files[i].name);
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
const char *children[] = { "main", "mainww", 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, "794: cleanup %s\n", children[i]);
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
if (rmdir(dir) != 0) {
|
||||
fprintf(stderr, "794: cleanup directory\n");
|
||||
rc = 1;
|
||||
}
|
||||
if (rc) {
|
||||
fprintf(stderr, "794 xmod_ident_prefer: FAILED\n");
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user