From 84fdc8a1c587b44b003d8c94943c7426592ec71c Mon Sep 17 00:00:00 2001 From: cnc Date: Tue, 2 Jun 2026 22:15:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E6=8C=89=20align-linuxcnc=20?= =?UTF-8?q?=E7=BA=A6=E6=9D=9F=EF=BC=9A=E8=A1=A5=E5=A2=9E=E5=BC=BA=E5=9D=97?= =?UTF-8?q?=E8=BD=B4=E5=80=BC=E9=94=99=E8=AF=AF=E6=BA=90=E7=A0=81=E8=A6=86?= =?UTF-8?q?=E7=9B=96=EF=BC=8C=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test-linuxcnc-source-link.sh | 23 +++++++++++++++++++ test-native.sh | 2 ++ .../linuxcnc_axis_without_motion_error.ngc | 3 +++ .../gcode/linuxcnc_g52_missing_axis_error.ngc | 3 +++ tests/gcode/linuxcnc_g80_axis_error.ngc | 3 +++ .../gcode/linuxcnc_g92_missing_axis_error.ngc | 3 +++ .../linuxcnc_motion_missing_axis_error.ngc | 3 +++ .../linuxcnc_motion_with_g92_axis_error.ngc | 3 +++ 8 files changed, 43 insertions(+) create mode 100644 tests/gcode/linuxcnc_axis_without_motion_error.ngc create mode 100644 tests/gcode/linuxcnc_g52_missing_axis_error.ngc create mode 100644 tests/gcode/linuxcnc_g80_axis_error.ngc create mode 100644 tests/gcode/linuxcnc_g92_missing_axis_error.ngc create mode 100644 tests/gcode/linuxcnc_motion_missing_axis_error.ngc create mode 100644 tests/gcode/linuxcnc_motion_with_g92_axis_error.ngc 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