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

@@ -26,19 +26,13 @@
* r4_i32_double | `type b = a; type a = struct{i32...}` | wedge pre-fix (RC=14)
* | aliased twice → `type c = b;` |
*
* Each row asserts:
* - cstage RC == 0
* - wwstage RC == 0 (when w6c_ww present)
* - cstage and wwstage emit byte-identical asm
*
* Pre-fix: rows 2 and 4 fail the RC check on both stages and the
* byte-id is also broken on rows 2/4 (one stage emits sret discipline,
* the other emits the scalar-AX fall-through). Post-fix all 12
* fixtures pass.
* Runtime ownership moved to the matching r756_* fixtures. This carrier
* retains the cstage/wwstage assembly byte-identity discriminator.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -135,36 +129,6 @@ static const struct row rows[] = {
},
};
static int
build_and_run(const char *driver, const struct row *r, int i)
{
char tmpdir[64], src[128], outbin[128], rmcmd[160], cmd[1024];
snprintf(tmpdir, sizeof tmpdir, "/tmp/acu_%d_d_%d", getpid(), i);
mkdir(tmpdir, 0755);
snprintf(src, sizeof src, "%s/acu_%d_%d.ww", tmpdir, getpid(), i);
snprintf(outbin, sizeof outbin, "%s/acu_%d_%d", tmpdir, getpid(), i);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
FILE *f = fopen(src, "wb");
if (!f) { runwait(rmcmd); return -1; }
fputs(r->src, f);
fclose(f);
snprintf(cmd, sizeof cmd, "%s build -o %s %s",
driver, outbin, src);
if (runwait(cmd) != 0) {
fprintf(stderr, "row[%s]: build via %s failed\n",
r->label, driver);
runwait(rmcmd);
return -1;
}
int got = runwait(outbin);
runwait(rmcmd);
return got;
}
static int
emit_s(const char *w6c, const struct row *r, int i, char *out_s, size_t cap)
{
@@ -180,7 +144,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;
}
@@ -197,52 +172,40 @@ main(void)
bin = absbin;
}
char cdrv[640], wdrv[640];
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
char cw6c[640], ww6c[640];
snprintf(cw6c, sizeof cw6c, "%s/w6c", bin);
snprintf(ww6c, sizeof ww6c, "%s/w6c_ww", bin);
int have_ww = (access(wdrv, X_OK) == 0)
&& (access(ww6c, X_OK) == 0);
int have_ww = access(ww6c, 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++) {
/* cstage RC */
total++;
int got_c = build_and_run(cdrv, &rows[i], i);
if (got_c != 0) {
fprintf(stderr,
"alias_chain[cstage][%s]: exit=%d want=0\n",
rows[i].label, got_c);
fail++;
}
if (!have_ww) continue;
/* wwstage RC */
total++;
int got_w = build_and_run(wdrv, &rows[i], i);
if (got_w != 0) {
fprintf(stderr,
"alias_chain[wwstage][%s]: exit=%d want=0\n",
rows[i].label, got_w);
fail++;
}
/* byte-id cstage vs wwstage */
total++;
char cs_path[160], ws_path[160];
if (emit_s(cw6c, &rows[i], i, cs_path, sizeof cs_path) != 0
|| emit_s(ww6c, &rows[i], i, ws_path, sizeof ws_path) != 0) {
/* legs split: on a first-leg failure ws_path is never
* filled in, so it must never reach unlink. */
if (emit_s(cw6c, &rows[i], i, cs_path, sizeof cs_path) != 0) {
fprintf(stderr,
"alias_chain[byte-id][%s]: emit failed\n",
rows[i].label);
fail++;
unlink(cs_path); unlink(ws_path);
continue;
}
if (emit_s(ww6c, &rows[i], i, ws_path, sizeof ws_path) != 0) {
fprintf(stderr,
"alias_chain[byte-id][%s]: emit failed\n",
rows[i].label);
fail++;
if (unlink(cs_path) != 0 && errno != ENOENT) {
perror(cs_path);
cleanfail = 1;
}
continue;
}
char cmpcmd[512];
@@ -254,7 +217,21 @@ main(void)
rows[i].label);
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, "alias_chain: cleanup failed\n");
return 1;
}
if (fail) {