diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 8d9785a..e296985 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -576,6 +576,29 @@ for case in "${polar_coordinate_error_cases[@]}"; do fi grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" done +# Source basis: LinuxCNC src/emc/rs274ngc/interp_internal.cc +# enhance_block() assigns motion_to_be and rejects invalid axis use with G80, +# missing axes for G52/G92 or motion codes, bare axis words without active +# motion, and modal-0 G codes that consume axis values on a motion block. +enhance_block_error_cases=( + "linuxcnc_g80_axis_error|Cannot use axis values with g80" + "linuxcnc_g52_missing_axis_error|All axes missing with g52 or g92" + "linuxcnc_g92_missing_axis_error|All axes missing with g52 or g92" + "linuxcnc_motion_missing_axis_error|All axes missing with motion code" + "linuxcnc_axis_without_motion_error|Cannot use axis values without a g code that uses them" + "linuxcnc_motion_with_g92_axis_error|Cannot use two g codes that both use axis values" +) +for case in "${enhance_block_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 1096b8c..cbaf2c6 100755 --- a/test-native.sh +++ b/test-native.sh @@ -147,6 +147,8 @@ grep -F 'tests/gcode/linuxcnc_lathe_diameter_g76.ngc' docs/linuxcnc-porting.md > grep -F 'missing source-linked G7 diameter-mode G76 final threading pass' 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 '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 '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_axis_without_motion_error.ngc b/tests/gcode/linuxcnc_axis_without_motion_error.ngc new file mode 100644 index 0000000..f36fdd8 --- /dev/null +++ b/tests/gcode/linuxcnc_axis_without_motion_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +X1 +M30 diff --git a/tests/gcode/linuxcnc_g52_missing_axis_error.ngc b/tests/gcode/linuxcnc_g52_missing_axis_error.ngc new file mode 100644 index 0000000..0b40266 --- /dev/null +++ b/tests/gcode/linuxcnc_g52_missing_axis_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G52 +M30 diff --git a/tests/gcode/linuxcnc_g80_axis_error.ngc b/tests/gcode/linuxcnc_g80_axis_error.ngc new file mode 100644 index 0000000..4b622d5 --- /dev/null +++ b/tests/gcode/linuxcnc_g80_axis_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G80 X1 +M30 diff --git a/tests/gcode/linuxcnc_g92_missing_axis_error.ngc b/tests/gcode/linuxcnc_g92_missing_axis_error.ngc new file mode 100644 index 0000000..0f30a1d --- /dev/null +++ b/tests/gcode/linuxcnc_g92_missing_axis_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G92 +M30 diff --git a/tests/gcode/linuxcnc_motion_missing_axis_error.ngc b/tests/gcode/linuxcnc_motion_missing_axis_error.ngc new file mode 100644 index 0000000..99f3bcb --- /dev/null +++ b/tests/gcode/linuxcnc_motion_missing_axis_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G81 F100 +M30 diff --git a/tests/gcode/linuxcnc_motion_with_g92_axis_error.ngc b/tests/gcode/linuxcnc_motion_with_g92_axis_error.ngc new file mode 100644 index 0000000..82f3dd5 --- /dev/null +++ b/tests/gcode/linuxcnc_motion_with_g92_axis_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +G1 G92 X1 F100 +M30