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

@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -49,21 +50,30 @@ static int
run_row(const char *bin, const char *label, const char *src,
const char *wwerr, int i)
{
char dir[96], srcf[160], outbin[160], wwe[160], ss[160], rm[200], cmd[2048];
snprintf(dir, sizeof dir, "/tmp/aacc_%d_%d", getpid(), i);
mkdir(dir, 0755);
char dir[128], srcf[192], outbin[192], wwe[192], ss[192];
char scratch[208], cmd[2048];
snprintf(dir, sizeof dir, "/tmp/aacc_%d_%d_XXXXXX", getpid(), i);
if (mkdtemp(dir) == NULL) {
fprintf(stderr, "row[%s]: temporary directory acquisition failed\n",
label);
return -1;
}
snprintf(srcf, sizeof srcf, "%s/c.ww", dir);
snprintf(outbin, sizeof outbin, "%s/bin", dir);
snprintf(wwe, sizeof wwe, "%s/ww.err", dir);
snprintf(ss, sizeof ss, "%s/o.s", dir);
snprintf(rm, sizeof rm, "rm -rf %s", dir);
snprintf(scratch, sizeof scratch, "%s.sepwork", outbin);
FILE *f = fopen(srcf, "wb");
if (!f) { runwait(rm); return -1; }
int ok = 1;
if (!f) {
fprintf(stderr, "row[%s]: source setup failed\n", label);
ok = 0;
goto cleanup;
}
fputs(src, f);
fclose(f);
int ok = 1;
snprintf(cmd, sizeof cmd,
"timeout 20 %s/ww build -o %s %s >/dev/null 2>&1", bin, outbin, srcf);
if (runwait(cmd) != 0) {
@@ -80,7 +90,22 @@ run_row(const char *bin, const char *label, const char *src,
label, wwerr, wrc);
ok = 0;
}
runwait(rm);
cleanup:
{
int bad = 0;
snprintf(cmd, sizeof cmd, "rm -rf %s", scratch);
if (runwait(cmd) != 0) bad = 1;
if (unlink(ss) != 0 && errno != ENOENT) bad = 1;
if (unlink(wwe) != 0 && errno != ENOENT) bad = 1;
if (unlink(outbin) != 0 && errno != ENOENT) bad = 1;
if (unlink(srcf) != 0 && errno != ENOENT) bad = 1;
if (rmdir(dir) != 0) bad = 1;
if (bad) {
fprintf(stderr, "row[%s]: temporary cleanup failed\n", label);
ok = 0;
}
}
return ok ? 0 : 1;
}