参考所有分组:补齐 O-word native 覆盖,测试通过
This commit is contained in:
@@ -578,6 +578,68 @@ CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs2
|
||||
# Fanuc-style M98/M99 subprogram blocks, and interp_o_word.cc execute_call()
|
||||
# handles L-word repeat counts and return-to-caller position.
|
||||
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/smoke_subprogram_m98.ngc >"$output_dir/cnc_sim_linuxcnc_m98_subprogram.json"
|
||||
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_o()
|
||||
# and read_items() reject malformed O-word control lines, empty call
|
||||
# parameter expressions through read_real_expression()/read_real_number(),
|
||||
# and Fanuc-style M98 calls before execution.
|
||||
oword_reader_error_cases=(
|
||||
"linuxcnc_oword_unknown_command_error|Unknown control command in o word"
|
||||
"linuxcnc_oword_unexpected_trailing_item_error|Unexpected character after O-word"
|
||||
"linuxcnc_oword_if_missing_bracket_error|Left bracket missing after 'if'"
|
||||
"linuxcnc_oword_elseif_missing_bracket_error|Left bracket missing after 'elseif'"
|
||||
"linuxcnc_oword_while_missing_bracket_error|Left bracket missing after 'while'"
|
||||
"linuxcnc_oword_repeat_missing_bracket_error|Left bracket missing after 'repeat'"
|
||||
"linuxcnc_oword_too_many_call_parameters_error|Too many subroutine parameters"
|
||||
"linuxcnc_oword_empty_call_parameter_error|bad number format (conversion failed) parsing ''"
|
||||
"linuxcnc_m98_missing_p_word_error|Found 'm98' code with no P-word"
|
||||
"linuxcnc_midline_m98_error|Unknown m code used: M98"
|
||||
"linuxcnc_comment_prefixed_m98_error|Unknown m code used: M98"
|
||||
)
|
||||
for case in "${oword_reader_error_cases[@]}"; do
|
||||
fixture=${case%%|*}
|
||||
expected=${case#*|}
|
||||
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
|
||||
"$build_dir/linuxcnc_rs274_dump" "tests/gcode/$fixture.ngc" \
|
||||
>"$output_dir/cnc_sim_linuxcnc_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_$fixture.err"; then
|
||||
echo "expected $fixture.ngc to fail" >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err"
|
||||
done
|
||||
# Source basis: LinuxCNC src/emc/rs274ngc/interp_o_word.cc
|
||||
# convert_control_functions() rejects unmatched, duplicate, and
|
||||
# out-of-context O-word control labels during execution.
|
||||
oword_execution_error_cases=(
|
||||
"linuxcnc_oword_endsub_without_sub_error|not in a subroutine definition"
|
||||
"linuxcnc_oword_return_without_sub_error|not in a subroutine definition"
|
||||
"linuxcnc_oword_duplicate_if_label_error|duplicate O-word label"
|
||||
"linuxcnc_oword_elseif_undefined_label_error|undefined O-word label"
|
||||
"linuxcnc_oword_else_undefined_label_error|undefined O-word label"
|
||||
"linuxcnc_oword_endif_undefined_label_error|undefined O-word label"
|
||||
"linuxcnc_oword_break_undefined_label_error|undefined O-word label"
|
||||
"linuxcnc_oword_continue_undefined_label_error|undefined O-word label"
|
||||
"linuxcnc_oword_endwhile_undefined_label_error|undefined O-word label"
|
||||
"linuxcnc_oword_elseif_no_matching_if_error|no matching 'if' label"
|
||||
"linuxcnc_oword_break_no_matching_loop_error|no matching while/do label"
|
||||
"linuxcnc_oword_continue_no_matching_loop_error|no matching while/do label"
|
||||
"linuxcnc_oword_endrepeat_no_matching_repeat_error|no matching label"
|
||||
"linuxcnc_oword_endif_no_matching_if_error|no matching label"
|
||||
"linuxcnc_oword_endwhile_no_matching_while_error|no matching label"
|
||||
"linuxcnc_oword_fanuc_requires_m99_error|Fanuc 'O....' subroutine definition must end with 'M99'"
|
||||
"linuxcnc_oword_sub_requires_endsub_error|'O.... endsub' or 'O.... return' must follow 'O.... sub'"
|
||||
"linuxcnc_oword_too_many_call_levels_error|Too many subroutine levels"
|
||||
)
|
||||
for case in "${oword_execution_error_cases[@]}"; do
|
||||
fixture=${case%%|*}
|
||||
expected=${case#*|}
|
||||
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
|
||||
"$build_dir/linuxcnc_rs274_dump" "tests/gcode/$fixture.ngc" \
|
||||
>"$output_dir/cnc_sim_linuxcnc_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_$fixture.err"; then
|
||||
echo "expected $fixture.ngc to fail" >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err"
|
||||
done
|
||||
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_oword_control_flow.ngc >"$output_dir/cnc_sim_linuxcnc_oword_control_flow.json"
|
||||
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_named_parameter_exists.ngc >"$output_dir/cnc_sim_linuxcnc_named_parameter_exists.json"
|
||||
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_indexed_parameters.ngc >"$output_dir/cnc_sim_linuxcnc_indexed_parameters.json"
|
||||
|
||||
Reference in New Issue
Block a user