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:
2026-06-11 00:08:39 +09:00
parent 08a76cf4c8
commit 16c83e70d3
15 changed files with 961 additions and 194 deletions

View File

@@ -54,9 +54,10 @@ static int
run_fixture(const char *bin, const char *comp, const char *drv)
{
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/at910_%s_%d.ww", comp, pid);
snprintf(binout, sizeof binout, "/tmp/at910_%s_%d", comp, pid);
snprintf(comb, sizeof comb, "/tmp/at910_%s_%d.combined.ww", comp, pid);
snprintf(asmf, sizeof asmf, "/tmp/at910_%s_%d.s", comp, pid);
snprintf(obj, sizeof obj, "/tmp/at910_%s_%d.o", comp, pid);
@@ -66,12 +67,12 @@ run_fixture(const char *bin, const char *comp, const char *drv)
snprintf(cmd, sizeof cmd, "cp test/wcc/data/attest_pass.ww %s", src);
if (runwait(cmd) != 0) { fprintf(stderr, "910 FAIL: cp\n"); return 1; }
/* Driver resolves `import rt` into <src>.combined.ww. The build
* itself exits nonzero (the @test-only fixture has no main — that
* is exactly what -T synthesizes), but the combined unit is written
* before any compile step, so we depend on the ARTIFACT, not the
* exit code. */
snprintf(cmd, sizeof cmd, "%s/%s build %s > /dev/null 2>&1", bin, drv, src);
/* `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 depend on the
* combined ARTIFACT; `-o` keeps the binary off the CWD. */
snprintf(cmd, sizeof cmd, "%s/%s test -c -o %s %s > /dev/null 2>&1",
bin, drv, binout, src);
runwait(cmd);
if (access(comb, 0) != 0) {
fprintf(stderr, "910 FAIL: %s build produced no %s\n", drv, comb);
@@ -94,6 +95,10 @@ run_fixture(const char *bin, const char *comp, const char *drv)
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;
}
@@ -161,9 +166,18 @@ nondrop(const char *bin, const char *comp)
fprintf(stderr, "910 FAIL: %s non-T nondrop compile\n", comp);
return 1;
}
/* The -T compile synthesizes a main that calls lib/test's run(), so it
* needs the lib/test-inclusive combined `ww test -c` writes (the plain
* compile above has no synth, so it stays on the raw fixture). */
char stem[256], comb[300];
snprintf(stem, sizeof stem, "/tmp/at910nd_%s_c_%d", comp, pid);
snprintf(comb, sizeof comb, "%s.combined.ww", stem);
snprintf(cmd, sizeof cmd,
"%s/%s -T test/wcc/data/attest_nondrop.ww -o %s 2>/dev/null",
bin, comp, tee);
"%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/%s -T %s -o %s 2>/dev/null", bin, comp, comb, tee);
if (runwait(cmd) != 0) {
fprintf(stderr, "910 FAIL: %s -T nondrop compile\n", comp);
return 1;
@@ -184,7 +198,11 @@ nondrop(const char *bin, const char *comp)
break;
}
}
unlink(plain); unlink(tee);
unlink(plain); unlink(tee); 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;
}