diff --git a/docs/linuxcnc-porting.md b/docs/linuxcnc-porting.md index 5febe22..dc58418 100644 --- a/docs/linuxcnc-porting.md +++ b/docs/linuxcnc-porting.md @@ -213,5 +213,6 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu | Probe moves `G38.2/G38.3/G38.4/G38.5` | covered as distinct probe events with LinuxCNC `probe_type` preserved through smoke, native, and source-linked paths | `tests/gcode/linuxcnc_probe_no_error.ngc` | | O-word subroutines, calls, and control flow | covered for numeric and named `O... sub/call/return/endsub` plus `if`/`elseif`/`else`, `while`, `repeat`, `do`/`while`, `break`, and `continue` through LinuxCNC file mode; smoke parser also covers named `O` sub/call/return/endsub and loop-control forms | `tests/gcode/smoke_oword_subprogram.ngc`, `tests/gcode/linuxcnc_named_oword_subprogram.ngc`, `tests/gcode/linuxcnc_oword_control_flow.ngc` | | Parameter expressions and operators | covered for parameter references, source-linked `mod`, `**`, logical, and relational operator precedence, plus LinuxCNC divide-by-zero, negative-power, malformed `ATAN[]/[]`, unary operation, `read_operation()` binary-operation prefix, unknown operation, and unclosed-expression error paths from `interp_read.cc`/`interp_execute.cc` | `tests/gcode/linuxcnc_parameter_expression_assignment.ngc`, `tests/gcode/linuxcnc_expression_operators.ngc`, `tests/gcode/linuxcnc_divide_by_zero_error.ngc`, `tests/gcode/linuxcnc_negative_power_error.ngc`, `tests/gcode/linuxcnc_atan_missing_slash_error.ngc`, `tests/gcode/linuxcnc_atan_missing_bracket_error.ngc`, `tests/gcode/linuxcnc_unary_missing_bracket_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_word_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_a_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_e_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_g_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_l_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_m_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_n_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_o_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_x_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_operation_error.ngc`, `tests/gcode/linuxcnc_unclosed_expression_error.ngc` | +| Word reader validation | source-linked LinuxCNC reader errors covered for negative `F/G/H/L/M/S/T` values and repeated `F/H/L/S/T/X/Y/Z` words from `interp_read.cc` | `tests/gcode/linuxcnc_negative_f_word_error.ngc`, `tests/gcode/linuxcnc_negative_g_code_error.ngc`, `tests/gcode/linuxcnc_negative_h_word_error.ngc`, `tests/gcode/linuxcnc_negative_l_word_error.ngc`, `tests/gcode/linuxcnc_negative_m_code_error.ngc`, `tests/gcode/linuxcnc_negative_s_word_error.ngc`, `tests/gcode/linuxcnc_negative_t_word_error.ngc`, `tests/gcode/linuxcnc_multiple_f_words_error.ngc`, `tests/gcode/linuxcnc_multiple_h_words_error.ngc`, `tests/gcode/linuxcnc_multiple_l_words_error.ngc`, `tests/gcode/linuxcnc_multiple_s_words_error.ngc`, `tests/gcode/linuxcnc_multiple_t_words_error.ngc`, `tests/gcode/linuxcnc_multiple_x_words_error.ngc`, `tests/gcode/linuxcnc_multiple_y_words_error.ngc`, `tests/gcode/linuxcnc_multiple_z_words_error.ngc` | | Broader canned cycles `G73`, `G74`, `G82`-`G89` | partially covered: `G73`, `G74`, `G82`, `G83`, `G84`, `G85`, `G86`, `G87`, `G88`, `G89`; smoke parser maps supported cycles across `G17/G18/G19`, including LinuxCNC's special non-XY `G74/G84` tapping argument order and `G87` plane-specific `I/J/K` mapping; native/source regressions now check non-XY `G74/G84/G86/G87/G88` sequences | `tests/gcode/linuxcnc_canned_cycles_extended.ngc`, `tests/gcode/linuxcnc_canned_cycle_planes.ngc`, smoke API regression | | Full source-level wasm build | covered for the current wasm-safe RS274 source set, with remaining work focused on broadening browser-hostile dependency replacement and feature coverage | `./build-wasm.sh`, `test-linuxcnc-wasm-runtime-link.sh`, `test-web-wasm-node-smoke.sh`, `test-web-wasm-browser-smoke.sh` | diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index ae8718b..f1af5dc 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -654,6 +654,53 @@ for case in "${binary_operation_error_cases[@]}"; do fi grep -q "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" done +# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc +# read_f()/read_g()/read_h()/read_l()/read_m()/read_s()/read_t() +# reject negative word values before command execution. +negative_word_error_cases=( + "linuxcnc_negative_f_word_error|Negative f word used" + "linuxcnc_negative_g_code_error|Negative g code used" + "linuxcnc_negative_h_word_error|Negative h word used" + "linuxcnc_negative_l_word_error|Negative l word used" + "linuxcnc_negative_m_code_error|Negative m code used" + "linuxcnc_negative_s_word_error|Negative spindle speed used" + "linuxcnc_negative_t_word_error|Negative tool id (tool not found)" +) +for case in "${negative_word_error_cases[@]}"; do + fixture=${case%%|*} + expected=${case#*|} + if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" "tests/gcode/$fixture.ngc" \ + >"$output_dir/cnc_sim_linuxcnc_source_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_source_$fixture.err"; then + echo "expected $fixture.ngc to fail" >&2 + exit 1 + fi + grep -q "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" +done +# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc +# the word-specific reader functions reject repeated words while +# filling a single block. +multiple_word_error_cases=( + "linuxcnc_multiple_f_words_error|Multiple f words on one line" + "linuxcnc_multiple_h_words_error|Multiple h words on one line" + "linuxcnc_multiple_l_words_error|Multiple l words on one line" + "linuxcnc_multiple_s_words_error|Multiple s words on one line" + "linuxcnc_multiple_t_words_error|Multiple t words on one line" + "linuxcnc_multiple_x_words_error|Multiple x words on one line" + "linuxcnc_multiple_y_words_error|Multiple y words on one line" + "linuxcnc_multiple_z_words_error|Multiple z words on one line" +) +for case in "${multiple_word_error_cases[@]}"; do + fixture=${case%%|*} + expected=${case#*|} + if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" "tests/gcode/$fixture.ngc" \ + >"$output_dir/cnc_sim_linuxcnc_source_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_source_$fixture.err"; then + echo "expected $fixture.ngc to fail" >&2 + exit 1 + fi + grep -q "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" +done CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_value_returned.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_value_returned.json" diff --git a/tests/gcode/linuxcnc_multiple_f_words_error.ngc b/tests/gcode/linuxcnc_multiple_f_words_error.ngc new file mode 100644 index 0000000..2474ea8 --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_f_words_error.ngc @@ -0,0 +1 @@ +F1 F2 diff --git a/tests/gcode/linuxcnc_multiple_h_words_error.ngc b/tests/gcode/linuxcnc_multiple_h_words_error.ngc new file mode 100644 index 0000000..52b823f --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_h_words_error.ngc @@ -0,0 +1 @@ +H1 H2 diff --git a/tests/gcode/linuxcnc_multiple_l_words_error.ngc b/tests/gcode/linuxcnc_multiple_l_words_error.ngc new file mode 100644 index 0000000..e030c1b --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_l_words_error.ngc @@ -0,0 +1 @@ +L1 L2 diff --git a/tests/gcode/linuxcnc_multiple_s_words_error.ngc b/tests/gcode/linuxcnc_multiple_s_words_error.ngc new file mode 100644 index 0000000..479ec69 --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_s_words_error.ngc @@ -0,0 +1 @@ +S100 S200 diff --git a/tests/gcode/linuxcnc_multiple_t_words_error.ngc b/tests/gcode/linuxcnc_multiple_t_words_error.ngc new file mode 100644 index 0000000..87d01de --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_t_words_error.ngc @@ -0,0 +1 @@ +T1 T2 diff --git a/tests/gcode/linuxcnc_multiple_x_words_error.ngc b/tests/gcode/linuxcnc_multiple_x_words_error.ngc new file mode 100644 index 0000000..66a8455 --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_x_words_error.ngc @@ -0,0 +1 @@ +G1 X1 X2 F100 diff --git a/tests/gcode/linuxcnc_multiple_y_words_error.ngc b/tests/gcode/linuxcnc_multiple_y_words_error.ngc new file mode 100644 index 0000000..e4f7204 --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_y_words_error.ngc @@ -0,0 +1 @@ +G1 Y1 Y2 F100 diff --git a/tests/gcode/linuxcnc_multiple_z_words_error.ngc b/tests/gcode/linuxcnc_multiple_z_words_error.ngc new file mode 100644 index 0000000..b9a99b4 --- /dev/null +++ b/tests/gcode/linuxcnc_multiple_z_words_error.ngc @@ -0,0 +1 @@ +G1 Z1 Z2 F100 diff --git a/tests/gcode/linuxcnc_negative_f_word_error.ngc b/tests/gcode/linuxcnc_negative_f_word_error.ngc new file mode 100644 index 0000000..0bed61a --- /dev/null +++ b/tests/gcode/linuxcnc_negative_f_word_error.ngc @@ -0,0 +1 @@ +F-1 diff --git a/tests/gcode/linuxcnc_negative_g_code_error.ngc b/tests/gcode/linuxcnc_negative_g_code_error.ngc new file mode 100644 index 0000000..013f83c --- /dev/null +++ b/tests/gcode/linuxcnc_negative_g_code_error.ngc @@ -0,0 +1 @@ +G-1 diff --git a/tests/gcode/linuxcnc_negative_h_word_error.ngc b/tests/gcode/linuxcnc_negative_h_word_error.ngc new file mode 100644 index 0000000..a8d2581 --- /dev/null +++ b/tests/gcode/linuxcnc_negative_h_word_error.ngc @@ -0,0 +1 @@ +H-2 diff --git a/tests/gcode/linuxcnc_negative_l_word_error.ngc b/tests/gcode/linuxcnc_negative_l_word_error.ngc new file mode 100644 index 0000000..78cc41e --- /dev/null +++ b/tests/gcode/linuxcnc_negative_l_word_error.ngc @@ -0,0 +1 @@ +L-1 diff --git a/tests/gcode/linuxcnc_negative_m_code_error.ngc b/tests/gcode/linuxcnc_negative_m_code_error.ngc new file mode 100644 index 0000000..23a2982 --- /dev/null +++ b/tests/gcode/linuxcnc_negative_m_code_error.ngc @@ -0,0 +1 @@ +M-1 diff --git a/tests/gcode/linuxcnc_negative_s_word_error.ngc b/tests/gcode/linuxcnc_negative_s_word_error.ngc new file mode 100644 index 0000000..4767781 --- /dev/null +++ b/tests/gcode/linuxcnc_negative_s_word_error.ngc @@ -0,0 +1 @@ +S-1 diff --git a/tests/gcode/linuxcnc_negative_t_word_error.ngc b/tests/gcode/linuxcnc_negative_t_word_error.ngc new file mode 100644 index 0000000..4044d9c --- /dev/null +++ b/tests/gcode/linuxcnc_negative_t_word_error.ngc @@ -0,0 +1 @@ +T-1