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

@@ -53,6 +53,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
@@ -125,7 +126,18 @@ emit_s(const char *w6c, const struct row *r, int i, char *out_s, size_t cap)
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null", w6c, out_s, src);
int rc = runwait(cmd);
unlink(src);
int cleanfail = 0;
if (unlink(src) != 0 && errno != ENOENT) {
perror(src);
cleanfail = 1;
}
/* a failing compile can still leave a partial .s behind */
if (rc != 0 && unlink(out_s) != 0 && errno != ENOENT) {
perror(out_s);
cleanfail = 1;
}
if (cleanfail && rc == 0)
rc = -1;
return rc;
}
@@ -187,6 +199,7 @@ main(void)
int have_ww = (access(w6c_ww, X_OK) == 0);
int n = (int)(sizeof rows / sizeof rows[0]);
int total = 0, fail = 0;
int cleanfail = 0;
for (int i = 0; i < n; i++) {
char cs_path[128], ws_path[128];
@@ -200,19 +213,43 @@ main(void)
total++;
if (check_imm(cs_path, &rows[i], "cstage") != 0) fail++;
if (!have_ww) { unlink(cs_path); continue; }
if (!have_ww) {
if (unlink(cs_path) != 0 && errno != ENOENT) {
perror(cs_path);
cleanfail = 1;
}
continue;
}
if (emit_s(w6c_ww, &rows[i], i, ws_path, sizeof ws_path) != 0) {
fprintf(stderr,
"convwrap_audit[wwstage][%s]: w6c_ww failed\n",
rows[i].label);
fail++; total++;
unlink(cs_path); continue;
if (unlink(cs_path) != 0 && errno != ENOENT) {
perror(cs_path);
cleanfail = 1;
}
continue;
}
total++;
if (check_imm(ws_path, &rows[i], "wwstage") != 0) fail++;
unlink(cs_path); unlink(ws_path);
if (unlink(cs_path) != 0 && errno != ENOENT) {
perror(cs_path);
cleanfail = 1;
}
if (unlink(ws_path) != 0 && errno != ENOENT) {
perror(ws_path);
cleanfail = 1;
}
}
/* a cleanup failure must not pass silently, but must not mask a
* real assertion failure's own report either. */
if (cleanfail && fail == 0) {
fprintf(stderr, "convwrap_audit: cleanup failed\n");
return 1;
}
if (fail) {