参考所有分组:补 G10 source 覆盖,测试通过

This commit is contained in:
cnc
2026-06-03 09:32:16 +08:00
parent bbd5739e7a
commit a134dcef7d
11 changed files with 68 additions and 0 deletions

View File

@@ -661,7 +661,12 @@ check_g_code_error_cases=(
"linuxcnc_g10_invalid_l_error|Line with G10 does not have L0, L1, L10, L11, L2, or L20"
"linuxcnc_g10_p_non_integer_error|P value not an integer with G10"
"linuxcnc_g10_l2_p_out_of_range_error|P value out of range (0-9) with G10 L2"
"linuxcnc_g10_l2_p_missing_error|P value out of range (0-9) with G10 L2"
"linuxcnc_g10_l20_p_out_of_range_error|P value out of range (0-9) with G10 L20"
"linuxcnc_g10_l20_p_missing_error|P value out of range (0-9) with G10 L20"
"linuxcnc_g10_l1_p_out_of_range_error|P value out of range with G10 L1"
"linuxcnc_g10_l10_p_out_of_range_error|P value out of range with G10 L10"
"linuxcnc_g10_l11_p_out_of_range_error|P value out of range with G10 L11"
"linuxcnc_g53_arc_error|Must use g0 or g1 with g53"
"linuxcnc_g53_incremental_error|Cannot use g53 incremental"
)
@@ -676,6 +681,26 @@ for case in "${check_g_code_error_cases[@]}"; do
fi
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err"
done
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_setup() rejects disallowed G10 L2/L20 words, and
# convert_tool_table() rejects G10 L1 table updates without offsets.
g10_convert_error_cases=(
"linuxcnc_g10_l1_without_offsets_error|G10 L1 without offsets has no effect"
"linuxcnc_g10_l2_i_word_error|I J words not allowed with G10 L2"
"linuxcnc_g10_l20_i_word_error|I J words not allowed with G10 L2"
"linuxcnc_g10_l20_r_word_error|R not allowed in G10 L20"
)
for case in "${g10_convert_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"