test/misc hosts the residual mixed-shape observers (divergence pins, stamp/stderr probes, .wwi trees) on testenv, wired into test-compiler beside the sep/xmod/asm families; its rule declares both full per-stage toolchains plus the wwdump twins for the coming files. The 689 port keeps the both-driver run-exit-6 backstop and the per-stage absolute DATAW row count (linker dedup and byte-id sweeps are both blind to a symmetric double-emit).
94 lines
2.7 KiB
Plaintext
94 lines
2.7 KiB
Plaintext
package arrglob_test;
|
|
|
|
// #12: a no-init module-level array global emits its zero-fill DATAW
|
|
// row EXACTLY ONCE. Port of the retired native carrier
|
|
// test/wcc/689_arrglob_nodup_run.c; every assertion preserved. The
|
|
// wwstage bug was a SIZE-keyed (sz == 24) str-fallback arm matching a
|
|
// [3]u64 global on top of the TY_ARRAY arm — two identical rows the
|
|
// linker deduped, so runtime and byte-id-only sweeps stayed blind to
|
|
// the absolute count: the per-stage count == 1 is the unowned claim.
|
|
//
|
|
// Legs: build+run exit 6 through both driver stages (correctness
|
|
// backstop), then per-stage `DATAW main.g(SB)` occurrence count == 1
|
|
// over the emitted .s (both stages emitting 2 identical rows would
|
|
// pass a byte-id sweep).
|
|
|
|
import os;
|
|
import os.exec;
|
|
import strings;
|
|
import testenv;
|
|
import time;
|
|
|
|
fn fail(label: str, why: str) void = {
|
|
let m: str = strings.concat("arrglob 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 src() str = {
|
|
return strings.concat(
|
|
"package main;\n",
|
|
"let g: [3]u64;\n",
|
|
"export fn main() i32 = {\n",
|
|
" g[0] = 1; g[1] = 2; g[2] = 3;\n",
|
|
" return (g[0] + g[1] + g[2]): i32;\n",
|
|
"};\n");
|
|
};
|
|
|
|
fn runcode(dir: str, name: str, argv: []str) i32 = {
|
|
let co: testenv.commandout;
|
|
testenv.runcommand(dir, dir, name, argv, tmo(), &co);
|
|
if (co.termination != exec.termination.EXIT) { return -1; };
|
|
return co.code;
|
|
};
|
|
|
|
@test fn rundrivers() void = {
|
|
let drvs: []str = ["ww", "ww_ww"];
|
|
let s: i32 = 0;
|
|
for (s < 2) {
|
|
let td: str = testenv.fresh();
|
|
testenv.writefile(strings.concat(td, "/t.ww"), src());
|
|
let av: []str = [testenv.driver(drvs[s]), "build", "-o",
|
|
"t", "t.ww"];
|
|
if (runcode(td, strings.concat("build_", drvs[s]), av) != 0) {
|
|
fail(drvs[s], "driver build failed");
|
|
};
|
|
let rav: []str = [strings.concat(td, "/t")];
|
|
if (runcode(td, strings.concat("run_", drvs[s]), rav) != 6) {
|
|
fail(drvs[s], "run-exit != 6");
|
|
};
|
|
testenv.clean(td);
|
|
s += 1;
|
|
};
|
|
};
|
|
|
|
@test fn datawcount() void = {
|
|
let tools: []str = ["w6c", "w6c_ww"];
|
|
let s: i32 = 0;
|
|
for (s < 2) {
|
|
let td: str = testenv.fresh();
|
|
testenv.writefile(strings.concat(td, "/t.ww"), src());
|
|
let av: []str = [testenv.driver(tools[s]), "-o",
|
|
strings.concat(td, "/t.s"),
|
|
strings.concat(td, "/t.ww")];
|
|
let co: testenv.commandout;
|
|
testenv.runcommand(td, td, tools[s], av, tmo(), &co);
|
|
if (co.termination != exec.termination.EXIT || co.code != 0) {
|
|
fail(tools[s], "compile failed");
|
|
};
|
|
let asm: str = testenv.readfile(strings.concat(td, "/t.s"));
|
|
let n: i32 = testenv.occurrences(asm, "DATAW main.g(SB)");
|
|
if (n != 1) {
|
|
fail(tools[s],
|
|
"DATAW main.g rows != 1 (double-emit #12)");
|
|
};
|
|
testenv.clean(td);
|
|
s += 1;
|
|
};
|
|
};
|