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:
@@ -29,7 +29,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include "wwtestpkg.h"
|
||||
|
||||
@@ -70,8 +69,7 @@ struct row {
|
||||
const char *label;
|
||||
/* Direct-w6c source: bare fn produce, no package/imports. */
|
||||
const char *asm_src;
|
||||
/* Driver source: `package main; import os; ...` runtime wrapper. */
|
||||
const char *run_src;
|
||||
/* Runtime copies are owned by test/wcc/data/r744_letcopy_*. */
|
||||
/* Source-slot loads expected in produce: at least N for the copy.
|
||||
* Pre-fix cstage emitted 0; pre-fix wwstage emitted 1 with stale BX.
|
||||
* `MOVQ -K(BP), AX` is also emitted by p2.a / p2.s.len reads in the
|
||||
@@ -96,18 +94,6 @@ static const struct row rows[] = {
|
||||
" if (p2.c != 33) { return 13; };\n"
|
||||
" return 0;\n"
|
||||
"};\n",
|
||||
"package main;\n"
|
||||
"import os;\n"
|
||||
"type tri = struct { a: i32, b: i32, c: i32 };\n"
|
||||
"fn produce() i32 = {\n"
|
||||
" let p1: tri = tri{a=11, b=22, c=33};\n"
|
||||
" let p2: tri = p1;\n"
|
||||
" if (p2.a != 11) { return 11; };\n"
|
||||
" if (p2.b != 22) { return 12; };\n"
|
||||
" if (p2.c != 33) { return 13; };\n"
|
||||
" return 0;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = { os.exit(produce()); };\n",
|
||||
1 },
|
||||
/* (b) i32 + str field, sz=24. Copy = 3 × MOVQ. */
|
||||
{ "field_str",
|
||||
@@ -120,18 +106,6 @@ static const struct row rows[] = {
|
||||
" if (p2.s.len != 2) { return 12; };\n"
|
||||
" return 0;\n"
|
||||
"};\n",
|
||||
"package main;\n"
|
||||
"import os;\n"
|
||||
"type ws = struct { a: i32, s: str };\n"
|
||||
"fn produce() i32 = {\n"
|
||||
" let p1: ws;\n"
|
||||
" p1.a = 7; p1.s = \"hi\";\n"
|
||||
" let p2: ws = p1;\n"
|
||||
" if (p2.a != 7) { return 11; };\n"
|
||||
" if (p2.s.len != 2) { return 12; };\n"
|
||||
" return 0;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = { os.exit(produce()); };\n",
|
||||
3 },
|
||||
/* (c) i32 + []u8 slice field, sz=32. Copy = 4 × MOVQ. */
|
||||
{ "field_slice",
|
||||
@@ -145,19 +119,6 @@ static const struct row rows[] = {
|
||||
" if (p2.b.len != 3) { return 12; };\n"
|
||||
" return 0;\n"
|
||||
"};\n",
|
||||
"package main;\n"
|
||||
"import os;\n"
|
||||
"type wsl = struct { a: i32, b: []u8 };\n"
|
||||
"fn produce() i32 = {\n"
|
||||
" let raw: [3]u8 = [1: u8, 2: u8, 3: u8];\n"
|
||||
" let p1: wsl;\n"
|
||||
" p1.a = 9; p1.b = raw[0:3];\n"
|
||||
" let p2: wsl = p1;\n"
|
||||
" if (p2.a != 9) { return 11; };\n"
|
||||
" if (p2.b.len != 3) { return 12; };\n"
|
||||
" return 0;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = { os.exit(produce()); };\n",
|
||||
4 },
|
||||
/* (d) i32 + tagged (i32|str) field, sz=32. Copy = 4 × MOVQ.
|
||||
* Runtime checks only p2.a; the asm load-count (>=4) and the
|
||||
@@ -174,21 +135,6 @@ static const struct row rows[] = {
|
||||
" if (p2.a != 5) { return 11; };\n"
|
||||
" return 0;\n"
|
||||
"};\n",
|
||||
"package main;\n"
|
||||
"import os;\n"
|
||||
"type tag = (i32 | str);\n"
|
||||
"type wtg = struct { a: i32, t: tag };\n"
|
||||
"fn produce() i32 = {\n"
|
||||
" let p1: wtg = wtg{a=5, t=42: tag};\n"
|
||||
" let p2: wtg = p1;\n"
|
||||
" if (p2.a != 5) { return 11; };\n"
|
||||
" match (p2.t) {\n"
|
||||
" case let x: i32 => if (x != 42) { return 12; };\n"
|
||||
" case let s: str => return 13;\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = { os.exit(produce()); };\n",
|
||||
4 },
|
||||
};
|
||||
|
||||
@@ -243,39 +189,6 @@ emit_s(const char *w6c, const struct row *r, int i, int stage,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
run_driver(const char *driver, const struct row *r, int i, int stage)
|
||||
{
|
||||
char tmpdir[64], src[128], outbin[128], rmcmd[160], cmd[1024];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/lcs_run_%d_d_%d_%d",
|
||||
getpid(), i, stage);
|
||||
mkdir(tmpdir, 0755);
|
||||
snprintf(src, sizeof src, "%s/lcs_run_%d_%d_%d.ww",
|
||||
tmpdir, getpid(), i, stage);
|
||||
snprintf(outbin, sizeof outbin, "%s/lcs_run_%d_%d_%d",
|
||||
tmpdir, getpid(), i, stage);
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) { runwait(rmcmd); return -1; }
|
||||
wwtest_fputs(r->run_src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s build -o %s %s 2>/dev/null",
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -289,14 +202,11 @@ main(void)
|
||||
bin = absbin;
|
||||
}
|
||||
|
||||
char w6c[640], w6c_ww[640], cdrv[640], wdrv[640];
|
||||
char w6c[640], w6c_ww[640];
|
||||
snprintf(w6c, sizeof w6c, "%s/w6c", bin);
|
||||
snprintf(w6c_ww, sizeof w6c_ww, "%s/w6c_ww", bin);
|
||||
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
|
||||
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
|
||||
|
||||
int have_ww = (access(w6c_ww, X_OK) == 0);
|
||||
int have_wdrv = (access(wdrv, X_OK) == 0);
|
||||
|
||||
int n = (int)(sizeof rows / sizeof rows[0]);
|
||||
int total = 0, fail = 0;
|
||||
@@ -343,27 +253,6 @@ main(void)
|
||||
}
|
||||
unlink(cs_path);
|
||||
|
||||
/* Runtime correctness via cstage driver. */
|
||||
total++;
|
||||
int got = run_driver(cdrv, r, i, 2);
|
||||
if (got != 0) {
|
||||
fprintf(stderr,
|
||||
"letcopy_struct[ww/%s]: exit=%d want=0\n",
|
||||
r->label, got);
|
||||
fail++;
|
||||
}
|
||||
|
||||
/* Runtime correctness via wwstage driver. */
|
||||
if (have_wdrv) {
|
||||
total++;
|
||||
got = run_driver(wdrv, r, i, 3);
|
||||
if (got != 0) {
|
||||
fprintf(stderr,
|
||||
"letcopy_struct[ww_ww/%s]: exit=%d want=0\n",
|
||||
r->label, got);
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fail) {
|
||||
|
||||
Reference in New Issue
Block a user