继续按 align-linuxcnc 约束:补 O-word 读取错误源码覆盖

结论:新增 malformed O-word、缺少控制表达式括号、O-call 参数过多和 M98 缺 P 的 source-link 断言;依据 LinuxCNC interp_read.cc,未扩展 smoke。
This commit is contained in:
cnc
2026-06-02 17:35:18 +08:00
parent 9a9b931982
commit a44199eb48
10 changed files with 33 additions and 1 deletions

View File

@@ -869,6 +869,30 @@ if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
echo "expected linuxcnc_numeric_oword_sub_illegal_location.ngc to fail" >&2
exit 1
fi
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_o()
# and read_items() reject malformed O-word control lines and Fanuc-style
# M98 calls before execution.
oword_reader_error_cases=(
"linuxcnc_oword_unknown_command_error|Unknown control command in o word"
"linuxcnc_oword_unexpected_trailing_item_error|Unexpected character after O-word"
"linuxcnc_oword_if_missing_bracket_error|Left bracket missing after 'if'"
"linuxcnc_oword_elseif_missing_bracket_error|Left bracket missing after 'elseif'"
"linuxcnc_oword_while_missing_bracket_error|Left bracket missing after 'while'"
"linuxcnc_oword_repeat_missing_bracket_error|Left bracket missing after 'repeat'"
"linuxcnc_oword_too_many_call_parameters_error|Too many subroutine parameters"
"linuxcnc_m98_missing_p_word_error|Found 'm98' code with no P-word"
)
for case in "${oword_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
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_reject_rotary_followup.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_reject_rotary_followup.json" 2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_reject_rotary_followup.err"; then