继续按 align-linuxcnc 约束:补未使用字地址源码覆盖,测试通过

This commit is contained in:
cnc
2026-06-02 19:53:28 +08:00
parent 4d0cf788b1
commit 3a60624108
13 changed files with 61 additions and 1 deletions

View File

@@ -215,6 +215,6 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu
| Parameter expressions and operators | covered for parameter references, source-linked `mod`, `**`, logical, and relational operator precedence, plus LinuxCNC parameter-setting syntax, parameter index validation, named-parameter termination, real-number parsing, divide-by-zero, negative sqrt/power, infinity rejection, malformed and bare `ATAN[]/[]`, unary operation syntax including bare unary items, `read_operation_unary()` unknown-word branches, `read_operation()` binary-operation prefix, unknown operation, and unclosed-expression error paths from `interp_read.cc`/`interp_execute.cc` | `tests/gcode/linuxcnc_parameter_expression_assignment.ngc`, `tests/gcode/linuxcnc_parameter_missing_equal_error.ngc`, `tests/gcode/linuxcnc_midline_parameter_missing_equal_error.ngc`, `tests/gcode/linuxcnc_parameter_missing_value_error.ngc`, `tests/gcode/linuxcnc_parameter_number_out_of_range_error.ngc`, `tests/gcode/linuxcnc_parameter_reference_out_of_range_error.ngc`, `tests/gcode/linuxcnc_non_integer_parameter_index_error.ngc`, `tests/gcode/linuxcnc_named_parameter_not_terminated_error.ngc`, `tests/gcode/linuxcnc_no_real_value_error.ngc`, `tests/gcode/linuxcnc_bad_number_format_error.ngc`, `tests/gcode/linuxcnc_expression_operators.ngc`, `tests/gcode/linuxcnc_negative_sqrt_error.ngc`, `tests/gcode/linuxcnc_divide_by_zero_error.ngc`, `tests/gcode/linuxcnc_negative_power_error.ngc`, `tests/gcode/linuxcnc_infinite_expression_error.ngc`, `tests/gcode/linuxcnc_atan_missing_slash_error.ngc`, `tests/gcode/linuxcnc_atan_missing_bracket_error.ngc`, `tests/gcode/linuxcnc_top_level_bare_atan_error.ngc`, `tests/gcode/linuxcnc_midline_bare_atan_error.ngc`, `tests/gcode/linuxcnc_unary_missing_bracket_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_c_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_e_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_f_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_l_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_r_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_s_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_t_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_default_word_error.ngc`, `tests/gcode/linuxcnc_top_level_bare_unary_error.ngc`, `tests/gcode/linuxcnc_midline_bare_unary_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_a_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_e_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_g_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_l_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_m_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_n_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_o_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_x_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_operation_error.ngc`, `tests/gcode/linuxcnc_unclosed_expression_error.ngc` | | Parameter expressions and operators | covered for parameter references, source-linked `mod`, `**`, logical, and relational operator precedence, plus LinuxCNC parameter-setting syntax, parameter index validation, named-parameter termination, real-number parsing, divide-by-zero, negative sqrt/power, infinity rejection, malformed and bare `ATAN[]/[]`, unary operation syntax including bare unary items, `read_operation_unary()` unknown-word branches, `read_operation()` binary-operation prefix, unknown operation, and unclosed-expression error paths from `interp_read.cc`/`interp_execute.cc` | `tests/gcode/linuxcnc_parameter_expression_assignment.ngc`, `tests/gcode/linuxcnc_parameter_missing_equal_error.ngc`, `tests/gcode/linuxcnc_midline_parameter_missing_equal_error.ngc`, `tests/gcode/linuxcnc_parameter_missing_value_error.ngc`, `tests/gcode/linuxcnc_parameter_number_out_of_range_error.ngc`, `tests/gcode/linuxcnc_parameter_reference_out_of_range_error.ngc`, `tests/gcode/linuxcnc_non_integer_parameter_index_error.ngc`, `tests/gcode/linuxcnc_named_parameter_not_terminated_error.ngc`, `tests/gcode/linuxcnc_no_real_value_error.ngc`, `tests/gcode/linuxcnc_bad_number_format_error.ngc`, `tests/gcode/linuxcnc_expression_operators.ngc`, `tests/gcode/linuxcnc_negative_sqrt_error.ngc`, `tests/gcode/linuxcnc_divide_by_zero_error.ngc`, `tests/gcode/linuxcnc_negative_power_error.ngc`, `tests/gcode/linuxcnc_infinite_expression_error.ngc`, `tests/gcode/linuxcnc_atan_missing_slash_error.ngc`, `tests/gcode/linuxcnc_atan_missing_bracket_error.ngc`, `tests/gcode/linuxcnc_top_level_bare_atan_error.ngc`, `tests/gcode/linuxcnc_midline_bare_atan_error.ngc`, `tests/gcode/linuxcnc_unary_missing_bracket_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_c_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_e_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_f_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_l_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_r_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_s_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_t_word_error.ngc`, `tests/gcode/linuxcnc_unary_unknown_default_word_error.ngc`, `tests/gcode/linuxcnc_top_level_bare_unary_error.ngc`, `tests/gcode/linuxcnc_midline_bare_unary_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_a_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_e_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_g_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_l_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_m_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_n_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_o_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_x_operation_error.ngc`, `tests/gcode/linuxcnc_binary_unknown_operation_error.ngc`, `tests/gcode/linuxcnc_unclosed_expression_error.ngc` |
| Word reader validation | source-linked LinuxCNC reader errors covered for negative `F/G/H/L/M/S/T` values and repeated `A/B/C/D/E/F/H/I/J/K/L/P/Q/R/S/T/U/V/W/X/Y/Z` words from `interp_read.cc` | `tests/gcode/linuxcnc_negative_f_word_error.ngc`, `tests/gcode/linuxcnc_negative_g_code_error.ngc`, `tests/gcode/linuxcnc_negative_h_word_error.ngc`, `tests/gcode/linuxcnc_negative_l_word_error.ngc`, `tests/gcode/linuxcnc_negative_m_code_error.ngc`, `tests/gcode/linuxcnc_negative_s_word_error.ngc`, `tests/gcode/linuxcnc_negative_t_word_error.ngc`, `tests/gcode/linuxcnc_multiple_a_words_error.ngc`, `tests/gcode/linuxcnc_multiple_b_words_error.ngc`, `tests/gcode/linuxcnc_multiple_c_words_error.ngc`, `tests/gcode/linuxcnc_multiple_d_words_error.ngc`, `tests/gcode/linuxcnc_multiple_e_words_error.ngc`, `tests/gcode/linuxcnc_multiple_f_words_error.ngc`, `tests/gcode/linuxcnc_multiple_h_words_error.ngc`, `tests/gcode/linuxcnc_multiple_i_words_error.ngc`, `tests/gcode/linuxcnc_multiple_j_words_error.ngc`, `tests/gcode/linuxcnc_multiple_k_words_error.ngc`, `tests/gcode/linuxcnc_multiple_l_words_error.ngc`, `tests/gcode/linuxcnc_multiple_p_words_error.ngc`, `tests/gcode/linuxcnc_multiple_q_words_error.ngc`, `tests/gcode/linuxcnc_multiple_r_words_error.ngc`, `tests/gcode/linuxcnc_multiple_s_words_error.ngc`, `tests/gcode/linuxcnc_multiple_t_words_error.ngc`, `tests/gcode/linuxcnc_multiple_u_words_error.ngc`, `tests/gcode/linuxcnc_multiple_v_words_error.ngc`, `tests/gcode/linuxcnc_multiple_w_words_error.ngc`, `tests/gcode/linuxcnc_multiple_x_words_error.ngc`, `tests/gcode/linuxcnc_multiple_y_words_error.ngc`, `tests/gcode/linuxcnc_multiple_z_words_error.ngc` | | Word reader validation | source-linked LinuxCNC reader errors covered for negative `F/G/H/L/M/S/T` values and repeated `A/B/C/D/E/F/H/I/J/K/L/P/Q/R/S/T/U/V/W/X/Y/Z` words from `interp_read.cc` | `tests/gcode/linuxcnc_negative_f_word_error.ngc`, `tests/gcode/linuxcnc_negative_g_code_error.ngc`, `tests/gcode/linuxcnc_negative_h_word_error.ngc`, `tests/gcode/linuxcnc_negative_l_word_error.ngc`, `tests/gcode/linuxcnc_negative_m_code_error.ngc`, `tests/gcode/linuxcnc_negative_s_word_error.ngc`, `tests/gcode/linuxcnc_negative_t_word_error.ngc`, `tests/gcode/linuxcnc_multiple_a_words_error.ngc`, `tests/gcode/linuxcnc_multiple_b_words_error.ngc`, `tests/gcode/linuxcnc_multiple_c_words_error.ngc`, `tests/gcode/linuxcnc_multiple_d_words_error.ngc`, `tests/gcode/linuxcnc_multiple_e_words_error.ngc`, `tests/gcode/linuxcnc_multiple_f_words_error.ngc`, `tests/gcode/linuxcnc_multiple_h_words_error.ngc`, `tests/gcode/linuxcnc_multiple_i_words_error.ngc`, `tests/gcode/linuxcnc_multiple_j_words_error.ngc`, `tests/gcode/linuxcnc_multiple_k_words_error.ngc`, `tests/gcode/linuxcnc_multiple_l_words_error.ngc`, `tests/gcode/linuxcnc_multiple_p_words_error.ngc`, `tests/gcode/linuxcnc_multiple_q_words_error.ngc`, `tests/gcode/linuxcnc_multiple_r_words_error.ngc`, `tests/gcode/linuxcnc_multiple_s_words_error.ngc`, `tests/gcode/linuxcnc_multiple_t_words_error.ngc`, `tests/gcode/linuxcnc_multiple_u_words_error.ngc`, `tests/gcode/linuxcnc_multiple_v_words_error.ngc`, `tests/gcode/linuxcnc_multiple_w_words_error.ngc`, `tests/gcode/linuxcnc_multiple_x_words_error.ngc`, `tests/gcode/linuxcnc_multiple_y_words_error.ngc`, `tests/gcode/linuxcnc_multiple_z_words_error.ngc` |
| G/M reader validation | source-linked LinuxCNC `read_g()`/`read_m()` errors covered for range checks, unknown code tables, and same-modal-group conflicts from `interp_read.cc` and `interp_array.cc` | `tests/gcode/linuxcnc_g_code_out_of_range_error.ngc`, `tests/gcode/linuxcnc_unknown_g_code_error.ngc`, `tests/gcode/linuxcnc_two_g_codes_same_modal_group_error.ngc`, `tests/gcode/linuxcnc_m_code_greater_199_error.ngc`, `tests/gcode/linuxcnc_unknown_m_code_error.ngc`, `tests/gcode/linuxcnc_two_m_codes_same_modal_group_error.ngc` | | G/M reader validation | source-linked LinuxCNC `read_g()`/`read_m()` errors covered for range checks, unknown code tables, and same-modal-group conflicts from `interp_read.cc` and `interp_array.cc` | `tests/gcode/linuxcnc_g_code_out_of_range_error.ngc`, `tests/gcode/linuxcnc_unknown_g_code_error.ngc`, `tests/gcode/linuxcnc_two_g_codes_same_modal_group_error.ngc`, `tests/gcode/linuxcnc_m_code_greater_199_error.ngc`, `tests/gcode/linuxcnc_unknown_m_code_error.ngc`, `tests/gcode/linuxcnc_two_m_codes_same_modal_group_error.ngc` |
| Block/item reader validation | source-linked LinuxCNC block reader errors covered for repeated `$`, bad item-start characters, middle-of-line or comment-prefixed `N` words, comment-prefixed or midline `O` words, top-level or midline bracket items, naked top-level numbers, malformed leading `N` numbers, EOF/program-end file checks, overlong file lines, and too many M-codes from `interp_read.cc`, `interp_array.cc`, and `interp_check.cc` | `tests/gcode/linuxcnc_multiple_spindle_choice_words_error.ngc`, `tests/gcode/linuxcnc_bad_character_bang_error.ngc`, `tests/gcode/linuxcnc_bad_character_middle_n_word_error.ngc`, `tests/gcode/linuxcnc_comment_prefixed_n_word_error.ngc`, `tests/gcode/linuxcnc_comment_prefixed_spaced_n_word_error.ngc`, `tests/gcode/linuxcnc_comment_prefixed_oword_error.ngc`, `tests/gcode/linuxcnc_midline_numeric_oword_error.ngc`, `tests/gcode/linuxcnc_midline_named_oword_error.ngc`, `tests/gcode/linuxcnc_bad_character_top_left_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_top_right_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_midline_left_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_midline_right_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_top_number_error.ngc`, `tests/gcode/linuxcnc_bad_n_number_format_error.ngc`, `tests/gcode/linuxcnc_file_ended_no_program_end_error.ngc`, `tests/gcode/linuxcnc_file_ended_no_percent_error.ngc`, generated `linuxcnc_command_too_long_error.ngc`, `tests/gcode/linuxcnc_too_many_m_codes_error.ngc` | | Block/item reader validation | source-linked LinuxCNC block reader errors covered for repeated `$`, unused `D/$/E/H/I/J/K/L/P/Q/R` words, bad item-start characters, middle-of-line or comment-prefixed `N` words, comment-prefixed or midline `O` words, top-level or midline bracket items, naked top-level numbers, malformed leading `N` numbers, EOF/program-end file checks, overlong file lines, and too many M-codes from `interp_read.cc`, `interp_array.cc`, and `interp_check.cc` | `tests/gcode/linuxcnc_multiple_spindle_choice_words_error.ngc`, `tests/gcode/linuxcnc_d_word_no_use_error.ngc`, `tests/gcode/linuxcnc_spindle_dollar_no_use_error.ngc`, `tests/gcode/linuxcnc_e_word_no_use_error.ngc`, `tests/gcode/linuxcnc_h_word_no_use_error.ngc`, `tests/gcode/linuxcnc_i_word_no_use_error.ngc`, `tests/gcode/linuxcnc_j_word_no_use_error.ngc`, `tests/gcode/linuxcnc_k_word_no_use_error.ngc`, `tests/gcode/linuxcnc_l_word_no_use_error.ngc`, `tests/gcode/linuxcnc_p_word_no_use_error.ngc`, `tests/gcode/linuxcnc_q_word_no_use_error.ngc`, `tests/gcode/linuxcnc_r_word_no_use_error.ngc`, `tests/gcode/linuxcnc_bad_character_bang_error.ngc`, `tests/gcode/linuxcnc_bad_character_middle_n_word_error.ngc`, `tests/gcode/linuxcnc_comment_prefixed_n_word_error.ngc`, `tests/gcode/linuxcnc_comment_prefixed_spaced_n_word_error.ngc`, `tests/gcode/linuxcnc_comment_prefixed_oword_error.ngc`, `tests/gcode/linuxcnc_midline_numeric_oword_error.ngc`, `tests/gcode/linuxcnc_midline_named_oword_error.ngc`, `tests/gcode/linuxcnc_bad_character_top_left_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_top_right_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_midline_left_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_midline_right_bracket_error.ngc`, `tests/gcode/linuxcnc_bad_character_top_number_error.ngc`, `tests/gcode/linuxcnc_bad_n_number_format_error.ngc`, `tests/gcode/linuxcnc_file_ended_no_program_end_error.ngc`, `tests/gcode/linuxcnc_file_ended_no_percent_error.ngc`, generated `linuxcnc_command_too_long_error.ngc`, `tests/gcode/linuxcnc_too_many_m_codes_error.ngc` |
| Broader canned cycles `G73`, `G74`, `G82`-`G89` | partially covered: `G73`, `G74`, `G82`, `G83`, `G84`, `G85`, `G86`, `G87`, `G88`, `G89`; smoke parser maps supported cycles across `G17/G18/G19`, including LinuxCNC's special non-XY `G74/G84` tapping argument order and `G87` plane-specific `I/J/K` mapping; native/source regressions now check non-XY `G74/G84/G86/G87/G88` sequences | `tests/gcode/linuxcnc_canned_cycles_extended.ngc`, `tests/gcode/linuxcnc_canned_cycle_planes.ngc`, smoke API regression | | Broader canned cycles `G73`, `G74`, `G82`-`G89` | partially covered: `G73`, `G74`, `G82`, `G83`, `G84`, `G85`, `G86`, `G87`, `G88`, `G89`; smoke parser maps supported cycles across `G17/G18/G19`, including LinuxCNC's special non-XY `G74/G84` tapping argument order and `G87` plane-specific `I/J/K` mapping; native/source regressions now check non-XY `G74/G84/G86/G87/G88` sequences | `tests/gcode/linuxcnc_canned_cycles_extended.ngc`, `tests/gcode/linuxcnc_canned_cycle_planes.ngc`, smoke API regression |
| Full source-level wasm build | covered for the current wasm-safe RS274 source set, with remaining work focused on broadening browser-hostile dependency replacement and feature coverage | `./build-wasm.sh`, `test-linuxcnc-wasm-runtime-link.sh`, `test-web-wasm-node-smoke.sh`, `test-web-wasm-browser-smoke.sh` | | Full source-level wasm build | covered for the current wasm-safe RS274 source set, with remaining work focused on broadening browser-hostile dependency replacement and feature coverage | `./build-wasm.sh`, `test-linuxcnc-wasm-runtime-link.sh`, `test-web-wasm-node-smoke.sh`, `test-web-wasm-browser-smoke.sh` |

