继续按 align-linuxcnc 约束:补 G/M reader 源码错误覆盖

结论:覆盖 LinuxCNC interp_read.cc/read_g()/read_m() 的范围、未知代码和同 modal group 冲突错误,代码表依据 interp_array.cc;未扩展 smoke。

验证:./test-linuxcnc-source-link.sh;./test-native.sh。
This commit is contained in:
cnc
2026-06-02 16:35:58 +08:00
parent 6ffcada028
commit b83bc47c45
8 changed files with 29 additions and 0 deletions

View File

@@ -710,6 +710,28 @@ for case in "${negative_word_error_cases[@]}"; do
grep -q "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err"
done
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc
# read_g()/read_m() validate numeric range, known code tables from
# interp_array.cc, and same-modal-group conflicts while filling a block.
gm_reader_error_cases=(
"linuxcnc_g_code_out_of_range_error|G-code out of range"
"linuxcnc_unknown_g_code_error|Unknown g code used"
"linuxcnc_two_g_codes_same_modal_group_error|Two g codes used from same modal group"
"linuxcnc_m_code_greater_199_error|M-code greater than 199: M200"
"linuxcnc_unknown_m_code_error|Unknown m code used: M13"
"linuxcnc_two_m_codes_same_modal_group_error|Two m codes used from same modal group"
)
for case in "${gm_reader_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=(