继续按 align-linuxcnc 约束:补 G 代码校验错误源码覆盖,测试通过
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -153,6 +153,8 @@ grep -F 'tests/gcode/linuxcnc_polar_coordinates.ngc' test-linuxcnc-source-link.s
|
||||
grep -F 'tests/gcode/linuxcnc_polar_coordinate_variants.ngc' test-linuxcnc-source-link.sh >/dev/null
|
||||
grep -F 'enhance_block() assigns motion_to_be' test-linuxcnc-source-link.sh >/dev/null
|
||||
grep -F 'linuxcnc_g80_axis_error|Cannot use axis values with g80' test-linuxcnc-source-link.sh >/dev/null
|
||||
grep -F 'check_g_codes() rejects invalid modal-0 combinations' test-linuxcnc-source-link.sh >/dev/null
|
||||
grep -F 'linuxcnc_g53_incremental_error|Cannot use g53 incremental' test-linuxcnc-source-link.sh >/dev/null
|
||||
grep -F 'lookup_named_param()' test-linuxcnc-rs274-native.sh >/dev/null
|
||||
grep -F 'tests/gcode/linuxcnc_readonly_named_parameters.ngc' docs/linuxcnc-porting.md >/dev/null
|
||||
grep -F 'rs274ngc_pre.cc ini_load() consumes INI_FILE_NAME' test-web-wasm-node-smoke.cjs >/dev/null
|
||||
|
||||
3
tests/gcode/linuxcnc_g10_invalid_l_error.ngc
Normal file
3
tests/gcode/linuxcnc_g10_invalid_l_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G90 G17
|
||||
G10 L3 P1 X1
|
||||
M30
|
||||
3
tests/gcode/linuxcnc_g10_l1_p_out_of_range_error.ngc
Normal file
3
tests/gcode/linuxcnc_g10_l1_p_out_of_range_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G90 G17
|
||||
G10 L1 P0 X1
|
||||
M30
|
||||
3
tests/gcode/linuxcnc_g10_l2_p_out_of_range_error.ngc
Normal file
3
tests/gcode/linuxcnc_g10_l2_p_out_of_range_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G90 G17
|
||||
G10 L2 P10 X1
|
||||
M30
|
||||
3
tests/gcode/linuxcnc_g10_p_non_integer_error.ngc
Normal file
3
tests/gcode/linuxcnc_g10_p_non_integer_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G90 G17
|
||||
G10 L2 P1.2 X1
|
||||
M30
|
||||
3
tests/gcode/linuxcnc_g4_arc_p_conflict_error.ngc
Normal file
3
tests/gcode/linuxcnc_g4_arc_p_conflict_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G90 G17
|
||||
G2 G4 X1 Y0 I0 J1 P1
|
||||
M30
|
||||
3
tests/gcode/linuxcnc_g4_missing_p_error.ngc
Normal file
3
tests/gcode/linuxcnc_g4_missing_p_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G90 G17
|
||||
G4
|
||||
M30
|
||||
3
tests/gcode/linuxcnc_g53_arc_error.ngc
Normal file
3
tests/gcode/linuxcnc_g53_arc_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G90 G17
|
||||
G53 G2 X1 Y0 I0 J1
|
||||
M30
|
||||
3
tests/gcode/linuxcnc_g53_incremental_error.ngc
Normal file
3
tests/gcode/linuxcnc_g53_incremental_error.ngc
Normal file
@@ -0,0 +1,3 @@
|
||||
G21 G91 G17
|
||||
G53 G0 X1
|
||||
M30
|
||||
Reference in New Issue
Block a user