Cover M-code states in source link tests

This commit is contained in:
cnc
2026-05-22 17:54:44 +08:00
parent 63ecbb6577
commit 7fe7ea6038
2 changed files with 59 additions and 0 deletions

View File

@@ -103,6 +103,18 @@ CNC_SIM_RS274_VAR="$var_file" \
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rtcp_controls.ngc \
>/tmp/cnc_sim_linuxcnc_source_rtcp_controls.json
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_spindle_direction.ngc \
>/tmp/cnc_sim_linuxcnc_source_spindle_direction.json
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_number.ngc \
>/tmp/cnc_sim_linuxcnc_source_tool_number.json
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_program_stops.ngc \
>/tmp/cnc_sim_linuxcnc_source_program_stops.json
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_coolant.ngc \
>/tmp/cnc_sim_linuxcnc_source_coolant.json
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_feed_modes.ngc \
>/tmp/cnc_sim_linuxcnc_source_feed_modes.json
@@ -169,6 +181,48 @@ rtcp = [event for event in controls if event["type"] == "rtcp-state"]
if [(event["line"], event["tool"], event["feed"]) for event in rtcp] != [(3, 0, 0), (4, 7, 1)]:
raise SystemExit("unexpected source-linked RTCP state sequence")
spindle = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_spindle_direction.json").read_text())
spindle_states = [
(event["line"], event["spindle"], event["reserved"])
for event in spindle
if event["type"] == "set-spindle"
]
if (2, 1200, 1) not in spindle_states:
raise SystemExit("missing source-linked M3 clockwise spindle state")
if (3, 1200, 2) not in spindle_states:
raise SystemExit("missing source-linked M4 counterclockwise spindle state")
if (4, 0, 0) not in spindle_states:
raise SystemExit("missing source-linked M5 stopped spindle state")
tool_number = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_tool_number.json").read_text())
if not any(
event["type"] == "tool-change" and
event["line"] == 2 and
event["tool"] == 1
for event in tool_number
):
raise SystemExit("missing source-linked M61 Q1 tool-number event line")
stops = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_program_stops.json").read_text())
stop_states = [
(event["line"], event["reserved"])
for event in stops
if event["type"] == "program-end"
]
for expected in [(2, 1), (3, 2), (4, 3), (4, 1), (5, 0)]:
if expected not in stop_states:
raise SystemExit(f"missing source-linked program stop state {expected!r}")
coolant = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_coolant.json").read_text())
coolant_states = [
(event["line"], event["reserved"])
for event in coolant
if event["type"] == "comment"
]
for expected in [(2, 11), (3, 21), (4, 10), (4, 20)]:
if expected not in coolant_states:
raise SystemExit(f"missing source-linked coolant state {expected!r}")
feed_modes = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_feed_modes.json").read_text())
feed_mode_comments = [
(event["line"], event["reserved"])
@@ -370,6 +424,10 @@ PY
echo "linuxcnc rs274 source link smoke passed (${#objects[@]} local objects)"
echo "dumped /tmp/cnc_sim_linuxcnc_source_basic_mill.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_rtcp_controls.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_spindle_direction.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_tool_number.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_program_stops.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_coolant.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_feed_modes.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_motion_modes.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_tool_length.json"