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

结论:新增重复/未匹配 O-word label 和 out-of-context return/endsub 的 source-link 断言;依据 LinuxCNC interp_o_word.cc,未扩展 smoke。
This commit is contained in:
cnc
2026-06-02 17:55:14 +08:00
parent 25519b5bc4
commit cc708b1ccc
8 changed files with 33 additions and 1 deletions

View File

@@ -893,6 +893,28 @@ for case in "${oword_reader_error_cases[@]}"; do
fi
grep -q "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err"
done
# Source basis: LinuxCNC src/emc/rs274ngc/interp_o_word.cc
# convert_control_functions() rejects unmatched, duplicate, and
# out-of-context O-word control labels during execution.
oword_execution_error_cases=(
"linuxcnc_oword_endsub_without_sub_error|not in a subroutine definition"
"linuxcnc_oword_return_without_sub_error|not in a subroutine definition"
"linuxcnc_oword_duplicate_if_label_error|duplicate O-word label"
"linuxcnc_oword_elseif_undefined_label_error|undefined O-word label"
"linuxcnc_oword_break_undefined_label_error|undefined O-word label"
"linuxcnc_oword_endrepeat_no_matching_repeat_error|no matching label"
)
for case in "${oword_execution_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 read_text()
# rejects EOF without the matching percent/program end and overlong file
# lines; read_n_number() rejects malformed N-line numbers through