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

@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -73,16 +74,28 @@ static const char *experr = "deferred #277";
static int
check(const char *driver, int expect_err, int want)
{
char tmpdir[96], srcp[128], outbin[128], errf[128], rmcmd[160], cmd[1024];
snprintf(tmpdir, sizeof tmpdir, "/tmp/vc277_%d_%d", getpid(), expect_err);
mkdir(tmpdir, 0755);
char tmpdir[128], srcp[192], outbin[192], errf[192];
char scratch[208], cmd[1024];
snprintf(tmpdir, sizeof tmpdir, "/tmp/vc277_%d_%d_XXXXXX",
getpid(), expect_err);
if (mkdtemp(tmpdir) == NULL) {
fprintf(stderr, "callret_bound277: %s temporary directory "
"acquisition failed\n", driver);
return 1;
}
snprintf(srcp, sizeof srcp, "%s/c.ww", tmpdir);
snprintf(outbin, sizeof outbin, "%s/c", tmpdir);
snprintf(errf, sizeof errf, "%s/err", tmpdir);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
snprintf(scratch, sizeof scratch, "%s.sepwork", outbin);
FILE *f = fopen(srcp, "wb");
if (!f) { runwait(rmcmd); return 1; }
int rc = 0;
if (!f) {
fprintf(stderr, "callret_bound277: %s source setup failed\n",
driver);
rc = 1;
goto cleanup;
}
fputs(src, f);
fclose(f);
@@ -90,7 +103,6 @@ check(const char *driver, int expect_err, int want)
driver, outbin, srcp, errf);
int brc = runwait(cmd);
int rc = 0;
if (expect_err) {
if (brc == 0 || !errlog_has(errf, experr)) {
fprintf(stderr, "callret_bound277: %s expected loud "
@@ -108,7 +120,22 @@ check(const char *driver, int expect_err, int want)
rc = 1;
}
}
runwait(rmcmd);
cleanup:
{
int bad = 0;
snprintf(cmd, sizeof cmd, "rm -rf %s", scratch);
if (runwait(cmd) != 0) bad = 1;
if (unlink(errf) != 0 && errno != ENOENT) bad = 1;
if (unlink(outbin) != 0 && errno != ENOENT) bad = 1;
if (unlink(srcp) != 0 && errno != ENOENT) bad = 1;
if (rmdir(tmpdir) != 0) bad = 1;
if (bad) {
fprintf(stderr, "callret_bound277: %s temporary cleanup "
"failed\n", driver);
rc = 1;
}
}
return rc;
}