wcc: drop @test fns from non-T builds, both stages (harec check.c:3941)
Splice @test N_FNDECLs out of the unit after the body-check passes, mirroring harec's checked-but-not-emitted: a broken @test body still errors loudly in non-T; @test-free units are emission-unchanged. 910/997 table rows pin keep/test x non-T/-T, head+consecutive unlink, undef-body reject, and plain-calls-dropped loud link-fail. w6c+wwdump combined.ww regen. (#6-team)
This commit is contained in:
@@ -156,6 +156,104 @@ static const struct {
|
||||
{ "test/wcc/data/attest_badsig.ww", "non-void @test" },
|
||||
};
|
||||
|
||||
/* #6: TEXT-def present/absent rows for attest_nondrop.ww (mirror 910). */
|
||||
static const struct {
|
||||
const char *sym;
|
||||
int testmode; /* 1 => -T, 0 => plain build */
|
||||
int present;
|
||||
const char *what;
|
||||
} nondrop_rows[] = {
|
||||
{ "data.nondrop_keep", 0, 1, "plain fn kept non-T" },
|
||||
{ "data.nondrop_test_a", 0, 0, "head @test dropped non-T" },
|
||||
{ "data.nondrop_test_b", 0, 0, "mid @test dropped non-T" },
|
||||
{ "data.nondrop_test_c", 0, 0, "consecutive @test dropped non-T" },
|
||||
{ "data.nondrop_keep", 1, 1, "plain fn kept under -T" },
|
||||
{ "data.nondrop_test_a", 1, 1, "head @test kept under -T" },
|
||||
{ "data.nondrop_test_b", 1, 1, "mid @test kept under -T" },
|
||||
{ "data.nondrop_test_c", 1, 1, "consecutive @test kept under -T" },
|
||||
};
|
||||
|
||||
/* nondrop — drive the #6 splice through w6c_ww (rows) AND assert the
|
||||
* non-T asm is cs/ww byte-identical (rule 10: the drop must be symmetric,
|
||||
* not just cstage-side — 997's byteid above only covered -T mode). */
|
||||
static int
|
||||
nondrop(const char *bin)
|
||||
{
|
||||
int pid = getpid();
|
||||
char wp[256], wt[256], cp[256], 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(cmd, sizeof cmd,
|
||||
"%s/w6c_ww test/wcc/data/attest_nondrop.ww -o %s 2>/dev/null", bin, wp);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "997 FAIL: w6c_ww non-T nondrop compile\n");
|
||||
return 1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/w6c_ww -T test/wcc/data/attest_nondrop.ww -o %s 2>/dev/null", bin, wt);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "997 FAIL: w6c_ww -T nondrop compile\n");
|
||||
return 1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"%s/w6c test/wcc/data/attest_nondrop.ww -o %s 2>/dev/null", bin, cp);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "997 FAIL: w6c non-T nondrop compile\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rc = 0;
|
||||
for (size_t i = 0; i < sizeof nondrop_rows / sizeof nondrop_rows[0]; i++) {
|
||||
const char *f = nondrop_rows[i].testmode ? wt : wp;
|
||||
snprintf(cmd, sizeof cmd, "grep -q '^TEXT %s,' %s",
|
||||
nondrop_rows[i].sym, f);
|
||||
int found = runwait(cmd) == 0;
|
||||
if (found != nondrop_rows[i].present) {
|
||||
fprintf(stderr, "997 FAIL: w6c_ww — %s: %s %s (expected %s)\n",
|
||||
nondrop_rows[i].what, nondrop_rows[i].sym,
|
||||
found ? "present" : "absent",
|
||||
nondrop_rows[i].present ? "present" : "absent");
|
||||
rc = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rc == 0) {
|
||||
char *bc = NULL, *bw = NULL;
|
||||
size_t nc = 0, nw = 0;
|
||||
if (slurp(cp, &bc, &nc) < 0 || slurp(wp, &bw, &nw) < 0) {
|
||||
fprintf(stderr, "997 FAIL: slurp non-T nondrop asm\n");
|
||||
rc = 1;
|
||||
} else if (nc != nw || memcmp(bc, bw, nc) != 0) {
|
||||
fprintf(stderr, "997 FAIL: non-T @test-drop asm differs "
|
||||
"(cs %zu, ww %zu)\n", nc, nw);
|
||||
rc = 1;
|
||||
}
|
||||
free(bc); free(bw);
|
||||
}
|
||||
unlink(wp); unlink(wt); unlink(cp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* reject_plain — `w6c_ww <fixture>` (NON-T) must exit nonzero. Pins (as
|
||||
* 910 does for cstage) that wwstage type-checks a @test body before the
|
||||
* #6 splice drops it: an undefined symbol is caught loud even though the
|
||||
* fn never reaches codegen (checked at check.ww pass 2/3, dropped after). */
|
||||
static int
|
||||
reject_plain(const char *bin, const char *fixture, const char *what)
|
||||
{
|
||||
char cmd[4096];
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww %s -o /dev/null 2>/dev/null",
|
||||
bin, fixture);
|
||||
if (runwait(cmd) == 0) {
|
||||
fprintf(stderr, "997 FAIL: w6c_ww (non-T) accepted %s "
|
||||
"(expected reject)\n", what);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -167,7 +265,11 @@ main(void)
|
||||
for (size_t i = 0; i < sizeof rejects / sizeof rejects[0]; i++)
|
||||
if (reject(bin, rejects[i].fixture, rejects[i].what) != 0)
|
||||
return 1;
|
||||
if (nondrop(bin) != 0) return 1;
|
||||
if (reject_plain(bin, "test/wcc/data/attest_undefbody.ww",
|
||||
"undefined symbol in @test body") != 0) return 1;
|
||||
|
||||
printf("@test -T (ww_ww): run ok + cs/ww byte-id + rejects ok\n");
|
||||
printf("@test -T (ww_ww): run ok + cs/ww byte-id + rejects + "
|
||||
"non-T @test drop cs/ww byte-id + checked-body (#6)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user