扩展解释器WASM基础夹具

结论:解释器核心WASM验证新增G53、进给模式、位置参数和探测语义夹具,并通过LinuxCNC解释器状态读回覆盖position_params。
This commit is contained in:
2026-06-08 05:12:02 +08:00
parent 52bfa175ab
commit 123c335e8f
3 changed files with 23 additions and 13 deletions

View File

@@ -75,7 +75,8 @@ The WASM interpreter-core smoke script builds
vendored LinuxCNC interpreter source set used by the native minimal
interpreter harness. It loads the module in Node, runs the first WASM
interpreter fixture group through `Interp::execute()`, and compares emitted
canonical events with the matching files in `tests/fixtures/canon/`.
canonical events plus required LinuxCNC `_setup` state readback with the
matching files in `tests/fixtures/canon/`.
The OPFS host-boundary script validates the JavaScript file-service adapter
with a Node mock of the browser File System Access handles. It covers nested
@@ -143,7 +144,7 @@ The validation fails if:
| Harness | Purpose |
| --- | --- |
| `tests/wasm/node/verify_ini_wasm.sh` | Validates the browser-facing INI WASM module can be built from vendored LinuxCNC `inifile.cc`, loaded through the JS SDK in Node, and queried through the exported C ABI. |
| `tests/wasm/node/verify_interp_wasm.sh` | Validates the initial interpreter-core WASM module can be built from vendored LinuxCNC interpreter source, run the first fixture group through `Interp::execute()`, and match the native canonical event fixtures. |
| `tests/wasm/node/verify_interp_wasm.sh` | Validates the initial interpreter-core WASM module can be built from vendored LinuxCNC interpreter source, run the first fixture group through `Interp::execute()`, and match the native canonical event plus required state readback fixtures. |
| `tests/opfs/node/verify_file_service.sh` | Validates the host-owned OPFS text-file adapter, path model, session snapshot store, machine file store, and G-code text store used by the browser INI panel without moving file persistence into the WASM core. |
| `tests/browser/verify_ini_panel_browser.sh` | Validates the INI SDK, WASM module loading, OPFS text-file round trip, generic session snapshot round trip, machine file text round trip, and G-code text round trip in a real browser runtime. |
| `tests/host/verify_host_smokes.sh` | Runs the current host-side Node, WASM interpreter-core, OPFS, and browser smoke validation with shared WASM builds. |
@@ -192,10 +193,11 @@ Negative fixtures currently cover:
Current full-core validation is native-only. WASM/SDK validation covers the
INI parser smoke harness and an initial interpreter-core canonical event smoke
for `minimal_linear`, `arc_semantics`, `length_units`, `modal_incremental`,
`plane_selection`, and `coordinate_offsets`. OPFS validation is limited to the
JavaScript host-boundary adapter plus the INI browser smoke harness. Full
browser coverage, full SDK coverage, and full machine-session validation remain
future work.
`plane_selection`, `coordinate_offsets`, `g53_machine_coordinates`,
`feed_control_modes`, `position_params`, and `probe_semantics`. OPFS validation
is limited to the JavaScript host-boundary adapter plus the INI browser smoke
harness. Full browser coverage, full SDK coverage, and full machine-session
validation remain future work.
The current fixture expectations validate standalone behavior against both the
vendored LinuxCNC source path and an upstream `rs274` side-by-side baseline for

View File

@@ -146,6 +146,12 @@ char *lcinterp_run_program(const char *program_text)
for (const auto &event : standalone::canon_events()) {
output << "canon_event=" << event << "\n";
}
output << "setup.current_x=" << interp._setup.current_x << "\n";
output << "setup.current_y=" << interp._setup.current_y << "\n";
output << "setup.current_z=" << interp._setup.current_z << "\n";
output << "setup.parameter_5420=" << interp._setup.parameters[5420] << "\n";
output << "setup.parameter_5421=" << interp._setup.parameters[5421] << "\n";
output << "setup.parameter_5422=" << interp._setup.parameters[5422] << "\n";
return copy_result(output.str());
}

View File

@@ -47,6 +47,10 @@ const fixtureNames = [
"modal_incremental",
"plane_selection",
"coordinate_offsets",
"g53_machine_coordinates",
"feed_control_modes",
"position_params",
"probe_semantics",
];
for (const fixtureName of fixtureNames) {
@@ -60,16 +64,14 @@ for (const fixtureName of fixtureNames) {
).trimEnd();
const output = runProgram(interp, programText);
const actualEventSet = new Set(
output.split("\n").filter((line) => line.startsWith("canon_event=")),
);
const expectedEventLines = expectedEvents.split("\n").filter(Boolean);
const actualLineSet = new Set(output.split("\n").filter(Boolean));
const expectedLines = expectedEvents.split("\n").filter(Boolean);
for (const expectedEvent of expectedEventLines) {
for (const expectedLine of expectedLines) {
assert.equal(
actualEventSet.has(expectedEvent),
actualLineSet.has(expectedLine),
true,
`${fixtureName}: ${expectedEvent}`,
`${fixtureName}: ${expectedLine}`,
);
}
}