ww test: fork-isolated record-and-continue harness (lib/test, both stages)
lib/test/run.ww: fork+wait4 runner; each @test runs in its own child, abort/SEGV/FPE decoded from wait-status, failures recorded and the run continues; exit = fail count. Tests are hermetic: module globals do not persist test-to-test (fresh fork image; sanctioned divergence from harec's shared-process __test_main, no setjmp/signal layer needed). -T synth (both stages) emits a module-global (str,*fn() void) table + return run(table) instead of straight-line calls. Driver twins bundle lib/test under test mode and gain ww test -c/-o (go test -c) so the byte-id gates diff the same artifact the real path builds. Gates 989/910/997 rewired onto it; new 911 pins record-and-continue across all three fault classes; 949 +3 rows. (#17-team commit-2)
This commit is contained in:
@@ -66,9 +66,10 @@ static int
|
||||
run_fixture(const char *bin)
|
||||
{
|
||||
int pid = getpid();
|
||||
char src[256], comb[256], asmf[256], obj[256], exe[256];
|
||||
char src[256], comb[256], binout[256], asmf[256], obj[256], exe[256];
|
||||
char rt[1024], cmd[4096];
|
||||
snprintf(src, sizeof src, "/tmp/at997_%d.ww", pid);
|
||||
snprintf(binout, sizeof binout, "/tmp/at997_%d", pid);
|
||||
snprintf(comb, sizeof comb, "/tmp/at997_%d.combined.ww", pid);
|
||||
snprintf(asmf, sizeof asmf, "/tmp/at997_%d.s", pid);
|
||||
snprintf(obj, sizeof obj, "/tmp/at997_%d.o", pid);
|
||||
@@ -78,10 +79,12 @@ run_fixture(const char *bin)
|
||||
snprintf(cmd, sizeof cmd, "cp test/wcc/data/attest_pass.ww %s", src);
|
||||
if (runwait(cmd) != 0) { fprintf(stderr, "997 FAIL: cp\n"); return 1; }
|
||||
|
||||
/* ww_ww build resolves `import rt` into the combined unit; it exits
|
||||
* nonzero (no main — that is what -T synthesizes), so we gate on the
|
||||
* combined ARTIFACT existing, not the exit code. */
|
||||
snprintf(cmd, sizeof cmd, "%s/ww_ww build %s > /dev/null 2>&1", bin, src);
|
||||
/* `ww_ww test -c -o <stem>` (compile-only) resolves imports AND auto-
|
||||
* bundles lib/test (#17) into <stem>.combined.ww — the synth's run()
|
||||
* callee must link below — WITHOUT running the harness. We gate on the
|
||||
* combined ARTIFACT existing; `-o` keeps the binary off the CWD. */
|
||||
snprintf(cmd, sizeof cmd, "%s/ww_ww test -c -o %s %s > /dev/null 2>&1",
|
||||
bin, binout, src);
|
||||
runwait(cmd);
|
||||
if (access(comb, 0) != 0) {
|
||||
fprintf(stderr, "997 FAIL: ww_ww build produced no %s\n", comb);
|
||||
@@ -101,23 +104,38 @@ run_fixture(const char *bin)
|
||||
return 1;
|
||||
}
|
||||
unlink(src); unlink(comb); unlink(asmf); unlink(obj); unlink(exe);
|
||||
unlink(binout);
|
||||
char tmp[300];
|
||||
snprintf(tmp, sizeof tmp, "%s.s", binout); unlink(tmp);
|
||||
snprintf(tmp, sizeof tmp, "%s.o", binout); unlink(tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* byteid — `w6c -T` and `w6c_ww -T` on the same source must agree. */
|
||||
/* byteid — `w6c -T` and `w6c_ww -T` on the same unit must agree. The #17
|
||||
* synth's run() callee only resolves against the auto-bundled lib/test, so
|
||||
* we byte-compare the lib/test-INCLUSIVE combined (raw -T of the fixture
|
||||
* would loud-reject the undefined run); `ww test -c` writes that combined. */
|
||||
static int
|
||||
byteid(const char *bin)
|
||||
{
|
||||
int pid = getpid();
|
||||
char cs[256], ws[256], cmd[4096];
|
||||
char stem[256], comb[256], cs[256], ws[256], cmd[4096];
|
||||
snprintf(stem, sizeof stem, "/tmp/at997_bid_%d", pid);
|
||||
snprintf(comb, sizeof comb, "%s.combined.ww", stem);
|
||||
snprintf(cs, sizeof cs, "/tmp/at997_bid_c_%d.s", pid);
|
||||
snprintf(ws, sizeof ws, "/tmp/at997_bid_w_%d.s", pid);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -T test/wcc/data/attest_pass.ww -o %s 2>/dev/null",
|
||||
bin, cs);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/ww test -c -o %s test/wcc/data/attest_pass.ww > /dev/null 2>&1",
|
||||
bin, stem);
|
||||
runwait(cmd);
|
||||
if (access(comb, 0) != 0) {
|
||||
fprintf(stderr, "997 FAIL: ww test -c produced no %s\n", comb);
|
||||
return 1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -T %s -o %s 2>/dev/null", bin, comb, cs);
|
||||
if (runwait(cmd) != 0) { fprintf(stderr, "997 FAIL: w6c -T (byteid)\n"); return 1; }
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -T test/wcc/data/attest_pass.ww -o %s 2>/dev/null",
|
||||
bin, ws);
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -T %s -o %s 2>/dev/null", bin, comb, ws);
|
||||
if (runwait(cmd) != 0) { fprintf(stderr, "997 FAIL: w6c_ww -T (byteid)\n"); return 1; }
|
||||
|
||||
char *bc = NULL, *bw = NULL;
|
||||
@@ -131,7 +149,11 @@ byteid(const char *bin)
|
||||
rc = 1;
|
||||
}
|
||||
free(bc); free(bw);
|
||||
unlink(cs); unlink(ws);
|
||||
unlink(comb); unlink(cs); unlink(ws);
|
||||
char tmp[300];
|
||||
snprintf(tmp, sizeof tmp, "%s.s", stem); unlink(tmp);
|
||||
snprintf(tmp, sizeof tmp, "%s.o", stem); unlink(tmp);
|
||||
unlink(stem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -180,10 +202,12 @@ static int
|
||||
nondrop(const char *bin)
|
||||
{
|
||||
int pid = getpid();
|
||||
char wp[256], wt[256], cp[256], cmd[4096];
|
||||
char wp[256], wt[256], cp[256], stem[256], comb[300], cmd[4096];
|
||||
snprintf(wp, sizeof wp, "/tmp/at997nd_wp_%d.s", pid);
|
||||
snprintf(wt, sizeof wt, "/tmp/at997nd_wt_%d.s", pid);
|
||||
snprintf(cp, sizeof cp, "/tmp/at997nd_cp_%d.s", pid);
|
||||
snprintf(stem, sizeof stem, "/tmp/at997nd_c_%d", pid);
|
||||
snprintf(comb, sizeof comb, "%s.combined.ww", stem);
|
||||
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/w6c_ww test/wcc/data/attest_nondrop.ww -o %s 2>/dev/null", bin, wp);
|
||||
@@ -191,8 +215,14 @@ nondrop(const char *bin)
|
||||
fprintf(stderr, "997 FAIL: w6c_ww non-T nondrop compile\n");
|
||||
return 1;
|
||||
}
|
||||
/* the -T compile synthesizes a main calling lib/test's run(), so it
|
||||
* needs the lib/test-inclusive combined `ww test -c` writes. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/w6c_ww -T test/wcc/data/attest_nondrop.ww -o %s 2>/dev/null", bin, wt);
|
||||
"%s/ww test -c -o %s test/wcc/data/attest_nondrop.ww > /dev/null 2>&1",
|
||||
bin, stem);
|
||||
runwait(cmd);
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/w6c_ww -T %s -o %s 2>/dev/null", bin, comb, wt);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "997 FAIL: w6c_ww -T nondrop compile\n");
|
||||
return 1;
|
||||
@@ -232,7 +262,11 @@ nondrop(const char *bin)
|
||||
}
|
||||
free(bc); free(bw);
|
||||
}
|
||||
unlink(wp); unlink(wt); unlink(cp);
|
||||
unlink(wp); unlink(wt); unlink(cp); unlink(comb);
|
||||
char tmp[300];
|
||||
snprintf(tmp, sizeof tmp, "%s.s", stem); unlink(tmp);
|
||||
snprintf(tmp, sizeof tmp, "%s.o", stem); unlink(tmp);
|
||||
unlink(stem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user