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

@@ -33,6 +33,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -372,42 +373,61 @@ main(void)
int n = 0, fail = 0;
for (int i = 0; rows[i].src; i++, n++) {
char tmpdir[64];
snprintf(tmpdir, sizeof tmpdir, "/tmp/wwflt_%d_%d", getpid(), i);
mkdir(tmpdir, 0755);
char rmcmd[128];
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
char src[128];
snprintf(src, sizeof src, "%s/wwflt_%d_%d.ww", tmpdir, getpid(), i);
FILE *f = fopen(src, "wb");
if (f == NULL) { fail++; runwait(rmcmd); continue; }
fputs(rows[i].src, f);
fclose(f);
char outbin[128];
char tmpdir[] = "/tmp/wwflt_XXXXXX";
if (mkdtemp(tmpdir) == NULL) {
fprintf(stderr, "row %d: mkdtemp failed\n", i);
fail++;
continue;
}
int rowfail = 0;
char src[128], outbin[128], cmd[2048];
snprintf(src, sizeof src, "%s/case.ww", tmpdir);
snprintf(outbin, sizeof outbin, "%s/out", tmpdir);
char cmd[2048];
FILE *f = fopen(src, "wb");
if (f == NULL) {
fprintf(stderr, "row %d: source open failed\n", i);
rowfail = 1;
goto cleanup;
}
int writefail = fputs(rows[i].src, f) == EOF;
if (fclose(f) != 0) writefail = 1;
if (writefail) {
fprintf(stderr, "row %d: source write failed\n", i);
rowfail = 1;
goto cleanup;
}
snprintf(cmd, sizeof cmd, "%s/ww build -I %s/lib -o %s %s",
bin, cwd, outbin, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "row %d: build failed\n src: %s\n",
i, rows[i].src);
fail++;
runwait(rmcmd);
continue;
rowfail = 1;
goto cleanup;
}
int got = runwait(outbin);
if (got != rows[i].want_exit) {
fprintf(stderr, "row %d: exit %d, want %d\n src: %s\n",
i, got, rows[i].want_exit, rows[i].src);
fail++;
rowfail = 1;
}
runwait(rmcmd);
cleanup:
{
int cleanfail = 0;
snprintf(cmd, sizeof cmd, "rm -rf %s/out.sepwork", tmpdir);
if (runwait(cmd) != 0) cleanfail = 1;
if (unlink(outbin) != 0 && errno != ENOENT) cleanfail = 1;
if (unlink(src) != 0 && errno != ENOENT) cleanfail = 1;
if (rmdir(tmpdir) != 0) cleanfail = 1;
if (cleanfail) {
fprintf(stderr, "row %d: temporary cleanup failed\n", i);
rowfail = 1;
}
}
if (rowfail) fail++;
}
if (fail) {
fprintf(stderr, "%d/%d floats tests failed\n", fail, n);