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

@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -129,16 +130,33 @@ main(void)
int n = 0, fail = 0;
for (int i = 0; rows[i].src; i++, n++) {
char tmpdir[80], src[128], outbin[128], rmcmd[160];
snprintf(tmpdir, sizeof tmpdir, "/tmp/wwdyn_%d_d_%d", getpid(), i);
mkdir(tmpdir, 0755);
char tmpdir[] = "/tmp/wwdyn_XXXXXX";
char src[128], outbin[128], scratch[160], rmcmd[192];
int rowfail = 0;
if (mkdtemp(tmpdir) == NULL) {
fprintf(stderr, "dyn row %d: mkdtemp failed\n", i);
fail++;
continue;
}
snprintf(src, sizeof src, "%s/wwdyn_%d_%d.ww", tmpdir, getpid(), i);
snprintf(outbin, sizeof outbin, "%s/wwdyn_%d_%d", tmpdir, getpid(), i);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
snprintf(scratch, sizeof scratch, "%s.sepwork", outbin);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", scratch);
FILE *f = fopen(src, "wb");
if (f == NULL) {
fprintf(stderr, "dyn row %d: source create failed\n", i);
rowfail = 1;
goto row_done;
}
wwtest_fputs(rows[i].src, f);
fclose(f);
int werr = ferror(f);
if (fclose(f) != 0) werr = 1;
if (werr) {
fprintf(stderr, "dyn row %d: source write failed\n", i);
rowfail = 1;
goto row_done;
}
char cmd[1024];
snprintf(cmd, sizeof cmd,
@@ -146,18 +164,35 @@ main(void)
bin, outbin, src, libdir);
if (runwait(cmd) != 0) {
fprintf(stderr, "dyn row %d: build failed\n", i);
fail++;
runwait(rmcmd);
continue;
rowfail = 1;
goto row_done;
}
int got = runwait(outbin);
if (got != rows[i].want_exit) {
fprintf(stderr, "dyn row %d: exit %d, want %d\n",
i, got, rows[i].want_exit);
fail++;
rowfail = 1;
}
runwait(rmcmd);
row_done:
if (runwait(rmcmd) != 0) {
fprintf(stderr, "dyn row %d: scratch cleanup failed\n", i);
rowfail = 1;
}
if (unlink(outbin) != 0 && errno != ENOENT) {
fprintf(stderr, "dyn row %d: output cleanup failed\n", i);
rowfail = 1;
}
if (unlink(src) != 0 && errno != ENOENT) {
fprintf(stderr, "dyn row %d: source cleanup failed\n", i);
rowfail = 1;
}
if (rmdir(tmpdir) != 0) {
fprintf(stderr, "dyn row %d: workspace cleanup failed\n", i);
rowfail = 1;
}
if (rowfail) fail++;
}
if (fail) {
fprintf(stderr, "%d/%d dyn tests failed\n", fail, n);