继续按 align-linuxcnc 约束:补 G 代码校验错误源码覆盖,测试通过

This commit is contained in:
cnc
2026-06-02 22:34:52 +08:00
parent 138fe862ae
commit 777d29651c
10 changed files with 50 additions and 0 deletions

View File

@@ -641,6 +641,30 @@ for case in "${enhance_block_error_cases[@]}"; do
fi
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err"
done
# Source basis: LinuxCNC src/emc/rs274ngc/interp_check.cc
# check_g_codes() rejects invalid modal-0 combinations for G4, G10, and G53
# before convert_g() executes motion or coordinate updates.
check_g_code_error_cases=(
"linuxcnc_g4_missing_p_error|Dwell time missing with g4"
"linuxcnc_g4_arc_p_conflict_error|G4 not allowed with G2 or G3 because they both use P"
"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_l1_p_out_of_range_error|P value out of range with G10 L1"
"linuxcnc_g53_arc_error|Must use g0 or g1 with g53"
"linuxcnc_g53_incremental_error|Cannot use g53 incremental"
)
for case in "${check_g_code_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"