test: port the live cs/ww divergence pins to ww; retire 826 + 944 slim carriers
826_alias_tuple_coerce, 944_alias_accept_run and 944_variant_chain_b95_run all reduced to the same irreducible shape: a LIVE per-stage asymmetry (probed at HEAD) no symmetric fixture or @test can host. Ported under the DIVERGE discipline — both sides asserted loud (826 neg_0: cstage "not assignable to declared pair" vs wwstage over-accept; #96: cstage runs vs w6c_ww "unsupported address-of shape"; #277: cstage runs vs ww_ww "deferred #277"), so a fix on either side fails the row and demands graduation. Owned legs cited, not duplicated: r826_alias_tuple_* byte rows ride test-data-byteid, 826's neg_1 went symmetric at HEAD and moves to a //ww:error fixture per the audit split, the 944 value/reject corpora live in test/lang/{alias_accept,variant_chain_b95}_test.ww and the alias_*/vchain_* fixtures. Bundled: one file, one concern (held divergence pins).
This commit is contained in:
2
Makefile
2
Makefile
@@ -408,7 +408,7 @@ OBJECT_WW_TARGETS = $(OBJECT_WW_TESTS:%=wwtest/%)
|
||||
# cstage-only rejects). Compiler/driver gates like test/sep: they run
|
||||
# under test-compiler.
|
||||
MISC_WW_TESTS = test/misc/arrglob_test.ww test/misc/packedwwi_test.ww \
|
||||
test/misc/reject_test.ww
|
||||
test/misc/reject_test.ww test/misc/heldasym_test.ww
|
||||
MISC_WW_TARGETS = $(MISC_WW_TESTS:%=wwtest/%)
|
||||
BOOTSTRAP_WRAPPER_SOURCES = test/wcc/950_selfcheck.c \
|
||||
test/wcc/991_w6a_ww.c \
|
||||
|
||||
193
test/misc/heldasym_test.ww
Normal file
193
test/misc/heldasym_test.ww
Normal file
@@ -0,0 +1,193 @@
|
||||
package heldasym_test;
|
||||
|
||||
// LIVE cs-vs-ww divergence pins, ported from the retired native
|
||||
// carriers test/wcc/826_alias_tuple_coerce.c (neg_0),
|
||||
// test/wcc/944_alias_accept_run.c and
|
||||
// test/wcc/944_variant_chain_b95_run.c. Each row pins BOTH sides of a
|
||||
// held stage asymmetry the symmetric fixture grammar cannot host
|
||||
// (//ww:error demands both stages fail; @test needs ww to build).
|
||||
// DIVERGE discipline: the divergent side is asserted LOUD, so a fix
|
||||
// on either side fails the row and demands graduation to the
|
||||
// symmetric home — the asymmetry can never rot silently.
|
||||
//
|
||||
// aliastupleneg0: tuple-alias element-type mismatch. cstage rejects
|
||||
// with "not assignable to declared pair"; wwstage OVER-ACCEPTS (the
|
||||
// residual audit's held over-accept; graduates to a //ww:error
|
||||
// fixture on the wwstage tighten). The arity twin (neg_1) went
|
||||
// symmetric at HEAD and moves to the corpus per the audit split; the
|
||||
// r826_alias_tuple_* byte-id rows are owned by test-data-byteid.
|
||||
//
|
||||
// aliasaccept96 (held task #96): `&s.len` / `&s.cap` over a 1- or
|
||||
// 2-level alias-typed slice PARAM. cstage classifies the address
|
||||
// shape through the alias chase and runs correct (exit 0); the
|
||||
// wwstage frontend loud-rejects "unsupported address-of shape" — the
|
||||
// reject must carry its diagnostic, a crash is vacuous. Graduates to
|
||||
// test/lang/alias_accept_test.ww rows when #96 closes.
|
||||
//
|
||||
// variantchain277 (held task #277, out of #95): a CALL result typed
|
||||
// as a 2-level struct alias widened into (void | ali) then `v is
|
||||
// ali`. cstage's aggregate-return path builds+runs exit 0; the
|
||||
// wwstage DRIVER build loud-stops with the EXACT "deferred #277"
|
||||
// diagnostic (an unrelated wwstage error must not masquerade as
|
||||
// coverage — the ww_ww build path is where #277 fires, so the driver,
|
||||
// not bare w6c_ww, is driven). Graduates to test/lang when #277
|
||||
// wires.
|
||||
|
||||
import os;
|
||||
import os.exec;
|
||||
import strings;
|
||||
import testenv;
|
||||
import time;
|
||||
|
||||
fn fail(label: str, why: str) void = {
|
||||
let m: str = strings.concat("heldasym FAIL: ", label, " -- ", why,
|
||||
"\n");
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
assert(false);
|
||||
};
|
||||
|
||||
fn tmo() time.duration = {
|
||||
return (240i64 * (time.second: i64)): time.duration;
|
||||
};
|
||||
|
||||
fn rundir(dir: str, name: str, argv: []str, out: *testenv.commandout) i32 = {
|
||||
testenv.runcommand(dir, dir, name, argv, tmo(), out);
|
||||
if (out.termination != exec.termination.EXIT) { return -1; };
|
||||
return out.code;
|
||||
};
|
||||
|
||||
@test fn aliastupleneg0() void = {
|
||||
let td: str = testenv.fresh();
|
||||
testenv.writefile(strings.concat(td, "/n0.ww"), strings.concat(
|
||||
"package main;\n",
|
||||
"type pair = (int, int);\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet x: pair = (3, \"s\");\n",
|
||||
"\treturn x.0: i32;\n",
|
||||
"};\n"));
|
||||
let co: testenv.commandout;
|
||||
let cav: []str = [testenv.driver("w6c"), "-o",
|
||||
strings.concat(td, "/n0c.s"), strings.concat(td, "/n0.ww")];
|
||||
if (rundir(td, "cstage", cav, &co) == 0) {
|
||||
fail("neg_0", "w6c built (should loud-reject)");
|
||||
};
|
||||
if (!testenv.has(co.stderr, "not assignable to declared pair")) {
|
||||
fail("neg_0", "cstage reject lost its diagnostic");
|
||||
};
|
||||
let wav: []str = [testenv.driver("w6c_ww"), "-o",
|
||||
strings.concat(td, "/n0w.s"), strings.concat(td, "/n0.ww")];
|
||||
if (rundir(td, "wwstage", wav, &co) != 0) {
|
||||
fail("neg_0", strings.concat("w6c_ww rejected -- over-accept ",
|
||||
"closed; graduate this row to a //ww:error fixture"));
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
// cstage builds+runs exit 0; the wwstage FRONTEND (w6c_ww, where #96
|
||||
// fires) loud-rejects with its diagnostic.
|
||||
fn aliasrow(label: str, src: str) void = {
|
||||
let td: str = testenv.fresh();
|
||||
testenv.writefile(strings.concat(td, "/c.ww"), src);
|
||||
let co: testenv.commandout;
|
||||
let bav: []str = [testenv.driver("ww"), "build", "-o", "bin",
|
||||
"c.ww"];
|
||||
if (rundir(td, "build", bav, &co) != 0) {
|
||||
fail(label, "cstage build failed (want run)");
|
||||
};
|
||||
let rav: []str = [strings.concat(td, "/bin")];
|
||||
if (rundir(td, "run", rav, &co) != 0) {
|
||||
fail(label, "cstage run != 0");
|
||||
};
|
||||
let wav: []str = [testenv.driver("w6c_ww"), "-o",
|
||||
strings.concat(td, "/o.s"), strings.concat(td, "/c.ww")];
|
||||
if (rundir(td, "wwstage", wav, &co) == 0) {
|
||||
fail(label, strings.concat("w6c_ww accepted -- #96 closed; ",
|
||||
"graduate to test/lang/alias_accept_test.ww"));
|
||||
};
|
||||
if (!testenv.has(co.stderr, "unsupported address-of shape")) {
|
||||
fail(label, "wwstage reject lost its #96 diagnostic");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
@test fn aliasaccept96() void = {
|
||||
aliasrow("amplen1_bound96", strings.concat(
|
||||
"package main;\n",
|
||||
"type sl1 = []i64;\n",
|
||||
"fn check(s: sl1) i32 = {\n",
|
||||
"\tlet p: *i64 = &s.len;\n",
|
||||
"\tif (*p == 3) { return 0; };\n",
|
||||
"\treturn 1;\n",
|
||||
"};\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet b: []i64 = [1, 2, 3];\n",
|
||||
"\treturn check(b);\n",
|
||||
"};\n"));
|
||||
aliasrow("amplen2_bound96", strings.concat(
|
||||
"package main;\n",
|
||||
"type sl1 = []i64;\n",
|
||||
"type sl2 = sl1;\n",
|
||||
"fn check(s: sl2) i32 = {\n",
|
||||
"\tlet p: *i64 = &s.len;\n",
|
||||
"\tif (*p == 3) { return 0; };\n",
|
||||
"\treturn 1;\n",
|
||||
"};\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet b: []i64 = [1, 2, 3];\n",
|
||||
"\treturn check(b);\n",
|
||||
"};\n"));
|
||||
aliasrow("ampcap2_bound96", strings.concat(
|
||||
"package main;\n",
|
||||
"type sl1 = []i64;\n",
|
||||
"type sl2 = sl1;\n",
|
||||
"fn check(s: sl2) i32 = {\n",
|
||||
"\tlet p: *i64 = &s.cap;\n",
|
||||
"\tif (*p == 3) { return 0; };\n",
|
||||
"\treturn 1;\n",
|
||||
"};\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet b: []i64 = [1, 2, 3];\n",
|
||||
"\treturn check(b);\n",
|
||||
"};\n"));
|
||||
};
|
||||
|
||||
@test fn variantchain277() void = {
|
||||
let src: str = strings.concat(
|
||||
"package main;\n",
|
||||
"type base = struct { a: int, b: int };\n",
|
||||
"type al0 = base;\n",
|
||||
"type ali = al0;\n",
|
||||
"fn mk() ali = {\n",
|
||||
"\tlet s: ali;\n",
|
||||
"\ts.a = 4; s.b = 9;\n",
|
||||
"\treturn s;\n",
|
||||
"};\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet v: (void | ali) = mk();\n",
|
||||
"\tif (!(v is ali)) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n");
|
||||
let td: str = testenv.fresh();
|
||||
testenv.writefile(strings.concat(td, "/c.ww"), src);
|
||||
let co: testenv.commandout;
|
||||
let bav: []str = [testenv.driver("ww"), "build", "-o", "c",
|
||||
"c.ww"];
|
||||
if (rundir(td, "build_cstage", bav, &co) != 0) {
|
||||
fail("callret_bound277", "cstage build failed (want run)");
|
||||
};
|
||||
let rav: []str = [strings.concat(td, "/c")];
|
||||
if (rundir(td, "run_cstage", rav, &co) != 0) {
|
||||
fail("callret_bound277", "cstage run != 0");
|
||||
};
|
||||
let wav: []str = [testenv.driver("ww_ww"), "build", "-o", "cw",
|
||||
"c.ww"];
|
||||
if (rundir(td, "build_wwstage", wav, &co) == 0) {
|
||||
fail("callret_bound277", strings.concat("ww_ww accepted -- ",
|
||||
"#277 wired; graduate to test/lang"));
|
||||
};
|
||||
if (!testenv.has(co.stderr, "deferred #277")) {
|
||||
fail("callret_bound277", strings.concat("wwstage stop is not ",
|
||||
"the exact `deferred #277` diagnostic"));
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* 826_alias_tuple_coerce — residual asymmetric and assembly byte checks.
|
||||
* Symmetric runtime ownership is the r826_* compiler fixture set; the three
|
||||
* byte rows compile those exact files directly. Two negative controls remain
|
||||
* embedded because cstage must reject them while wwstage still over-accepts
|
||||
* them, so the symmetric fixture grammar cannot own that assertion.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
static int
|
||||
runwait(const char *cmd)
|
||||
{
|
||||
int rc = system(cmd);
|
||||
if (rc == -1) return -1;
|
||||
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct row { const char *label; const char *path; };
|
||||
|
||||
static const struct row rows[] = {
|
||||
{ "init", "test/wcc/data/r826_alias_tuple_init/case.ww" },
|
||||
{ "fnarg", "test/wcc/data/r826_alias_tuple_fnarg/case.ww" },
|
||||
{ "ret", "test/wcc/data/r826_alias_tuple_ret/case.ww" },
|
||||
};
|
||||
|
||||
static const char *neg[] = {
|
||||
"package main;\n"
|
||||
"type pair = (int, int);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
"\tlet x: pair = (3, \"s\");\n"
|
||||
"\treturn x.0: i32;\n"
|
||||
"};\n",
|
||||
|
||||
"package main;\n"
|
||||
"type pair = (int, int);\n"
|
||||
"export fn main() i32 = {\n"
|
||||
"\tlet x: pair = (3, 4, 5);\n"
|
||||
"\treturn x.0: i32;\n"
|
||||
"};\n",
|
||||
};
|
||||
|
||||
static int
|
||||
compile_should_fail(const char *compiler, const char *src, int i)
|
||||
{
|
||||
char s[128], outasm[128], cmd[1024];
|
||||
snprintf(s, sizeof s, "/tmp/atc_neg_%d_%d.ww", getpid(), i);
|
||||
snprintf(outasm, sizeof outasm, "/tmp/atc_neg_%d_%d.s", getpid(), i);
|
||||
FILE *f = fopen(s, "wb");
|
||||
if (!f) return -1;
|
||||
fputs(src, f);
|
||||
fclose(f);
|
||||
snprintf(cmd, sizeof cmd, "%s -o %s %s 2>/dev/null",
|
||||
compiler, outasm, s);
|
||||
int rc = runwait(cmd);
|
||||
unlink(s);
|
||||
unlink(outasm);
|
||||
return rc == 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asm_byte_identical(const char *bin, const struct row *r, int i)
|
||||
{
|
||||
char cs[64], ws[64], cmd[1024];
|
||||
snprintf(cs, sizeof cs, "/tmp/atc_asm_%d_%d_c.s", getpid(), i);
|
||||
snprintf(ws, sizeof ws, "/tmp/atc_asm_%d_%d_w.s", getpid(), i);
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>/dev/null",
|
||||
bin, cs, r->path);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c errored\n", r->label);
|
||||
return -1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>/dev/null",
|
||||
bin, ws, r->path);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww errored\n", r->label);
|
||||
unlink(cs);
|
||||
return -1;
|
||||
}
|
||||
FILE *fc = fopen(cs, "rb");
|
||||
FILE *fw = fopen(ws, "rb");
|
||||
int rc = 0;
|
||||
if (!fc || !fw) rc = -1;
|
||||
else {
|
||||
for (;;) {
|
||||
int a = fgetc(fc);
|
||||
int b = fgetc(fw);
|
||||
if (a != b) { rc = -1; break; }
|
||||
if (a == EOF) break;
|
||||
}
|
||||
}
|
||||
if (fc) fclose(fc);
|
||||
if (fw) fclose(fw);
|
||||
if (rc != 0)
|
||||
fprintf(stderr, "row[%s]: cstage vs wwstage asm differs\n",
|
||||
r->label);
|
||||
unlink(cs);
|
||||
unlink(ws);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char *bin = getenv("BIN");
|
||||
if (!bin) bin = "out/bin";
|
||||
char absbin[1024];
|
||||
if (bin[0] != '/') {
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin);
|
||||
bin = absbin;
|
||||
}
|
||||
char cdrv[1024], wdrv[1024];
|
||||
snprintf(cdrv, sizeof cdrv, "%s/w6c", bin);
|
||||
snprintf(wdrv, sizeof wdrv, "%s/w6c_ww", bin);
|
||||
int n = (int)(sizeof rows / sizeof rows[0]);
|
||||
int nneg = (int)(sizeof neg / sizeof neg[0]);
|
||||
int total = 0, fail = 0;
|
||||
for (int i = 0; i < nneg; i++) {
|
||||
total++;
|
||||
if (compile_should_fail(cdrv, neg[i], i) != 0) {
|
||||
fprintf(stderr,
|
||||
"alias_tuple_coerce[cstage][neg_%d]: built (should loud)\n",
|
||||
i);
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
if (access(wdrv, X_OK) == 0) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
total++;
|
||||
if (asm_byte_identical(bin, &rows[i], i) != 0) fail++;
|
||||
}
|
||||
}
|
||||
if (fail) {
|
||||
fprintf(stderr,
|
||||
"alias_tuple_coerce: %d/%d residual checks failed\n",
|
||||
fail, total);
|
||||
return 1;
|
||||
}
|
||||
printf("alias_tuple_coerce: %d/%d residual checks ok\n", total, total);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* 944_alias_accept_run — SLIM CARRIER (#5-C3 alias fold-2). The 62 K_RUN value
|
||||
* rows migrated to test/lang/alias_accept_test.ww (@test, cs==ww byte-id via
|
||||
* test-lang-byteid); the cs!=ww NOID row (v2_struct2, #81) to
|
||||
* test/lang/alias_accept_runonly_test.ww; the symmetric K_BUILDERR rejects
|
||||
* (assert_stays_loud, v2_ambig, v2_ambig2, union_as_bound_54) + the two
|
||||
* now-symmetric ex-K_BUILDERR_CS rows (binop_alias_vs_alias, untyped_nestvar,
|
||||
* superseded at HEAD) to test/wcc/data/alias_<name>/case.ww runww //ww:error.
|
||||
*
|
||||
* What survives here is the IRREDUCIBLE per-stage-asymmetric pin no in-language
|
||||
* surface can host: cstage builds+RUNS exit 0 while wwstage LOUD-REJECTS
|
||||
* (@test needs ww to build; runww //ww:error needs BOTH to fail). Held
|
||||
* divergence task #96: ww `&s.len` / `&s.cap` over an alias-typed slice PARAM
|
||||
* is "unsupported address-of shape"; cstage classifies the address shape
|
||||
* through the alias chase and runs correct. Drew-ruled slim-carrier home
|
||||
* (#5-C3, 954_tuprecv precedent).
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
static int
|
||||
runwait(const char *cmd)
|
||||
{
|
||||
int rc = system(cmd);
|
||||
if (rc == -1) return -1;
|
||||
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* a reject must fail WITH its diagnostic; a crash (no body) is vacuous. */
|
||||
static int
|
||||
errlog_has(const char *path, const char *needle)
|
||||
{
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) return 0;
|
||||
char buf[8192];
|
||||
size_t got = fread(buf, 1, sizeof buf - 1, f);
|
||||
fclose(f);
|
||||
buf[got] = '\0';
|
||||
return strstr(buf, needle) != NULL;
|
||||
}
|
||||
|
||||
/* cstage builds+runs (exit 0); wwstage frontend (w6c_ww) loud-rejects wwerr. */
|
||||
static int
|
||||
run_row(const char *bin, const char *label, const char *src,
|
||||
const char *wwerr, int i)
|
||||
{
|
||||
char dir[128], srcf[192], outbin[192], wwe[192], ss[192];
|
||||
char scratch[208], cmd[2048];
|
||||
snprintf(dir, sizeof dir, "/tmp/aacc_%d_%d_XXXXXX", getpid(), i);
|
||||
if (mkdtemp(dir) == NULL) {
|
||||
fprintf(stderr, "row[%s]: temporary directory acquisition failed\n",
|
||||
label);
|
||||
return -1;
|
||||
}
|
||||
snprintf(srcf, sizeof srcf, "%s/c.ww", dir);
|
||||
snprintf(outbin, sizeof outbin, "%s/bin", dir);
|
||||
snprintf(wwe, sizeof wwe, "%s/ww.err", dir);
|
||||
snprintf(ss, sizeof ss, "%s/o.s", dir);
|
||||
snprintf(scratch, sizeof scratch, "%s.sepwork", outbin);
|
||||
|
||||
FILE *f = fopen(srcf, "wb");
|
||||
int ok = 1;
|
||||
if (!f) {
|
||||
fprintf(stderr, "row[%s]: source setup failed\n", label);
|
||||
ok = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
fputs(src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"timeout 20 %s/ww build -o %s %s >/dev/null 2>&1", bin, outbin, srcf);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: cstage build failed (want run)\n", label);
|
||||
ok = 0;
|
||||
} else if (runwait(outbin) != 0) {
|
||||
fprintf(stderr, "row[%s]: cstage run != 0\n", label);
|
||||
ok = 0;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>%s", bin, ss, srcf, wwe);
|
||||
int wrc = runwait(cmd);
|
||||
if (!(wrc != 0 && errlog_has(wwe, wwerr))) {
|
||||
fprintf(stderr, "row[%s]: wwstage expected reject \"%s\" (rc=%d)\n",
|
||||
label, wwerr, wrc);
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
{
|
||||
int bad = 0;
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", scratch);
|
||||
if (runwait(cmd) != 0) bad = 1;
|
||||
if (unlink(ss) != 0 && errno != ENOENT) bad = 1;
|
||||
if (unlink(wwe) != 0 && errno != ENOENT) bad = 1;
|
||||
if (unlink(outbin) != 0 && errno != ENOENT) bad = 1;
|
||||
if (unlink(srcf) != 0 && errno != ENOENT) bad = 1;
|
||||
if (rmdir(dir) != 0) bad = 1;
|
||||
if (bad) {
|
||||
fprintf(stderr, "row[%s]: temporary cleanup failed\n", label);
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
struct row { const char *label; const char *src; const char *wwerr; };
|
||||
|
||||
static const struct row rows[] = {
|
||||
{ "amplen1_bound96",
|
||||
"package main;\n"
|
||||
"type sl1 = []i64;\n"
|
||||
"fn check(s: sl1) i32 = {\n"
|
||||
" let p: *i64 = &s.len;\n"
|
||||
" if (*p == 3) { return 0; };\n"
|
||||
" return 1;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let b: []i64 = [1, 2, 3];\n"
|
||||
" return check(b);\n"
|
||||
"};\n", "unsupported address-of shape" }, /* ww: task #96 */
|
||||
{ "amplen2_bound96",
|
||||
"package main;\n"
|
||||
"type sl1 = []i64;\n"
|
||||
"type sl2 = sl1;\n"
|
||||
"fn check(s: sl2) i32 = {\n"
|
||||
" let p: *i64 = &s.len;\n"
|
||||
" if (*p == 3) { return 0; };\n"
|
||||
" return 1;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let b: []i64 = [1, 2, 3];\n"
|
||||
" return check(b);\n"
|
||||
"};\n", "unsupported address-of shape" }, /* ww: task #96 */
|
||||
{ "ampcap2_bound96",
|
||||
"package main;\n"
|
||||
"type sl1 = []i64;\n"
|
||||
"type sl2 = sl1;\n"
|
||||
"fn check(s: sl2) i32 = {\n"
|
||||
" let p: *i64 = &s.cap;\n"
|
||||
" if (*p == 3) { return 0; };\n"
|
||||
" return 1;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let b: []i64 = [1, 2, 3];\n"
|
||||
" return check(b);\n"
|
||||
"};\n", "unsupported address-of shape" }, /* ww: task #96 */
|
||||
};
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char *bin = getenv("BIN");
|
||||
if (!bin) bin = "out/bin";
|
||||
char absbin[2080];
|
||||
if (bin[0] != '/') {
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin);
|
||||
bin = absbin;
|
||||
}
|
||||
|
||||
int n = (int)(sizeof rows / sizeof rows[0]);
|
||||
int fail = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
if (run_row(bin, rows[i].label, rows[i].src, rows[i].wwerr, i) != 0)
|
||||
fail++;
|
||||
|
||||
if (fail) {
|
||||
fprintf(stderr, "alias_accept (slim): %d/%d rows failed\n", fail, n);
|
||||
return 1;
|
||||
}
|
||||
printf("alias_accept (slim): %d/%d ok\n", n, n);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* 944_variant_chain_b95_run -- SLIMMED to the one irreducible asymmetric row.
|
||||
*
|
||||
* The #95 variant-match chain-membership corpus (22 rows) migrated to fold-2
|
||||
* homes (#5-C5): the K_RUN value rows -> test/lang/variant_chain_b95_test.ww
|
||||
* (@test + T2 byte-id); the two #81-byte-id-waived CALL-source rows ->
|
||||
* test/lang/variant_chain_b95_runonly_test.ww (value-only); the K_BUILDERR
|
||||
* reject rows -> test/wcc/data/vchain_<name>/case.ww runww //ww:error carriers.
|
||||
*
|
||||
* callret_bound277 (kb5_v2sE) CANNOT move: it is cstage-runs / wwstage-rejects
|
||||
* -- cstage builds+runs it (exit 0) while wwstage LOUD-STOPS with "deferred
|
||||
* #277" (the ww aggregate-return capability gap, OUT of #95). That asymmetry is
|
||||
* inexpressible as a single-compile @test (which builds one way) or a runww
|
||||
* //ww:error carrier (which demands BOTH stages reject). It stays a slim C pin.
|
||||
*
|
||||
* Non-vacuity (the pin CAN go RED): if cstage stops running it (exit != 0) or
|
||||
* wwstage starts accepting it (#277 wired), the row fails; the wwstage leg also
|
||||
* requires the EXACT "deferred #277" diagnostic so an unrelated wwstage error
|
||||
* cannot masquerade as coverage. Mutation-checked: dropping the cast-to-alias
|
||||
* (`mk()` typed plainly) flips cstage and was observed RED.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
static int
|
||||
runwait(const char *cmd)
|
||||
{
|
||||
int rc = system(cmd);
|
||||
if (rc == -1) return -1;
|
||||
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
errlog_has(const char *path, const char *needle)
|
||||
{
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) return 0;
|
||||
char buf[8192];
|
||||
size_t got = fread(buf, 1, sizeof buf - 1, f);
|
||||
fclose(f);
|
||||
buf[got] = '\0';
|
||||
return strstr(buf, needle) != NULL;
|
||||
}
|
||||
|
||||
/* kb5_v2sE: a CALL whose result is typed as the alias ali, widened into
|
||||
* (void | ali). cstage's aggregate-return path runs it; wwstage #277 rejects. */
|
||||
static const char *src =
|
||||
"package main;\n"
|
||||
"type base = struct { a: int, b: int };\n"
|
||||
"type al0 = base;\n"
|
||||
"type ali = al0;\n"
|
||||
"fn mk() ali = {\n"
|
||||
" let s: ali;\n"
|
||||
" s.a = 4; s.b = 9;\n"
|
||||
" return s;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: (void | ali) = mk();\n"
|
||||
" if (!(v is ali)) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n";
|
||||
|
||||
static const char *experr = "deferred #277";
|
||||
|
||||
/* Build src with `driver`; if expect_err, the build must FAIL with experr on
|
||||
* stderr. Otherwise build must succeed, then the binary runs and its exit must
|
||||
* equal `want`. Returns 0 on the expected outcome, 1 otherwise. */
|
||||
static int
|
||||
check(const char *driver, int expect_err, int want)
|
||||
{
|
||||
char tmpdir[128], srcp[192], outbin[192], errf[192];
|
||||
char scratch[208], cmd[1024];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/vc277_%d_%d_XXXXXX",
|
||||
getpid(), expect_err);
|
||||
if (mkdtemp(tmpdir) == NULL) {
|
||||
fprintf(stderr, "callret_bound277: %s temporary directory "
|
||||
"acquisition failed\n", driver);
|
||||
return 1;
|
||||
}
|
||||
snprintf(srcp, sizeof srcp, "%s/c.ww", tmpdir);
|
||||
snprintf(outbin, sizeof outbin, "%s/c", tmpdir);
|
||||
snprintf(errf, sizeof errf, "%s/err", tmpdir);
|
||||
snprintf(scratch, sizeof scratch, "%s.sepwork", outbin);
|
||||
|
||||
FILE *f = fopen(srcp, "wb");
|
||||
int rc = 0;
|
||||
if (!f) {
|
||||
fprintf(stderr, "callret_bound277: %s source setup failed\n",
|
||||
driver);
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
fputs(src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "timeout 20 %s build -o %s %s >/dev/null 2>%s",
|
||||
driver, outbin, srcp, errf);
|
||||
int brc = runwait(cmd);
|
||||
|
||||
if (expect_err) {
|
||||
if (brc == 0 || !errlog_has(errf, experr)) {
|
||||
fprintf(stderr, "callret_bound277: %s expected loud "
|
||||
"builderr \"%s\" (brc=%d)\n", driver, experr, brc);
|
||||
rc = 1;
|
||||
}
|
||||
} else if (brc != 0) {
|
||||
fprintf(stderr, "callret_bound277: build via %s failed\n", driver);
|
||||
rc = 1;
|
||||
} else {
|
||||
int got = runwait(outbin);
|
||||
if (got != want) {
|
||||
fprintf(stderr, "callret_bound277: %s exit %d, want %d\n",
|
||||
driver, got, want);
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
{
|
||||
int bad = 0;
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s", scratch);
|
||||
if (runwait(cmd) != 0) bad = 1;
|
||||
if (unlink(errf) != 0 && errno != ENOENT) bad = 1;
|
||||
if (unlink(outbin) != 0 && errno != ENOENT) bad = 1;
|
||||
if (unlink(srcp) != 0 && errno != ENOENT) bad = 1;
|
||||
if (rmdir(tmpdir) != 0) bad = 1;
|
||||
if (bad) {
|
||||
fprintf(stderr, "callret_bound277: %s temporary cleanup "
|
||||
"failed\n", driver);
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char *bin = getenv("BIN");
|
||||
if (!bin) bin = "out/bin";
|
||||
char absbin[2080];
|
||||
if (bin[0] != '/') {
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin);
|
||||
bin = absbin;
|
||||
}
|
||||
|
||||
char cdrv[2120], wdrv[2120];
|
||||
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
|
||||
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
|
||||
|
||||
int fail = 0;
|
||||
fail += check(cdrv, 0, 0); /* cstage runs, exit 0 */
|
||||
if (access(wdrv, X_OK) == 0)
|
||||
fail += check(wdrv, 1, 0); /* wwstage loud-stops #277 */
|
||||
|
||||
if (fail) {
|
||||
fprintf(stderr, "variant_chain_b95: %d checks failed\n", fail);
|
||||
return 1;
|
||||
}
|
||||
printf("variant_chain_b95: callret_bound277 pin ok\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user