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:
2026-08-07 23:02:47 +09:00
parent b2899dd8d3
commit a95a7a316b
132 changed files with 7573 additions and 6172 deletions

View File

@@ -45,6 +45,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -61,37 +62,61 @@ runwait(const char *cmd)
static int
run_pos(const char *driver, const char *fixdir, const char *tag)
{
/* -o into a /tmp tmpdir so pos.sepwork follows the OUTPUT stem out
* of the tracked fixture tree; cd <fixdir> stays pos.ww imports
* siblings mod1/mod2 via source-dir-first resolution. */
/* Keep the output and caller-owned pos.sepwork outside the tracked
* fixture tree; cd <fixdir> stays so pos.ww imports siblings mod1/mod2. */
char td[1024];
snprintf(td, sizeof td, "/tmp/fnlbl_%d_%s", getpid(), tag);
mkdir(td, 0755);
char rmcmd[1088];
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", td);
if (mkdir(td, 0755) != 0) {
fprintf(stderr, "fnlabel_mangle[%s]: mkdir %s: %s\n",
tag, td, strerror(errno));
return 1;
}
char bin[2048], sepdir[2048], rmcmd[2112];
snprintf(bin, sizeof bin, "%s/pos", td);
snprintf(sepdir, sizeof sepdir, "%s.sepwork", bin);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", sepdir);
char cmd[2048];
int failed = 0, got;
snprintf(cmd, sizeof cmd,
"cd %s && %s build -o %s/pos pos.ww >/dev/null 2>&1",
fixdir, driver, td);
if (runwait(cmd) != 0) {
fprintf(stderr,
"fnlabel_mangle[%s]: pos.ww build failed\n", tag);
runwait(rmcmd);
return 1;
failed = 1;
goto cleanup;
}
char bin[2048];
snprintf(bin, sizeof bin, "%s/pos", td);
int got = runwait(bin);
runwait(rmcmd);
got = runwait(bin);
if (got != 112) {
fprintf(stderr,
"fnlabel_mangle[%s]: pos.ww exit=%d want=112 — "
"fn labels likely collapsed at link, or LEAQ-of-fn "
"N_DOT branch missing in cgdot\n", tag, got);
return 1;
failed = 1;
}
return 0;
cleanup:
{
int cleanup_failed = 0;
if (runwait(rmcmd) != 0) {
fprintf(stderr, "fnlabel_mangle[%s]: remove %s failed\n",
tag, sepdir);
cleanup_failed = 1;
}
if (unlink(bin) != 0 && errno != ENOENT) {
fprintf(stderr, "fnlabel_mangle[%s]: unlink %s: %s\n",
tag, bin, strerror(errno));
cleanup_failed = 1;
}
if (rmdir(td) != 0) {
fprintf(stderr, "fnlabel_mangle[%s]: rmdir %s: %s\n",
tag, td, strerror(errno));
cleanup_failed = 1;
}
if (!failed && cleanup_failed) failed = 1;
}
return failed;
}
int