diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index f7709a7..9b52da6 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -641,6 +641,30 @@ for case in "${enhance_block_error_cases[@]}"; do fi grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" done +# Source basis: LinuxCNC src/emc/rs274ngc/interp_check.cc +# check_g_codes() rejects invalid modal-0 combinations for G4, G10, and G53 +# before convert_g() executes motion or coordinate updates. +check_g_code_error_cases=( + "linuxcnc_g4_missing_p_error|Dwell time missing with g4" + "linuxcnc_g4_arc_p_conflict_error|G4 not allowed with G2 or G3 because they both use P" + "linuxcnc_g10_invalid_l_error|Line with G10 does not have L0, L1, L10, L11, L2, or L20" + "linuxcnc_g10_p_non_integer_error|P value not an integer with G10" + "linuxcnc_g10_l2_p_out_of_range_error|P value out of range (0-9) with G10 L2" + "linuxcnc_g10_l1_p_out_of_range_error|P value out of range with G10 L1" + "linuxcnc_g53_arc_error|Must use g0 or g1 with g53" + "linuxcnc_g53_incremental_error|Cannot use g53 incremental" +) +for case in "${check_g_code_error_cases[@]}"; do + fixture=${case%%|*} + expected=${case#*|} + if 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 -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" +done CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_predefined_positions.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_predefined_positions.json" diff --git a/test-native.sh b/test-native.sh index f63bb8f..9b89e49 100755 --- a/test-native.sh +++ b/test-native.sh @@ -153,6 +153,8 @@ grep -F 'tests/gcode/linuxcnc_polar_coordinates.ngc' test-linuxcnc-source-link.s grep -F 'tests/gcode/linuxcnc_polar_coordinate_variants.ngc' test-linuxcnc-source-link.sh >/dev/null grep -F 'enhance_block() assigns motion_to_be' test-linuxcnc-source-link.sh >/dev/null grep -F 'linuxcnc_g80_axis_error|Cannot use axis values with g80' test-linuxcnc-source-link.sh >/dev/null +grep -F 'check_g_codes() rejects invalid modal-0 combinations' test-linuxcnc-source-link.sh >/dev/null +grep -F 'linuxcnc_g53_incremental_error|Cannot use g53 incremental' test-linuxcnc-source-link.sh >/dev/null grep -F 'lookup_named_param()' test-linuxcnc-rs274-native.sh >/dev/null grep -F 'tests/gcode/linuxcnc_readonly_named_parameters.ngc' docs/linuxcnc-porting.md >/dev/null grep -F 'rs274ngc_pre.cc ini_load() consumes INI_FILE_NAME' test-web-wasm-node-smoke.cjs >/dev/null diff --git a/tests/gcode/linuxcnc_g10_invalid_l_error.ngc b/tests/gcode/linuxcnc_g10_invalid_l_error.ngc new file mode 100644 index 0000000..de4e2a4 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_invalid_l_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G10 L3 P1 X1 +M30 diff --git a/tests/gcode/linuxcnc_g10_l1_p_out_of_range_error.ngc b/tests/gcode/linuxcnc_g10_l1_p_out_of_range_error.ngc new file mode 100644 index 0000000..2762284 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l1_p_out_of_range_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G10 L1 P0 X1 +M30 diff --git a/tests/gcode/linuxcnc_g10_l2_p_out_of_range_error.ngc b/tests/gcode/linuxcnc_g10_l2_p_out_of_range_error.ngc new file mode 100644 index 0000000..8610be3 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l2_p_out_of_range_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G10 L2 P10 X1 +M30 diff --git a/tests/gcode/linuxcnc_g10_p_non_integer_error.ngc b/tests/gcode/linuxcnc_g10_p_non_integer_error.ngc new file mode 100644 index 0000000..1250ac2 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_p_non_integer_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G10 L2 P1.2 X1 +M30 diff --git a/tests/gcode/linuxcnc_g4_arc_p_conflict_error.ngc b/tests/gcode/linuxcnc_g4_arc_p_conflict_error.ngc new file mode 100644 index 0000000..ad5b3d9 --- /dev/null +++ b/tests/gcode/linuxcnc_g4_arc_p_conflict_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G2 G4 X1 Y0 I0 J1 P1 +M30 diff --git a/tests/gcode/linuxcnc_g4_missing_p_error.ngc b/tests/gcode/linuxcnc_g4_missing_p_error.ngc new file mode 100644 index 0000000..c0332e6 --- /dev/null +++ b/tests/gcode/linuxcnc_g4_missing_p_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G4 +M30 diff --git a/tests/gcode/linuxcnc_g53_arc_error.ngc b/tests/gcode/linuxcnc_g53_arc_error.ngc new file mode 100644 index 0000000..e1edfd1 --- /dev/null +++ b/tests/gcode/linuxcnc_g53_arc_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G53 G2 X1 Y0 I0 J1 +M30 diff --git a/tests/gcode/linuxcnc_g53_incremental_error.ngc b/tests/gcode/linuxcnc_g53_incremental_error.ngc new file mode 100644 index 0000000..b4f0651 --- /dev/null +++ b/tests/gcode/linuxcnc_g53_incremental_error.ngc @@ -0,0 +1,3 @@ +G21 G91 G17 +G53 G0 X1 +M30