继续推进

结论:扩大 LinuxCNC source-link 覆盖,新增 basic motion 与普通注释事件验证,未扩展 smoke parser。
This commit is contained in:
cnc
2026-06-02 08:26:25 +08:00
parent ad7a461b3e
commit 0a0083b2d3

View File

@@ -166,6 +166,12 @@ cp "$base_var_file" "$var_file"
LINUXCNC_ROOT="$linuxcnc_root" "$build_dir/linuxcnc_gees_table_smoke"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_straight(),
# convert_arc(), and convert_comment(); comment queuing goes through
# src/emc/rs274ngc/interp_queue.cc enqueue_COMMENT().
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_basic_motion.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_basic_motion.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/basic_mill.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_basic_mill.json"
@@ -499,6 +505,9 @@ CNC_SIM_RS274_VAR="$var_file" \
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_cutter_comp.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_cutter_comp.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_comments.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_comments.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_probe_no_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_probe_no_error.json"
@@ -838,28 +847,36 @@ from pathlib import Path
OUTPUT_DIR = Path(os.environ["CNC_SIM_RS274_SOURCE_OUTPUT_DIR"])
events = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_basic_mill.json").read_text())
def load(name):
return json.loads((OUTPUT_DIR / name).read_text())
def check_motion(name, required):
events = load(name)
types = {event["type"] for event in events}
required = {
missing = sorted(required - types)
if missing:
raise SystemExit(f"{name}: missing source-linked events: {', '.join(missing)}")
final_motion = [event for event in events if event["type"] in {"rapid", "linear-feed", "arc-feed"}][-1]
if final_motion["end"]["x"] != 0 or final_motion["end"]["y"] != 0:
raise SystemExit(f"{name}: unexpected source-linked final XY position")
return events
required_motion = {
"set-units",
"set-plane",
"set-spindle",
"tool-change",
"rapid",
"set-feed",
"linear-feed",
"arc-feed",
"dwell",
"program-end",
}
missing = sorted(required - types)
if missing:
raise SystemExit("missing source-linked events: " + ", ".join(missing))
check_motion("cnc_sim_linuxcnc_source_basic_motion.json", required_motion)
check_motion("cnc_sim_linuxcnc_source_basic_mill.json", required_motion | {"tool-change"})
final_motion = [event for event in events if event["type"] in {"rapid", "linear-feed", "arc-feed"}][-1]
if final_motion["end"]["x"] != 0 or final_motion["end"]["y"] != 0:
raise SystemExit("unexpected source-linked final XY position")
block_delete_off = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_block_delete_off.json").read_text())
block_delete_off = load("cnc_sim_linuxcnc_source_block_delete_off.json")
if not any(
event["type"] == "linear-feed" and event["line"] == 2 and event["end"]["x"] == 5
for event in block_delete_off
@@ -1554,6 +1571,10 @@ actual_cutter_comp = [
if actual_cutter_comp != expected_cutter_comp:
raise SystemExit(f"unexpected source-linked cutter compensation path: {actual_cutter_comp!r}")
comments = load("cnc_sim_linuxcnc_source_comments.json")
if not any(event["type"] == "comment" and event["line"] == 2 for event in comments):
raise SystemExit("missing source-linked LinuxCNC comment line event")
probe = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_probe_no_error.json").read_text())
probe_events = [
(event["line"], event["reserved"], event["start"]["z"], event["end"]["z"])
@@ -2433,6 +2454,7 @@ if not any(
PY
echo "linuxcnc rs274 source link smoke passed (${#objects[@]} local objects)"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_basic_motion.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_basic_mill.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rtcp_controls.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_spindle_direction.json"
@@ -2460,6 +2482,7 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_source_arc_distance_modes.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_predefined_positions.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_machine_coordinates.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_cutter_comp.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_comments.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_probe_no_error.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_oword_subprogram.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_named_oword_subprogram.json"