diff --git a/wasm-port/docs/compatibility-validation.md b/wasm-port/docs/compatibility-validation.md index abb1614..27608eb 100644 --- a/wasm-port/docs/compatibility-validation.md +++ b/wasm-port/docs/compatibility-validation.md @@ -104,7 +104,8 @@ Emscripten filesystem through the SDK and runs them through LinuxCNC file execution path. The same Node smoke writes LinuxCNC-format parameter files into the Emscripten filesystem and validates vendored `Interp::restore_parameters()` and `Interp::save_parameters()`, including the -saved parameter values and `.bak` backup file boundary. It also writes the +saved parameter values, missing required numeric parameter defaulting, and the +`.bak` backup file boundary. It also writes the negative G-code fixtures into the Emscripten filesystem and verifies their LinuxCNC-produced error text through the `Interp::open()`/`read()`/`execute()` file path. @@ -291,9 +292,10 @@ group and check the LinuxCNC file-execution error text plus absent canonical motion constraints where applicable. The Node WASM and browser interpreter smokes also cover LinuxCNC parameter-file restore/save behavior through the exported C ABI, including out-of-order file -rejection, missing-file success, required numeric parameter writeback, removal -of named-parameter-only lines from saved output, and the `.bak` backup produced -by vendored `save_parameters()`. It also covers LinuxCNC tool-table +rejection, missing-file success, missing required numeric parameter defaulting, +required numeric parameter writeback, removal of named-parameter-only lines +from saved output, and the `.bak` backup produced by vendored +`save_parameters()`. It also covers LinuxCNC tool-table load/save behavior through vendored `tooldata_common.cc`, including the non-random and random-toolchanger `tooldata_init()` branches, with the SDK only copying text into the Emscripten filesystem and calling the exported C diff --git a/wasm-port/docs/drift-report.md b/wasm-port/docs/drift-report.md index f351a51..bbeeb2b 100644 --- a/wasm-port/docs/drift-report.md +++ b/wasm-port/docs/drift-report.md @@ -33,7 +33,7 @@ semantic rewrites: | Interpreter state tags | LinuxCNC `UPDATE_TAG` callbacks are captured from the state tags packed by vendored interpreter code; standalone code does not derive modal state. | | Rotary indexer lock state | LinuxCNC `UNLOCK_ROTARY` and `LOCK_ROTARY` callbacks are captured from the vendored single-axis indexer path; standalone code does not implement rotary-indexing semantics, and native, Node WASM, and browser interpreter smokes validate the same boundary events. | | File flush | LinuxCNC `FINISH` is captured as a canonical test event on the vendored `%`-delimited file-reading path. | -| WASM parameter-file backup | LinuxCNC `save_parameters()` calls `link()` to create the `.bak` parameter-file backup; `runtime/core/linuxcnc_wrap/linuxcnc_wasm_posix_stubs.cpp` maps that WASM/MEMFS edge to a file copy so the vendored save path can run unchanged. | +| WASM parameter-file backup | LinuxCNC `save_parameters()` calls `link()` to create the `.bak` parameter-file backup; `runtime/core/linuxcnc_wrap/linuxcnc_wasm_posix_stubs.cpp` maps that WASM/MEMFS edge to a file copy so the vendored save path can run unchanged, while `restore_parameters()` behavior such as missing required numeric parameter defaulting remains vendored LinuxCNC behavior validated through native, Node WASM, and browser interpreter smokes. | | Interpreter reset | LinuxCNC `ON_RESET` is captured as a canonical test event on the vendored interpreter reset/file-open path. | | Interpreter init | LinuxCNC `INIT_CANON` and the canonical initialization sequence from vendored `Interp::init()` are captured as test events in native, Node WASM, and browser interpreter validation. | | Comment logging | LinuxCNC `LOGOPEN`, `LOG`, `LOGAPPEND`, and `LOGCLOSE` callbacks are captured as canonical test events instead of writing host log files. | diff --git a/wasm-port/docs/source-reuse-map.md b/wasm-port/docs/source-reuse-map.md index c7c51e8..7a4154e 100644 --- a/wasm-port/docs/source-reuse-map.md +++ b/wasm-port/docs/source-reuse-map.md @@ -54,7 +54,7 @@ Current validation is intentionally mechanical: | Dependency | LinuxCNC files that expose it | Standalone treatment | | --- | --- | --- | -| Native file IO | `inifile.cc`, `rs274ngc_pre.cc`, `tooldata_common.cc`, parameter file paths, tool table paths | Allowed in native probes; the interpreter WASM C ABI validates parameter-file restore/save by calling vendored `Interp::restore_parameters()` and `Interp::save_parameters()` and tool-table load/save by calling vendored `tooldata_load()` and `tooldata_save()` against Emscripten filesystem paths; browser OPFS remains a host-side adapter under `runtime/opfs/`, with path ownership in `runtime/opfs/path-model.js`, generic snapshot persistence in `runtime/opfs/snapshot-store.js`, pure-text machine-file persistence in `runtime/opfs/machine-file-store.js`, OPFS-to-WASM parameter-file copying in `runtime/opfs/linuxcnc-parameter-bridge.js`, OPFS-to-WASM tool-table copying in `runtime/opfs/linuxcnc-tool-table-bridge.js`, and grouped INI/parameter/tool-table session loading in `runtime/opfs/linuxcnc-machine-session-bridge.js`, including INI-derived `[RS274NGC]PARAMETER_FILE` and `[EMCIO]TOOL_TABLE` OPFS filename selection through the LinuxCNC-backed INI SDK; explicit host session file-name options take precedence over INI-derived names, missing INI file-name values fall back to host default `linuxcnc.var` and `tool.tbl` paths, and OPFS path validation rejects traversal and nested segments before host storage access | +| Native file IO | `inifile.cc`, `rs274ngc_pre.cc`, `tooldata_common.cc`, parameter file paths, tool table paths | Allowed in native probes; the interpreter WASM C ABI validates parameter-file restore/save by calling vendored `Interp::restore_parameters()` and `Interp::save_parameters()`, including missing required numeric parameter defaulting, and tool-table load/save by calling vendored `tooldata_load()` and `tooldata_save()` against Emscripten filesystem paths; browser OPFS remains a host-side adapter under `runtime/opfs/`, with path ownership in `runtime/opfs/path-model.js`, generic snapshot persistence in `runtime/opfs/snapshot-store.js`, pure-text machine-file persistence in `runtime/opfs/machine-file-store.js`, OPFS-to-WASM parameter-file copying in `runtime/opfs/linuxcnc-parameter-bridge.js`, OPFS-to-WASM tool-table copying in `runtime/opfs/linuxcnc-tool-table-bridge.js`, and grouped INI/parameter/tool-table session loading in `runtime/opfs/linuxcnc-machine-session-bridge.js`, including INI-derived `[RS274NGC]PARAMETER_FILE` and `[EMCIO]TOOL_TABLE` OPFS filename selection through the LinuxCNC-backed INI SDK; explicit host session file-name options take precedence over INI-derived names, missing INI file-name values fall back to host default `linuxcnc.var` and `tool.tbl` paths, and OPFS path validation rejects traversal and nested segments before host storage access | | RTAPI | `rtapi_*.h`, TP, posemath, motion headers | Minimal standalone shim in `runtime/core/shims/rtapi.h` | | NML transport | `emc.hh`, motion/NML type headers | Transport is not ported; only the status/type edges needed by vendored compute code are exposed through standalone shims and probes | | HAL runtime | named parameter lookup, kinematics component lifecycle, and runtime status edges | Standalone HAL adapter under `runtime/core/linuxcnc_wrap/` | diff --git a/wasm-port/tests/browser/interp_smoke.html b/wasm-port/tests/browser/interp_smoke.html index e7aa087..dc06a57 100644 --- a/wasm-port/tests/browser/interp_smoke.html +++ b/wasm-port/tests/browser/interp_smoke.html @@ -288,6 +288,18 @@ ].join("\n"), ); + const missingRequiredParameterFilePath = "/work/browser-missing-required.var"; + interp.writeTextFile(missingRequiredParameterFilePath, "5161 3.5\n5220 1\n"); + verifyExpectedOutput( + "restore_parameters_missing_required", + interp.restoreParameters(missingRequiredParameterFilePath), + [ + "restore_parameters=0", + "parameter_5161=3.5", + "parameter_5162=0", + ].join("\n"), + ); + await saveMachineTextFiles("browser-interp", { ini: "[EMC]\nMACHINE = browser-interp\n", toolTable: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser finish tool\n", diff --git a/wasm-port/tests/wasm/node/verify_interp_wasm.mjs b/wasm-port/tests/wasm/node/verify_interp_wasm.mjs index ceb4aa4..bb4e541 100644 --- a/wasm-port/tests/wasm/node/verify_interp_wasm.mjs +++ b/wasm-port/tests/wasm/node/verify_interp_wasm.mjs @@ -301,6 +301,18 @@ verifyExpectedOutput( ].join("\n"), ); +const missingRequiredParameterFilePath = "/work/missing-required.var"; +interp.writeTextFile(missingRequiredParameterFilePath, "5161 3.5\n5220 1\n"); +verifyExpectedOutput( + "restore_parameters_missing_required", + interp.restoreParameters(missingRequiredParameterFilePath), + [ + "restore_parameters=0", + "parameter_5161=3.5", + "parameter_5162=0", + ].join("\n"), +); + verifyExpectedOutput( "save_parameters", interp.saveParameters(parameterFilePath, {