Expand LinuxCNC smoke coverage

This commit is contained in:
cnc
2026-05-22 15:11:28 +08:00
parent 44e024e49c
commit 0ff0058417
17 changed files with 3507 additions and 70 deletions

View File

@@ -103,6 +103,12 @@ CNC_SIM_RS274_VAR="$var_file" \
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle.ngc \
>/tmp/cnc_sim_linuxcnc_source_canned_cycle.json
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycles_extended.ngc \
>/tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/smoke_oword_subprogram.ngc \
>/tmp/cnc_sim_linuxcnc_source_oword_subprogram.json
python3 - <<'PY'
import json
@@ -149,9 +155,68 @@ expected_cycle = [
actual_cycle = [(event["type"], event["end"]["x"], event["end"]["y"], event["end"]["z"]) for event in motions]
if actual_cycle != expected_cycle:
raise SystemExit(f"unexpected source-linked G81/G80 expansion: {actual_cycle!r}")
extended_cycle = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 10 and
event["end"]["z"] == -2
for event in extended_cycle
):
raise SystemExit("missing source-linked G82 feed to bottom")
if not any(
event["type"] == "dwell" and
event["line"] == 3 and
event["dwellSeconds"] == 0.25
for event in extended_cycle
):
raise SystemExit("missing source-linked G82 dwell at bottom")
g83_feed_depths = [
event["end"]["z"]
for event in extended_cycle
if event["type"] == "linear-feed" and event["line"] == 4
]
if g83_feed_depths != [1, 0, -1, -2, -3]:
raise SystemExit(f"unexpected source-linked G83 peck depths: {g83_feed_depths!r}")
if not any(
event["type"] == "rapid" and
event["line"] == 4 and
event["end"]["x"] == 20 and
event["end"]["z"] == 2
for event in extended_cycle
):
raise SystemExit("missing source-linked G83 final retract to R plane")
oword = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_oword_subprogram.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 8 and
event["start"]["x"] == 0 and
event["end"]["x"] == 7
for event in oword
):
raise SystemExit("missing source-linked O-word expression motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 9 and
event["start"]["y"] == 0 and
event["end"]["y"] == 2
for event in oword
):
raise SystemExit("missing source-linked O-word #2 argument motion")
if any(
event["type"] == "linear-feed" and
event["line"] == 11 and
event["end"]["x"] == 99
for event in oword
):
raise SystemExit("source-linked O-word return should skip remaining subprogram body")
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_canned_cycle.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_oword_subprogram.json"