diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 7e3c139..911274b 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -289,6 +289,27 @@ CNC_SIM_RS274_VAR="$var_file" \ CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_dynamic_tool_length.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_dynamic_tool_length.json" +# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc +# convert_tool_length_offset() rejects invalid G43.2 H/axis combinations, +# and src/emc/rs274ngc/interp_find.cc find_tool_index() rejects H tool +# numbers missing from the LinuxCNC tooldata table. +tool_length_offset_error_cases=( + "linuxcnc_g43_missing_tool_error|Requested tool 99 not found in the tool table" + "linuxcnc_g43_2_missing_tool_error|Requested tool 99 not found in the tool table" + "linuxcnc_g43_2_h_axis_error|G43.2: Can not have both H and axis words" + "linuxcnc_g43_2_missing_h_axis_error|G43.2: No axes specified and H word missing" +) +for case in "${tool_length_offset_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_canned_cycle.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_canned_cycle.json" diff --git a/test-native.sh b/test-native.sh index 12b4dc5..506187a 100755 --- a/test-native.sh +++ b/test-native.sh @@ -145,6 +145,8 @@ grep -F 'convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K words' grep -F 'tests/gcode/linuxcnc_lathe_diameter_mode.ngc' docs/linuxcnc-porting.md >/dev/null grep -F 'tests/gcode/linuxcnc_lathe_diameter_g76.ngc' docs/linuxcnc-porting.md >/dev/null grep -F 'missing source-linked G7 diameter-mode G76 final threading pass' test-linuxcnc-source-link.sh >/dev/null +grep -F 'convert_tool_length_offset() rejects invalid G43.2 H/axis combinations' test-linuxcnc-source-link.sh >/dev/null +grep -F 'linuxcnc_g43_2_missing_h_axis_error|G43.2: No axes specified and H word missing' test-linuxcnc-source-link.sh >/dev/null grep -F 'read_atsign()' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_polar_coordinates.ngc' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_polar_coordinate_variants.ngc' test-linuxcnc-source-link.sh >/dev/null diff --git a/tests/gcode/linuxcnc_g43_2_h_axis_error.ngc b/tests/gcode/linuxcnc_g43_2_h_axis_error.ngc new file mode 100644 index 0000000..b07e0a2 --- /dev/null +++ b/tests/gcode/linuxcnc_g43_2_h_axis_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G43.2 H1 X1 +M30 diff --git a/tests/gcode/linuxcnc_g43_2_missing_h_axis_error.ngc b/tests/gcode/linuxcnc_g43_2_missing_h_axis_error.ngc new file mode 100644 index 0000000..8f2e1e3 --- /dev/null +++ b/tests/gcode/linuxcnc_g43_2_missing_h_axis_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G43.2 +M30 diff --git a/tests/gcode/linuxcnc_g43_2_missing_tool_error.ngc b/tests/gcode/linuxcnc_g43_2_missing_tool_error.ngc new file mode 100644 index 0000000..a6b48da --- /dev/null +++ b/tests/gcode/linuxcnc_g43_2_missing_tool_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G43.2 H99 +M30 diff --git a/tests/gcode/linuxcnc_g43_missing_tool_error.ngc b/tests/gcode/linuxcnc_g43_missing_tool_error.ngc new file mode 100644 index 0000000..e3f7c72 --- /dev/null +++ b/tests/gcode/linuxcnc_g43_missing_tool_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G43 H99 +M30