View File

@@ -805,6 +805,33 @@ if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
fi fi
grep -Fq "Multiple spindle choice (\$) words on one line" \ grep -Fq "Multiple spindle choice (\$) words on one line" \
"$output_dir/cnc_sim_linuxcnc_source_multiple_spindle_choice_words_error.err" "$output_dir/cnc_sim_linuxcnc_source_multiple_spindle_choice_words_error.err"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_check.cc
# check_other_codes() rejects otherwise well-formed words that have no active
# G/M/O code in the block to consume them.
unused_word_error_cases=(
"linuxcnc_d_word_no_use_error|D word with no G41, G41.1, G42, G42.1, G71, G71.1, G71.2 G73, G83 or G96 to use it"
"linuxcnc_spindle_dollar_no_use_error|\$ (spindle selection) word with no M3, M4, M5, M19, M51, G33, G33.1, G76, G95, G96 or G97 to use it"
"linuxcnc_e_word_no_use_error|E word with no G70, G76, M66, M67 or M68 to use it"
"linuxcnc_h_word_no_use_error|H word with no G43 or G76 to use it"
"linuxcnc_i_word_no_use_error|I word with no G2, G3, G5, G5.1, G6, G6.1, G10, G33.1, G76, or G87 to use it"
"linuxcnc_j_word_no_use_error|J word with no G2, G3, G5, G5.1, G6, G6.1, G10, G76 or G87 to use it"
"linuxcnc_k_word_no_use_error|K word with no G2, G3, G6.2, G33, G33.1, G76, or G87 to use it"
"linuxcnc_l_word_no_use_error|L word with no G10, cutter compensation, canned cycle, digital/analog input, M98 or NURBS code"
"linuxcnc_p_word_no_use_error|P word with no G2 G3 G4 G10 G64 G5 G5.2 G6, G6.2, G76 G82 G86 G88 G89 or M50 M51 M52 M53 M62 M63 M64 M65 M66 M98 or user M code to use it"
"linuxcnc_q_word_no_use_error|Q word with no G5, G6, G10, G64, G73, G76, G83, M19, M66, M67, M68 or user M code that uses it"
"linuxcnc_r_word_no_use_error|R word with no g code that uses it"
)
for case in "${unused_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 -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err"
done
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc # Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc
# read_items() only consumes a leading N word before item dispatch; # read_items() only consumes a leading N word before item dispatch;
# read_one_item() then uses the default reader table from interp_array.cc # read_one_item() then uses the default reader table from interp_array.cc

View File

@@ -0,0 +1,3 @@
G21 G90 G17
D1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
E1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
H1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
I1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
J1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
K1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
L1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
P1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
Q1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
R1
M30

View File

@@ -0,0 +1,3 @@
G21 G90 G17
$0
M30