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

结论:覆盖 LinuxCNC interp_read.cc 中负数 F/G/H/L/M/S/T 和重复 F/H/L/S/T/X/Y/Z word reader 错误;未扩展 smoke。

验证:./test-linuxcnc-source-link.sh;./test-native.sh。
This commit is contained in:
cnc
2026-06-02 16:17:19 +08:00
parent b4d0bfae46
commit 05ece027c4
17 changed files with 63 additions and 0 deletions

View File

@@ -654,6 +654,53 @@ for case in "${binary_operation_error_cases[@]}"; do
fi
grep -q "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err"
done
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc
# read_f()/read_g()/read_h()/read_l()/read_m()/read_s()/read_t()
# reject negative word values before command execution.
negative_word_error_cases=(
"linuxcnc_negative_f_word_error|Negative f word used"
"linuxcnc_negative_g_code_error|Negative g code used"
"linuxcnc_negative_h_word_error|Negative h word used"
"linuxcnc_negative_l_word_error|Negative l word used"
"linuxcnc_negative_m_code_error|Negative m code used"
"linuxcnc_negative_s_word_error|Negative spindle speed used"
"linuxcnc_negative_t_word_error|Negative tool id (tool not found)"
)
for case in "${negative_word_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=(
"linuxcnc_multiple_f_words_error|Multiple f words on one line"
"linuxcnc_multiple_h_words_error|Multiple h words on one line"
"linuxcnc_multiple_l_words_error|Multiple l words on one line"
"linuxcnc_multiple_s_words_error|Multiple s words on one line"
"linuxcnc_multiple_t_words_error|Multiple t words on one line"
"linuxcnc_multiple_x_words_error|Multiple x words on one line"
"linuxcnc_multiple_y_words_error|Multiple y words on one line"
"linuxcnc_multiple_z_words_error|Multiple z words on one line"
)
for case in "${multiple_word_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
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_value_returned.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_value_returned.json"