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:
@@ -25,10 +25,9 @@
|
||||
* @symbol("rt_free") decl — covered by the lisp example / stdlib
|
||||
* suites, not re-pinned here.
|
||||
*
|
||||
* Per row: w6c vs w6c_ww .s byte-id (rule 10), a negative grep that
|
||||
* no `free` symbol survives anywhere in the .s (byte-id alone would
|
||||
* pass if BOTH stages still emitted CALL free), and runtime via both
|
||||
* drivers.
|
||||
* Runtime behavior is carried by the r930_free_* wwfixtures. This wrapper
|
||||
* retains w6c vs w6c_ww byte identity plus the negative assembly assertion
|
||||
* that no `free` symbol survives.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -154,22 +153,6 @@ has_free_sym(const char *s_path)
|
||||
return runwait(cmd) == 0;
|
||||
}
|
||||
|
||||
static int
|
||||
run_driver(const char *driver, const char *src, const char *tmpdir,
|
||||
const char *label)
|
||||
{
|
||||
char cmd[1024], outbin[256];
|
||||
snprintf(outbin, sizeof outbin, "%s/%s_out", tmpdir, driver);
|
||||
snprintf(cmd, sizeof cmd, "%s/%s build -o %s %s >/dev/null 2>&1",
|
||||
g_bin, driver, outbin, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: build via %s failed\n",
|
||||
label, driver);
|
||||
return -1;
|
||||
}
|
||||
return runwait(outbin);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -192,66 +175,69 @@ main(void)
|
||||
* byte-id .s dumps all live under one tmpdir; rm -rf on every
|
||||
* exit path. Symbol mangling is package/import-derived, not
|
||||
* entry-path derived, so the in-tmpdir source keeps the cs==ww
|
||||
* .s identical. */
|
||||
* .s identical. Temp names must avoid the substring 'free':
|
||||
* has_free_sym greps the whole .s, so an embedded path would
|
||||
* false-fail every row. */
|
||||
char tmpdir[64], src[128], cs_s[128], ww_s[128], rmcmd[160];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/freenoop_%d_d_%d",
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/noopfr_%d_d_%d",
|
||||
getpid(), i);
|
||||
mkdir(tmpdir, 0755);
|
||||
snprintf(src, sizeof src, "%s/freenoop_%d_%d.ww",
|
||||
/* an unowned path (stale dir, full /tmp) must not be compiled
|
||||
* in — or rm -rf'd — below. */
|
||||
if (mkdir(tmpdir, 0755) != 0) {
|
||||
perror(tmpdir);
|
||||
return 1;
|
||||
}
|
||||
snprintf(src, sizeof src, "%s/noopfr_%d_%d.ww",
|
||||
tmpdir, getpid(), i);
|
||||
snprintf(cs_s, sizeof cs_s, "%s/cs.s", tmpdir);
|
||||
snprintf(ww_s, sizeof ww_s, "%s/ww.s", tmpdir);
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) { runwait(rmcmd); return 1; }
|
||||
if (!f) {
|
||||
perror(src);
|
||||
if (runwait(rmcmd) != 0)
|
||||
fprintf(stderr, "free_noop_run: cleanup "
|
||||
"%s failed\n", tmpdir);
|
||||
return 1;
|
||||
}
|
||||
fputs("package main;\n\n", f);
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
total++;
|
||||
int rowfail = 0;
|
||||
int cs_rc = compile_s("w6c", src, cs_s);
|
||||
int ww_rc = compile_s("w6c_ww", src, ww_s);
|
||||
if (cs_rc != 0 || ww_rc != 0) {
|
||||
fprintf(stderr, "FAIL row[%s]: compile rc cs=%d "
|
||||
"ww=%d\n", r->label, cs_rc, ww_rc);
|
||||
fail++;
|
||||
runwait(rmcmd);
|
||||
continue;
|
||||
}
|
||||
if (!file_eq(cs_s, ww_s)) {
|
||||
fprintf(stderr, "FAIL row[%s]: cs != ww .s\n",
|
||||
r->label);
|
||||
fail++;
|
||||
}
|
||||
if (has_free_sym(cs_s)) {
|
||||
fprintf(stderr, "FAIL row[%s]: 'free' survives in "
|
||||
"the .s — lowering is not a no-op\n", r->label);
|
||||
fail++;
|
||||
}
|
||||
int got_cs = run_driver("ww", src, tmpdir, r->label);
|
||||
if (got_cs != r->want) {
|
||||
fprintf(stderr, "FAIL row[%s] cstage: want %d "
|
||||
"got %d\n", r->label, r->want, got_cs);
|
||||
fail++;
|
||||
}
|
||||
char wwdrv[600];
|
||||
snprintf(wwdrv, sizeof wwdrv, "%s/ww_ww", g_bin);
|
||||
if (access(wwdrv, X_OK) == 0) {
|
||||
int got_ww = run_driver("ww_ww", src, tmpdir, r->label);
|
||||
if (got_ww != r->want) {
|
||||
fprintf(stderr, "FAIL row[%s] wwstage: "
|
||||
"want %d got %d\n",
|
||||
r->label, r->want, got_ww);
|
||||
fail++;
|
||||
fail++; rowfail = 1;
|
||||
} else {
|
||||
if (!file_eq(cs_s, ww_s)) {
|
||||
fprintf(stderr, "FAIL row[%s]: cs != ww .s\n",
|
||||
r->label);
|
||||
fail++; rowfail = 1;
|
||||
}
|
||||
if (has_free_sym(cs_s)) {
|
||||
fprintf(stderr, "FAIL row[%s]: 'free' survives in "
|
||||
"the .s — lowering is not a no-op\n", r->label);
|
||||
fail++; rowfail = 1;
|
||||
}
|
||||
}
|
||||
runwait(rmcmd);
|
||||
/* a silent cleanup failure must fail an otherwise-passing
|
||||
* row without masking its own diagnostic. */
|
||||
if (runwait(rmcmd) != 0) {
|
||||
fprintf(stderr, "FAIL row[%s]: cleanup %s failed\n",
|
||||
r->label, tmpdir);
|
||||
if (!rowfail)
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
if (fail) {
|
||||
fprintf(stderr, "free_noop_run: %d/%d rows failed\n",
|
||||
fail, total);
|
||||
return 1;
|
||||
}
|
||||
printf("free_noop_run: %d rows ok\n", total);
|
||||
printf("free_noop_run: %d assembly rows ok\n", total);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user