Files
wasm-simulator/test-linuxcnc-source-link.sh

3670 lines
175 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
# LinuxCNC source basis: this source-link test compiles the manifest-selected
# src/emc/rs274ngc objects directly and links only project dump/canon/kinematics
# bridge code around them for event comparison.
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
cxx=${CXX:-g++}
if [[ -z ${CXX:-} ]] && command -v ccache >/dev/null 2>&1; then
cxx="ccache $cxx"
fi
build_jobs=${CNC_SIM_BUILD_JOBS:-8}
if ! [[ "$build_jobs" =~ ^[1-9][0-9]*$ ]]; then
echo "CNC_SIM_BUILD_JOBS must be a positive integer: $build_jobs" >&2
exit 1
fi
build_dir=${CNC_SIM_SOURCE_LINK_BUILD_DIR-build/source-link-test}
if [[ -z "$build_dir" ]]; then
echo "CNC_SIM_SOURCE_LINK_BUILD_DIR must not be empty" >&2
exit 1
fi
if [[ "$build_dir" =~ [[:space:]] ]]; then
echo "CNC_SIM_SOURCE_LINK_BUILD_DIR must not contain whitespace: $build_dir" >&2
exit 1
fi
manifest=${1:-linuxcnc-rs274-source-files.txt}
mkdir -p "$build_dir"
build_dir=$(cd "$build_dir" && pwd)
if [[ "$build_dir" == "/" ]]; then
echo "CNC_SIM_SOURCE_LINK_BUILD_DIR must not be the filesystem root" >&2
exit 1
fi
preflight_cache_dir="$build_dir/preflight-cache"
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs-cached.sh --cache-dir "$preflight_cache_dir" "$manifest"
./check-linuxcnc-rs274-source-map.sh
./check-linuxcnc-kinematics-source-map.sh
./check-linuxcnc-opfs-source-map.sh
./check-linuxcnc-switchkins-remap-source-map.sh
./check-linuxcnc-wasm-smoke-source-map.sh
./check-linuxcnc-build-source-map.sh
./check-linuxcnc-browser-app-source-map.sh
./check-linuxcnc-workstreams-source-map.sh
./check-linuxcnc-tooldata-source-map.sh
./check-linuxcnc-wasm-shims-source-map.sh
./check-linuxcnc-wasm-blockers-source-map.sh
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-switchkins-remap-table-cached.sh --cache-dir "$preflight_cache_dir" linuxcnc-kinematics-source-files.txt
# The LinuxCNC source-linked dump path is not concurrency-safe under parallel execution.
exec 9>"${TMPDIR:-/tmp}/cnc_sim_rs274_source_link.lock"
flock 9
common_flag_output=$(
LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-common-cxxflags.sh \
--python \
--core-include \
--core-src
)
mapfile -t common_flags <<<"$common_flag_output"
link_flag_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-native-linkflags.sh)
mapfile -t link_flags <<<"$link_flag_output"
source_output=$(CNC_SIM_PREFLIGHT_CACHE_DIR="$preflight_cache_dir" LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-manifest-sources.sh "$manifest" core full)
mapfile -t linuxcnc_sources <<<"$source_output"
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs-cached.sh --cache-dir "$preflight_cache_dir" "$manifest" --require-rs274-complete
objects=()
linuxcnc_index=0
for source in "${linuxcnc_sources[@]}"; do
obj="$build_dir/linuxcnc_${linuxcnc_index}.o"
objects+=("$obj")
linuxcnc_index=$((linuxcnc_index + 1))
done
project_index=0
project_source_list="$build_dir/linuxcnc_rs274_dump_project_sources.txt"
./list-linuxcnc-rs274-dump-project-sources.sh > "$project_source_list"
mapfile -t project_sources < "$project_source_list"
for source in "${project_sources[@]}"; do
obj="$build_dir/project_${project_index}.o"
objects+=("$obj")
project_index=$((project_index + 1))
done
support_object_list="$build_dir/linuxcnc_support_objects.txt"
LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-source-support-objects.sh > "$support_object_list"
mapfile -t support_objects < "$support_object_list"
source_link_signature="$build_dir/source-link-build.signature"
source_link_next_signature="$build_dir/source-link-build.signature.next"
{
printf 'CXX=%s\n' "$cxx"
printf 'PWD=%s\n' "$PWD"
printf 'LINUXCNC_ROOT=%s\n' "$(cd "$linuxcnc_root" && pwd)"
printf 'BUILD_RULE_VERSION=1\n'
printf 'COMMON_FLAGS='
printf ' %s' "${common_flags[@]}"
printf '\n'
printf 'LINK_FLAGS='
printf ' %s' "${link_flags[@]}"
printf '\n'
printf 'LINUXCNC_SOURCES:\n'
printf '%s\n' "${linuxcnc_sources[@]}"
printf 'PROJECT_SOURCES:\n'
printf '%s\n' "${project_sources[@]}"
printf 'SUPPORT_OBJECTS:\n'
printf '%s\n' "${support_objects[@]}"
} > "$source_link_next_signature"
if [[ ! -f "$source_link_signature" ]] || ! cmp -s "$source_link_signature" "$source_link_next_signature"; then
rm -f "$build_dir"/linuxcnc_*.o \
"$build_dir"/*.d \
"$build_dir"/project_*.o \
"$build_dir"/linuxcnc_gees_table_smoke.o \
"$build_dir"/linuxcnc_rs274_source_dump \
"$build_dir"/linuxcnc_gees_table_smoke
fi
mv "$source_link_next_signature" "$source_link_signature"
source_link_makefile="$build_dir/source-link.mk"
{
printf 'CXX := %s\n' "$cxx"
printf 'COMMON_FLAGS :='
printf ' %s' "${common_flags[@]}"
printf '\n'
printf 'LINK_FLAGS :='
printf ' %s' "${link_flags[@]}"
printf '\n'
printf 'OBJECTS :='
printf ' %s' "${objects[@]}"
printf '\n'
printf 'SUPPORT_OBJECTS :='
printf ' %s' "${support_objects[@]}"
printf '\n\n'
printf 'DEP_FILES :=\n'
for object in "${objects[@]}"; do
printf 'DEP_FILES += %s.d\n' "$object"
done
printf 'DEP_FILES += %s.d\n\n' "$build_dir/linuxcnc_gees_table_smoke.o"
printf '.PHONY: all\n'
printf 'all: %s %s\n\n' \
"$build_dir/linuxcnc_rs274_source_dump" \
"$build_dir/linuxcnc_gees_table_smoke"
linuxcnc_index=0
for source in "${linuxcnc_sources[@]}"; do
printf '%s: %s\n' "$build_dir/linuxcnc_${linuxcnc_index}.o" "$source"
printf '\t@$(CXX) $(COMMON_FLAGS) -MMD -MP -MF %s.d -c %s -o %s\n\n' \
"$build_dir/linuxcnc_${linuxcnc_index}.o" "$source" "$build_dir/linuxcnc_${linuxcnc_index}.o"
linuxcnc_index=$((linuxcnc_index + 1))
done
project_index=0
for source in "${project_sources[@]}"; do
printf '%s: %s\n' "$build_dir/project_${project_index}.o" "$source"
printf '\t@$(CXX) $(COMMON_FLAGS) -MMD -MP -MF %s.d -c %s -o %s\n\n' \
"$build_dir/project_${project_index}.o" "$source" "$build_dir/project_${project_index}.o"
project_index=$((project_index + 1))
done
printf '%s: core/tests/linuxcnc_gees_table_smoke.cpp\n' "$build_dir/linuxcnc_gees_table_smoke.o"
printf '\t@$(CXX) -std=c++17 -I core/include -I core/src -MMD -MP -MF %s.d -c core/tests/linuxcnc_gees_table_smoke.cpp -o %s\n\n' \
"$build_dir/linuxcnc_gees_table_smoke.o" "$build_dir/linuxcnc_gees_table_smoke.o"
printf '%s: %s\n' "$build_dir/linuxcnc_gees_table_smoke" "$build_dir/linuxcnc_gees_table_smoke.o"
printf '\t@$(CXX) -std=c++17 -I core/include -I core/src %s -o %s\n\n' "$build_dir/linuxcnc_gees_table_smoke.o" "$build_dir/linuxcnc_gees_table_smoke"
printf '%s: $(OBJECTS) $(SUPPORT_OBJECTS)\n' "$build_dir/linuxcnc_rs274_source_dump"
printf '\t@$(CXX) $(OBJECTS) $(SUPPORT_OBJECTS) $(LINK_FLAGS) -llinuxcnc-uspace-posix -llinuxcncini -llinuxcnchal -lpyplugin -ltooldata -lnml -lposemath -lboost_python313 -lpython3.13 -lfmt -ldl -o %s\n' "$build_dir/linuxcnc_rs274_source_dump"
printf '\n-include $(DEP_FILES)\n'
} > "$source_link_makefile"
make --output-sync=target -j"$build_jobs" -f "$source_link_makefile"
var_file="$build_dir/rs274ngc-source.var"
base_var_file="$build_dir/rs274ngc-source-base.var"
ini_named_parameter_file="$(pwd)/tests/gcode/linuxcnc_ini_named_parameter.ini"
output_dir="$build_dir/outputs"
mkdir -p "$output_dir"
cp "$linuxcnc_root/tests/halui/jogging/sim.var" "$base_var_file"
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"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_distance_mode() updates G90/G91 state, and convert_arc() routes
# R-format arcs through src/emc/rs274ngc/interp_find.cc arc-center math.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/incremental_and_r_arc.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_incremental_and_r_arc.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_block_delete.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_block_delete_off.json"
CNC_SIM_BLOCK_DELETE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_block_delete.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_block_delete_on.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rtcp_controls.ngc \
>"$output_dir/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 \
>"$output_dir/cnc_sim_linuxcnc_source_spindle_direction.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_spindle_modes.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_spindle_modes.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_spindle_orient.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_spindle_orient.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_io_controls.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_io_controls.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_m()
# validates M62-M68 input/output words, M3/M4/M5/M19 spindle selectors, M61 Q
# tool numbers, and M19 Q wait values before issuing Canon output/input, tool,
# or spindle-orient calls. LinuxCNC src/emc/rs274ngc/interp_check.cc
# check_other_codes() validates M19 P/R words before conversion.
convert_m_error_cases=(
"linuxcnc_m3_spindle_dollar_out_of_range_error|Spindle (\$) number out of range in M3 Command"
"linuxcnc_m4_spindle_dollar_out_of_range_error|Spindle (\$) number out of range in M4 Command"
"linuxcnc_m5_spindle_dollar_out_of_range_error|Spindle (\$) number out of range in M5 Command"
"linuxcnc_m62_missing_p_word_error|No valid P word with M62"
"linuxcnc_m63_missing_p_word_error|No valid P word with M63"
"linuxcnc_m64_missing_p_word_error|No valid P word with M64"
"linuxcnc_m65_missing_p_word_error|No valid P word with M65"
"linuxcnc_m66_missing_input_error|Need to have either a valid P or a valid E word with M66"
"linuxcnc_m66_both_inputs_error|Invalid to select both a digital and an analog input with M66"
"linuxcnc_m66_zero_timeout_error|Zero timeout with wait type != immediate return"
"linuxcnc_m66_analog_wait_error|Can't select analog input with wait type != immediate return"
"linuxcnc_m67_missing_e_word_error|Invalid analog index with M67"
"linuxcnc_m68_missing_e_word_error|Invalid analog index with M68"
"linuxcnc_m19_spindle_dollar_out_of_range_error|Spindle (\$) number out of range in M19 Command"
"linuxcnc_m19_p_not_integer_error|P value not an integer with M19 G2 or G3"
"linuxcnc_m19_p_out_of_range_error|P value must be 0,1,or 2 with M19"
"linuxcnc_m19_r_out_of_range_error|R value must be within 0..360 with M19"
"linuxcnc_m19_zero_q_error|Q word with M19 requires a value > 0"
"linuxcnc_m61_negative_q_error|Need non-negative Q-word to specify tool number with M61"
)
for case in "${convert_m_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_override_controls.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_override_controls.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_modal_state.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_modal_state.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_modal_autorestore.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_modal_autorestore.json"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_modal_invalidate.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_modal_invalidate.json" 2>"$output_dir/cnc_sim_linuxcnc_source_modal_invalidate.err"; then
echo "expected linuxcnc_modal_invalidate.ngc to fail" >&2
exit 1
fi
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_threading_sync.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_threading_sync.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_threading_cycle.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_threading_cycle.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_lathe_diameter_mode() scales G7/G8 X words and G76 I/J/K words;
# interp_namedparams.cc exposes #<_lathe_diameter_mode> and
# #<_lathe_radius_mode>.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_lathe_diameter_mode.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_lathe_diameter_mode.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_lathe_diameter_g76.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_lathe_diameter_g76.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_number.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_tool_number.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_tool_select() and convert_m() M61 both route through
# src/emc/rs274ngc/interp_find.cc find_tool_index() for tooldata lookup.
tool_number_error_cases=(
"linuxcnc_t_missing_tool_error|Requested tool 99 not found in the tool table"
"linuxcnc_m61_missing_tool_error|Requested tool 99 not found in the tool table"
)
for case in "${tool_number_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_program_stops.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_program_stops.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_stop()
# sends M2 through the reset plus PROGRAM_END branch without the M30-only
# PALLET_SHUTTLE call.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_program_end_m2.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_program_end_m2.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_internal.hh defaults
# loop_on_main_m99 false; interp_convert.cc convert_stop() then treats
# main-program M99 as the same reset plus PROGRAM_END branch.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_program_end_m99.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_program_end_m99.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_check.cc treats exactly
# P-1.0 as a missing G4 dwell P word, while interp_convert.cc convert_dwell()
# and interp_queue.cc enqueue_DWELL() pass neighboring values through.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g4_dwell_boundaries.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g4_dwell_boundaries.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_coolant.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_coolant.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_feed_modes.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_feed_modes.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_motion_modes.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_motion_modes.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_control_mode() sends G64 P through SET_MOTION_CONTROL_MODE()
# and G64 Q through SET_NAIVECAM_TOLERANCE(), defaulting Q to P when Q is omitted.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_control_mode_tolerances.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_control_mode_tolerances.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_length.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_tool_length.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_dynamic_tool_length.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_dynamic_tool_length.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_tool_length_offset() rejects invalid G43.2 H/axis combinations,
# and src/emc/rs274ngc/interp_find.cc find_tool_index() rejects H tool
# numbers missing from the LinuxCNC tooldata table.
tool_length_offset_error_cases=(
"linuxcnc_g43_missing_tool_error|Requested tool 99 not found in the tool table"
"linuxcnc_g43_2_missing_tool_error|Requested tool 99 not found in the tool table"
"linuxcnc_g43_2_h_axis_error|G43.2: Can not have both H and axis words"
"linuxcnc_g43_2_missing_h_axis_error|G43.2: No axes specified and H word missing"
)
for case in "${tool_length_offset_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_cycles.cc
# convert_cycle() rejects inverse-time feed mode and active cutter
# compensation before expanding canned cycles through convert_cycle_xy()/yz()/zx().
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_inverse_time_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_inverse_time_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_inverse_time_error.err"; then
echo "expected linuxcnc_canned_cycle_inverse_time_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot use inverse time feed with canned cycles" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_inverse_time_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_cutter_comp_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_cutter_comp_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_cutter_comp_error.err"; then
echo "expected linuxcnc_canned_cycle_cutter_comp_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot use canned cycles with cutter compensation on" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_cutter_comp_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_l0_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_l0_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_l0_error.err"; then
echo "expected linuxcnc_canned_cycle_l0_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot do zero repeats of cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_l0_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_missing_r_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_missing_r_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_missing_r_error.err"; then
echo "expected linuxcnc_canned_cycle_missing_r_error.ngc to fail" >&2
exit 1
fi
grep -q "R clearance plane unspecified in cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_missing_r_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_missing_z_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_missing_z_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_missing_z_error.err"; then
echo "expected linuxcnc_canned_cycle_missing_z_error.ngc to fail" >&2
exit 1
fi
grep -q "Z value unspecified in xy plane canned cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_missing_z_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g18_missing_y_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g18_missing_y_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g18_missing_y_error.err"; then
echo "expected linuxcnc_canned_cycle_g18_missing_y_error.ngc to fail" >&2
exit 1
fi
grep -q "Y value unspecified in xz plane canned cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g18_missing_y_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g19_missing_x_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g19_missing_x_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g19_missing_x_error.err"; then
echo "expected linuxcnc_canned_cycle_g19_missing_x_error.ngc to fail" >&2
exit 1
fi
grep -q "X value unspecified in yz plane canned cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g19_missing_x_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_r_less_z_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_r_less_z_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_r_less_z_error.err"; then
echo "expected linuxcnc_canned_cycle_r_less_z_error.ngc to fail" >&2
exit 1
fi
grep -q "R less than z in cycle in xy plane" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_r_less_z_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g18_r_less_y_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g18_r_less_y_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g18_r_less_y_error.err"; then
echo "expected linuxcnc_canned_cycle_g18_r_less_y_error.ngc to fail" >&2
exit 1
fi
grep -q "R less than y in cycle in xz plane" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g18_r_less_y_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g19_r_less_x_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g19_r_less_x_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g19_r_less_x_error.err"; then
echo "expected linuxcnc_canned_cycle_g19_r_less_x_error.ngc to fail" >&2
exit 1
fi
grep -q "R less than x in cycle in yz plane" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g19_r_less_x_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_u_in_xy_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_u_in_xy_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_u_in_xy_error.err"; then
echo "expected linuxcnc_canned_cycle_u_in_xy_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot put a U in a canned cycle in the XY plane" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_u_in_xy_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_a_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_a_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_a_error.err"; then
echo "expected linuxcnc_canned_cycle_a_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot put an a in canned cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_a_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_b_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_b_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_b_error.err"; then
echo "expected linuxcnc_canned_cycle_b_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot put a b in canned cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_b_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_c_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_c_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_c_error.err"; then
echo "expected linuxcnc_canned_cycle_c_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot put a c in canned cycle" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_c_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g73_missing_q_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g73_missing_q_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g73_missing_q_error.err"; then
echo "expected linuxcnc_canned_cycle_g73_missing_q_error.ngc to fail" >&2
exit 1
fi
grep -q "Q word missing with g73" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g73_missing_q_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g83_missing_q_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g83_missing_q_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g83_missing_q_error.err"; then
echo "expected linuxcnc_canned_cycle_g83_missing_q_error.ngc to fail" >&2
exit 1
fi
grep -q "Q word missing with g83" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g83_missing_q_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g73_q0_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g73_q0_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g73_q0_error.err"; then
echo "expected linuxcnc_canned_cycle_g73_q0_error.ngc to fail" >&2
exit 1
fi
grep -q "Negative or zero q value used" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g73_q0_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g83_q0_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g83_q0_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g83_q0_error.err"; then
echo "expected linuxcnc_canned_cycle_g83_q0_error.ngc to fail" >&2
exit 1
fi
grep -q "Negative or zero q value used" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g83_q0_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g82_missing_p_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g82_missing_p_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g82_missing_p_error.err"; then
echo "expected linuxcnc_canned_cycle_g82_missing_p_error.ngc to fail" >&2
exit 1
fi
grep -q "Dwell time p word missing with g82" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g82_missing_p_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g86_missing_p_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g86_missing_p_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g86_missing_p_error.err"; then
echo "expected linuxcnc_canned_cycle_g86_missing_p_error.ngc to fail" >&2
exit 1
fi
grep -q "Dwell time p word missing with g86" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g86_missing_p_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g88_missing_p_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g88_missing_p_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g88_missing_p_error.err"; then
echo "expected linuxcnc_canned_cycle_g88_missing_p_error.ngc to fail" >&2
exit 1
fi
grep -q "Dwell time p word missing with g88" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g88_missing_p_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g89_missing_p_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g89_missing_p_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g89_missing_p_error.err"; then
echo "expected linuxcnc_canned_cycle_g89_missing_p_error.ngc to fail" >&2
exit 1
fi
grep -q "Dwell time p word missing with g89" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g89_missing_p_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g74_clockwise_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g74_clockwise_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g74_clockwise_error.err"; then
echo "expected linuxcnc_canned_cycle_g74_clockwise_error.ngc to fail" >&2
exit 1
fi
grep -q "Spindle turning clockwise in G74" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g74_clockwise_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g84_counterclockwise_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g84_counterclockwise_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g84_counterclockwise_error.err"; then
echo "expected linuxcnc_canned_cycle_g84_counterclockwise_error.ngc to fail" >&2
exit 1
fi
grep -q "Spindle turning counterclockwise in G84" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g84_counterclockwise_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g74_stopped_spindle_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g74_stopped_spindle_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g74_stopped_spindle_error.err"; then
echo "expected linuxcnc_canned_cycle_g74_stopped_spindle_error.ngc to fail" >&2
exit 1
fi
grep -q "Spindle not turning in G74" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g74_stopped_spindle_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g84_stopped_spindle_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g84_stopped_spindle_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g84_stopped_spindle_error.err"; then
echo "expected linuxcnc_canned_cycle_g84_stopped_spindle_error.ngc to fail" >&2
exit 1
fi
grep -q "Spindle not turning in G84" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g84_stopped_spindle_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g86_stopped_spindle_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g86_stopped_spindle_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g86_stopped_spindle_error.err"; then
echo "expected linuxcnc_canned_cycle_g86_stopped_spindle_error.ngc to fail" >&2
exit 1
fi
grep -q "Spindle not turning in g86" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g86_stopped_spindle_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g88_stopped_spindle_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g88_stopped_spindle_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g88_stopped_spindle_error.err"; then
echo "expected linuxcnc_canned_cycle_g88_stopped_spindle_error.ngc to fail" >&2
exit 1
fi
grep -q "Spindle not turning in g88" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g88_stopped_spindle_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g87_stopped_spindle_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_stopped_spindle_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_stopped_spindle_error.err"; then
echo "expected linuxcnc_canned_cycle_g87_stopped_spindle_error.ngc to fail" >&2
exit 1
fi
grep -q "Spindle not turning in g87" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_stopped_spindle_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g87_missing_k_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_k_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_k_error.err"; then
echo "expected linuxcnc_canned_cycle_g87_missing_k_error.ngc to fail" >&2
exit 1
fi
grep -q "K word missing with g87" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_k_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g87_missing_i_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_i_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_i_error.err"; then
echo "expected linuxcnc_canned_cycle_g87_missing_i_error.ngc to fail" >&2
exit 1
fi
grep -q "I word missing with g87" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_i_error.err"
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g87_missing_j_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_j_error.json" \
2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_j_error.err"; then
echo "expected linuxcnc_canned_cycle_g87_missing_j_error.ngc to fail" >&2
exit 1
fi
grep -q "J word missing with g87" "$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g87_missing_j_error.err"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_cycles.cc
# convert_cycle_g73()/g85()/g86()/g89() expand peck, feed-out,
# stop/restart, dwell, and retract sequences through Canon motion.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycles_extended.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycles_extended.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_planes.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_planes.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_extended_plane_cycle.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_extended_plane_cycle.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_arc_planes.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_arc_planes.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_arc_distance_modes.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_arc_distance_modes.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_atsign()
# and read_carat() parse @/^ polar words; src/emc/rs274ngc/interp_internal.cc
# enhance_block() restricts polar coordinates to G17 motion without X/Y words;
# src/emc/rs274ngc/interp_find.cc find_ends() maps absolute polar radius/angle
# to XY endpoints and rejects G53 or origin-indeterminate polar motions.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_polar_coordinates.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_polar_coordinates.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_polar_coordinate_variants.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_polar_coordinate_variants.json"
polar_coordinate_error_cases=(
"linuxcnc_polar_g18_error|Cannot use polar coordinate except in G17 plane"
"linuxcnc_polar_with_x_error|Cannot specify both polar coordinate and X word"
"linuxcnc_polar_with_y_error|Cannot specify both polar coordinate and Y word"
"linuxcnc_polar_g92_error|Polar coordinates can only be used for motion"
"linuxcnc_polar_g28_error|Polar coordinates can only be used for motion"
"linuxcnc_polar_g30_error|Polar coordinates can only be used for motion"
"linuxcnc_polar_g53_error|Cannot use polar coordinates with G53"
"linuxcnc_polar_radius_origin_error|Must specify angle in polar coordinate if at the origin"
"linuxcnc_polar_incremental_radius_origin_error|Incremental motion with polar coordinates is indeterminate when at the origin"
"linuxcnc_polar_incremental_theta_origin_error|G91 motion with polar coordinates is indeterminate when at the origin"
)
for case in "${polar_coordinate_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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_internal.cc
# enhance_block() assigns motion_to_be and rejects invalid axis use with G80,
# missing axes for G52/G92 or motion codes, bare axis words without active
# motion, and modal-0 G codes that consume axis values on a motion block.
enhance_block_error_cases=(
"linuxcnc_g80_axis_error|Cannot use axis values with g80"
"linuxcnc_g52_missing_axis_error|All axes missing with g52 or g92"
"linuxcnc_g92_missing_axis_error|All axes missing with g52 or g92"
"linuxcnc_motion_missing_axis_error|All axes missing with motion code"
"linuxcnc_axis_without_motion_error|Cannot use axis values without a g code that uses them"
"linuxcnc_motion_with_g92_axis_error|Cannot use two g codes that both use axis values"
)
for case in "${enhance_block_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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_check.cc
# check_g_codes() rejects invalid modal-0 combinations for G4, G10, and G53
# before convert_g() executes motion or coordinate updates.
check_g_code_error_cases=(
"linuxcnc_g4_missing_p_error|Dwell time missing with g4"
"linuxcnc_g4_negative_p_error|Dwell time missing with g4"
"linuxcnc_g4_arc_p_conflict_error|G4 not allowed with G2 or G3 because they both use P"
"linuxcnc_g10_invalid_l_error|Line with G10 does not have L0, L1, L10, L11, L2, or L20"
"linuxcnc_g10_p_non_integer_error|P value not an integer with G10"
"linuxcnc_g10_l2_p_out_of_range_error|P value out of range (0-9) with G10 L2"
"linuxcnc_g10_l2_p_missing_error|P value out of range (0-9) with G10 L2"
"linuxcnc_g10_l20_p_out_of_range_error|P value out of range (0-9) with G10 L20"
"linuxcnc_g10_l20_p_missing_error|P value out of range (0-9) with G10 L20"
"linuxcnc_g10_l1_p_out_of_range_error|P value out of range with G10 L1"
"linuxcnc_g10_l10_p_out_of_range_error|P value out of range with G10 L10"
"linuxcnc_g10_l11_p_out_of_range_error|P value out of range with G10 L11"
"linuxcnc_g53_arc_error|Must use g0 or g1 with g53"
"linuxcnc_g53_incremental_error|Cannot use g53 incremental"
)
for case in "${check_g_code_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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_convert.cc
# convert_setup() rejects disallowed G10 L2/L20 words, and
# convert_tool_table() rejects G10 L1 table updates without offsets.
g10_convert_error_cases=(
"linuxcnc_g10_l1_missing_tool_error|Requested tool 999 not found in the tool table"
"linuxcnc_g10_l1_without_offsets_error|G10 L1 without offsets has no effect"
"linuxcnc_g10_l1_q_noninteger_error|Q number in G10 is not an integer"
"linuxcnc_g10_l1_q_negative_error|Q number in G10 is not an integer"
"linuxcnc_g10_l1_q_out_of_range_error|Invalid tool orientation"
"linuxcnc_g10_l2_i_word_error|I J words not allowed with G10 L2"
"linuxcnc_g10_l20_i_word_error|I J words not allowed with G10 L2"
"linuxcnc_g10_l20_r_word_error|R not allowed in G10 L20"
)
for case in "${g10_convert_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_predefined_positions.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_predefined_positions.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_machine_coordinates.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_machine_coordinates.json"
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"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/smoke_oword_subprogram.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_oword_subprogram.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_named_oword_subprogram.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_named_oword_subprogram.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_m() marks
# 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_source_dump" tests/gcode/smoke_subprogram_m98.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_m98_subprogram.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_oword_control_flow.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_oword_control_flow.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_named_parameter_exists.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_named_parameter_exists.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_indexed_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_indexed_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_named_parameter_normalization.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_named_parameter_normalization.json"
INI_FILE_NAME="$ini_named_parameter_file" CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_ini_named_parameter.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_ini_named_parameter.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_namedparams.cc lookup_named_param()
# and init_readonly_param() expose modal/unit/feed/spindle readonly parameters.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_readonly_named_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_readonly_named_parameters_extra.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters_extra.json"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_readonly_named_parameter_assign_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_readonly_named_parameter_assign_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_readonly_named_parameter_assign_error.err"; then
echo "expected linuxcnc_readonly_named_parameter_assign_error.ngc to fail" >&2
exit 1
fi
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc
# read_parameter_setting() requires '=' after the parameter index, and
# read_real_value() requires a real value after '='.
parameter_setting_error_cases=(
"linuxcnc_parameter_missing_equal_error|Equal sign missing in parameter setting"
"linuxcnc_midline_parameter_missing_equal_error|Equal sign missing in parameter setting"
"linuxcnc_parameter_missing_value_error|No characters found in reading real value"
)
for case in "${parameter_setting_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
# read_parameter(), read_parameter_setting(), read_integer_value(),
# read_name(), and read_real_value() reject malformed parameter indices,
# unterminated named parameters, and missing or malformed real values.
parameter_reader_error_cases=(
"linuxcnc_parameter_number_out_of_range_error|Parameter number out of range"
"linuxcnc_parameter_reference_out_of_range_error|Parameter number out of range"
"linuxcnc_non_integer_parameter_index_error|Non integer value for integer"
"linuxcnc_named_parameter_not_terminated_error|Named parameter not terminated"
"linuxcnc_no_real_value_error|No characters found in reading real value"
"linuxcnc_bad_number_format_error|bad number format (conversion failed) parsing '+'"
)
for case in "${parameter_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_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
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_negative_sqrt_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_negative_sqrt_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_negative_sqrt_error.err"; then
echo "expected linuxcnc_negative_sqrt_error.ngc to fail" >&2
exit 1
fi
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_infinite_expression_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_infinite_expression_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_infinite_expression_error.err"; then
echo "expected linuxcnc_infinite_expression_error.ngc to fail" >&2
exit 1
fi
# Source basis: LinuxCNC src/emc/rs274ngc/interp_execute.cc
# execute_binary1() rejects divide-by-zero and negative base
# non-integer power expression operators.
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_divide_by_zero_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_divide_by_zero_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_divide_by_zero_error.err"; then
echo "expected linuxcnc_divide_by_zero_error.ngc to fail" >&2
exit 1
fi
grep -q "Attempt to divide by zero" \
"$output_dir/cnc_sim_linuxcnc_source_divide_by_zero_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_negative_power_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_negative_power_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_negative_power_error.err"; then
echo "expected linuxcnc_negative_power_error.ngc to fail" >&2
exit 1
fi
grep -q "Attempt to raise negative to non integer power" \
"$output_dir/cnc_sim_linuxcnc_source_negative_power_error.err"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_atan()
# requires ATAN's second argument to start with /[...].
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_atan_missing_slash_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_atan_missing_slash_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_atan_missing_slash_error.err"; then
echo "expected linuxcnc_atan_missing_slash_error.ngc to fail" >&2
exit 1
fi
grep -q "Slash missing after first atan argument" \
"$output_dir/cnc_sim_linuxcnc_source_atan_missing_slash_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_atan_missing_bracket_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_atan_missing_bracket_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_atan_missing_bracket_error.err"; then
echo "expected linuxcnc_atan_missing_bracket_error.ngc to fail" >&2
exit 1
fi
grep -q "Left bracket missing after slash with atan" \
"$output_dir/cnc_sim_linuxcnc_source_atan_missing_bracket_error.err"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc
# read_operation_unary() selects known unary operations, and read_unary()
# requires the operation name to be followed by a left bracket.
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_unary_missing_bracket_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_unary_missing_bracket_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_unary_missing_bracket_error.err"; then
echo "expected linuxcnc_unary_missing_bracket_error.ngc to fail" >&2
exit 1
fi
grep -q "Left bracket missing after unary operation name" \
"$output_dir/cnc_sim_linuxcnc_source_unary_missing_bracket_error.err"
unary_unknown_word_error_cases=(
"linuxcnc_unary_unknown_word_error|Unknown word starting with a"
"linuxcnc_unary_unknown_c_word_error|Unknown word starting with c"
"linuxcnc_unary_unknown_e_word_error|Unknown word starting with e"
"linuxcnc_unary_unknown_f_word_error|Unknown word starting with f"
"linuxcnc_unary_unknown_l_word_error|Unknown word starting with l"
"linuxcnc_unary_unknown_r_word_error|Unknown word starting with r"
"linuxcnc_unary_unknown_s_word_error|Unknown word starting with s"
"linuxcnc_unary_unknown_t_word_error|Unknown word starting with t"
"linuxcnc_unary_unknown_default_word_error|Unknown word where unary operation could be"
"linuxcnc_top_level_bare_unary_error|Unknown word where unary operation could be"
"linuxcnc_midline_bare_unary_error|Unknown word where unary operation could be"
)
for case in "${unary_unknown_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
# read_operation() rejects unknown binary operation names by prefix,
# unknown operation characters, and expressions that reach end-of-line
# before a right bracket.
binary_operation_error_cases=(
"linuxcnc_binary_unknown_a_operation_error|Unknown operation name starting with a"
"linuxcnc_binary_unknown_e_operation_error|Unknown operation name starting with e"
"linuxcnc_binary_unknown_g_operation_error|Unknown operation name starting with g"
"linuxcnc_binary_unknown_l_operation_error|Unknown operation name starting with l"
"linuxcnc_binary_unknown_m_operation_error|Unknown operation name starting with m"
"linuxcnc_binary_unknown_n_operation_error|Unknown operation name starting with n"
"linuxcnc_binary_unknown_o_operation_error|Unknown operation name starting with o"
"linuxcnc_binary_unknown_x_operation_error|Unknown operation name starting with x"
"linuxcnc_binary_unknown_operation_error|Unknown operation"
"linuxcnc_unclosed_expression_error|Unclosed expression"
)
for case in "${binary_operation_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
# read_f()/read_g()/read_h()/read_l()/read_m()/read_s()/read_t()
# reject negative word values before command execution.
negative_word_error_cases=(
"linuxcnc_negative_f_word_error|Negative f word used"
"linuxcnc_negative_g_code_error|Negative g code used"
"linuxcnc_negative_h_word_error|Negative h word used"
"linuxcnc_negative_l_word_error|Negative l word used"
"linuxcnc_negative_m_code_error|Negative m code used"
"linuxcnc_negative_s_word_error|Negative spindle speed used"
"linuxcnc_negative_t_word_error|Negative tool id (tool not found)"
)
for case in "${negative_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
# read_g()/read_m() validate numeric range, known code tables from
# interp_array.cc, and same-modal-group conflicts while filling a block.
gm_reader_error_cases=(
"linuxcnc_g_code_out_of_range_error|G-code out of range"
"linuxcnc_unknown_g_code_error|Unknown g code used"
"linuxcnc_two_g_codes_same_modal_group_error|Two g codes used from same modal group"
"linuxcnc_same_modal_predefined_position_error|Two g codes used from same modal group"
"linuxcnc_same_modal_g52_g92_error|Two g codes used from same modal group"
"linuxcnc_same_modal_g10_g92_error|Two g codes used from same modal group"
"linuxcnc_same_modal_control_mode_error|Two g codes used from same modal group"
"linuxcnc_same_modal_g4_g53_error|Two g codes used from same modal group"
"linuxcnc_same_modal_g921_g922_error|Two g codes used from same modal group"
"linuxcnc_same_modal_threading_motion_error|Two g codes used from same modal group"
"linuxcnc_same_modal_probe_motion_error|Two g codes used from same modal group"
"linuxcnc_m_code_greater_199_error|M-code greater than 199: M200"
"linuxcnc_unknown_m_code_error|Unknown m code used: M13"
"linuxcnc_two_m_codes_same_modal_group_error|Two m codes used from same modal group"
)
for case in "${gm_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_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
# read_dollar() rejects repeated spindle-choice words while filling a block.
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_multiple_spindle_choice_words_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_multiple_spindle_choice_words_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_multiple_spindle_choice_words_error.err"; then
echo "expected linuxcnc_multiple_spindle_choice_words_error.ngc to fail" >&2
exit 1
fi
grep -Fq "Multiple spindle choice (\$) words on one line" \
"$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_check.cc
# check_other_codes() enforces required and disallowed words for G96,
# G33/G33.1, and G76 before motion conversion.
threading_check_error_cases=(
"linuxcnc_g96_missing_s_word_error|S word missing with G96"
"linuxcnc_g33_missing_k_word_error|K word missing with g33/g33.1"
"linuxcnc_g33_f_word_error|F word used with a g33/g33.1"
"linuxcnc_g33_1_missing_k_word_error|K word missing with g33/g33.1"
"linuxcnc_g33_1_f_word_error|F word used with a g33/g33.1"
"linuxcnc_g76_missing_p_word_error|P word missing with G76"
"linuxcnc_g76_missing_i_word_error|I J or K words missing with G76"
"linuxcnc_g76_missing_j_word_error|I J or K words missing with G76"
"linuxcnc_g76_missing_k_word_error|I J or K words missing with G76"
)
for case in "${threading_check_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_convert.cc
# convert_arc(), convert_straight(), and convert_threading_cycle() reject invalid
# feed/spindle state, spindle selectors, rotary-axis motion, and G76 I/J/K
# geometry before issuing arc, straight, or synchronized threading motion.
threading_convert_error_cases=(
"linuxcnc_arc_inverse_time_missing_f_error|F word missing with inverse time arc move"
"linuxcnc_g1_zero_feed_error|Cannot do g1 with zero feed rate"
"linuxcnc_g1_inverse_time_missing_f_error|F word missing with inverse time g1 move"
"linuxcnc_g95_zero_spindle_speed_error|Cannot feed with zero spindle speed in feed per rev mode"
"linuxcnc_g33_stopped_spindle_error|Spindle not turning in G33"
"linuxcnc_g33_1_stopped_spindle_error|Spindle not turning in G33.1"
"linuxcnc_g33_spindle_dollar_out_of_range_error|Invalid spindle (\$) number in G33 move"
"linuxcnc_g33_1_spindle_dollar_out_of_range_error|Invalid spindle (\$) number in G33.1 move"
"linuxcnc_g76_spindle_dollar_out_of_range_error|Invalid D-number in G76 cycle"
"linuxcnc_g76_stopped_spindle_error|Chosen spindle (0) not turning in G76"
"linuxcnc_g76_rotary_axis_error|Cannot move rotary axes with G76"
"linuxcnc_g76_i_zero_error|In G76, I must not be 0"
"linuxcnc_g76_j_zero_error|In G76, J must be greater than 0"
"linuxcnc_g76_k_less_equal_j_error|In G76, K must be greater than J"
)
for case in "${threading_convert_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
# read_items() only consumes a leading N word before item dispatch;
# read_one_item() then uses the default reader table from interp_array.cc
# and rejects unknown item-start characters, including middle-of-line or
# comment-prefixed N/O words, midline O-words, bracket expressions, naked numbers, and
# non-leading ATAN argument slashes. LinuxCNC src/emc/rs274ngc/rs274ngc_pre.cc
# open() only enables percent-file mode when the first nonblank line contains
# only '%', so commented or non-opening percent lines reach read_one_item().
bad_character_error_cases=(
"linuxcnc_bad_character_bang_error|Bad character '!' used"
"linuxcnc_commented_percent_error|Bad character '%' used"
"linuxcnc_mid_program_percent_error|Bad character '%' used"
"linuxcnc_bad_character_middle_n_word_error|Bad character 'n' used"
"linuxcnc_comment_prefixed_n_word_error|Bad character 'n' used"
"linuxcnc_comment_prefixed_spaced_n_word_error|Bad character 'n' used"
"linuxcnc_comment_prefixed_oword_error|Bad character 'o' used"
"linuxcnc_midline_numeric_oword_error|Bad character 'o' used"
"linuxcnc_midline_named_oword_error|Bad character 'o' used"
"linuxcnc_bad_character_top_left_bracket_error|Bad character '[' used"
"linuxcnc_bad_character_top_right_bracket_error|Bad character ']' used"
"linuxcnc_bad_character_midline_left_bracket_error|Bad character '[' used"
"linuxcnc_bad_character_midline_right_bracket_error|Bad character ']' used"
"linuxcnc_bad_character_top_number_error|Bad character '1' used"
"linuxcnc_top_level_bare_atan_error|Bad character '/' used"
"linuxcnc_midline_bare_atan_error|Bad character '/' used"
)
for case in "${bad_character_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_check.cc
# check_m_codes() rejects blocks with more than MAX_EMS M-codes.
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_too_many_m_codes_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_too_many_m_codes_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_too_many_m_codes_error.err"; then
echo "expected linuxcnc_too_many_m_codes_error.ngc to fail" >&2
exit 1
fi
grep -q "Too many m codes on line" \
"$output_dir/cnc_sim_linuxcnc_source_too_many_m_codes_error.err"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc
# the word-specific reader functions reject repeated words while
# filling a single block.
multiple_word_error_cases=(
"linuxcnc_multiple_a_words_error|Multiple a words on one line"
"linuxcnc_multiple_b_words_error|Multiple b words on one line"
"linuxcnc_multiple_c_words_error|Multiple c words on one line"
"linuxcnc_multiple_d_words_error|Multiple d words on one line"
"linuxcnc_multiple_e_words_error|Multiple e words on one line"
"linuxcnc_multiple_f_words_error|Multiple f words on one line"
"linuxcnc_multiple_h_words_error|Multiple h words on one line"
"linuxcnc_multiple_i_words_error|Multiple i words on one line"
"linuxcnc_multiple_j_words_error|Multiple j words on one line"
"linuxcnc_multiple_k_words_error|Multiple k words on one line"
"linuxcnc_multiple_l_words_error|Multiple l words on one line"
"linuxcnc_multiple_p_words_error|Multiple p words on one line"
"linuxcnc_multiple_q_words_error|Multiple q words on one line"
"linuxcnc_multiple_r_words_error|Multiple r words on one line"
"linuxcnc_multiple_s_words_error|Multiple s words on one line"
"linuxcnc_multiple_t_words_error|Multiple t words on one line"
"linuxcnc_multiple_u_words_error|Multiple U words on one line"
"linuxcnc_multiple_v_words_error|Multiple V words on one line"
"linuxcnc_multiple_w_words_error|Multiple W words on one line"
"linuxcnc_multiple_x_words_error|Multiple x words on one line"
"linuxcnc_multiple_y_words_error|Multiple y words on one line"
"linuxcnc_multiple_z_words_error|Multiple z words on one line"
)
for case in "${multiple_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
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_value_returned.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_value_returned.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_call_level.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_call_level.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_exists_word_value.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_exists_word_value.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_lowercase_numeric_oword.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_lowercase_numeric_oword.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_parameter_expression_assignment.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_parameter_expression_assignment.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_operation()
# parses mod, power, logical, and relational operators; interp_execute.cc
# execute_binary1()/execute_binary2() evaluate their precedence and values.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_expression_operators.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_expression_operators.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_word_bracket_whitespace.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_word_bracket_whitespace.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_m98_mixed_styles_variables.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_m98_mixed_styles_variables.json"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_numeric_oword_main_eof_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_numeric_oword_main_eof_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_numeric_oword_main_eof_error.err"; then
echo "expected linuxcnc_numeric_oword_main_eof_error.ngc to fail" >&2
exit 1
fi
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_numeric_oword_sub_illegal_location.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_numeric_oword_sub_illegal_location.json" 2>"$output_dir/cnc_sim_linuxcnc_source_numeric_oword_sub_illegal_location.err"; then
echo "expected linuxcnc_numeric_oword_sub_illegal_location.ngc to fail" >&2
exit 1
fi
# 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_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_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_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 read_text()
# rejects EOF without the matching percent/program end and overlong file
# lines; read_n_number() rejects malformed N-line numbers through
# read_integer_unsigned(); src/emc/rs274ngc/interp_internal.cc
# close_and_downcase() rejects unclosed and nested parenthesis comments.
read_text_error_cases=(
"linuxcnc_file_ended_no_program_end_error|File ended with no percent sign"
"linuxcnc_file_ended_no_percent_error|File ended with no percent sign"
"linuxcnc_bad_n_number_format_error|Bad format unsigned integer"
"linuxcnc_unclosed_comment_error|Unclosed comment found"
"linuxcnc_nested_comment_error|Nested comment found"
)
for case in "${read_text_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
long_line_fixture="$output_dir/linuxcnc_command_too_long_error.ngc"
printf 'G1 X' > "$long_line_fixture"
printf '1%.0s' {1..260} >> "$long_line_fixture"
printf '\n' >> "$long_line_fixture"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" "$long_line_fixture" \
>"$output_dir/cnc_sim_linuxcnc_source_linuxcnc_command_too_long_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_linuxcnc_command_too_long_error.err"; then
echo "expected linuxcnc_command_too_long_error.ngc to fail" >&2
exit 1
fi
grep -q "Command too long" \
"$output_dir/cnc_sim_linuxcnc_source_linuxcnc_command_too_long_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_reject_rotary_followup.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_reject_rotary_followup.json" 2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_reject_rotary_followup.err"; then
echo "expected linuxcnc_canned_cycle_reject_rotary_followup.ngc to fail" >&2
exit 1
fi
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_cutter_comp_tool_change_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_tool_change_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_tool_change_error.err"; then
echo "expected linuxcnc_cutter_comp_tool_change_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot change tools with cutter radius compensation on" \
"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_tool_change_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_cutter_comp_wait_input_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_wait_input_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_wait_input_error.err"; then
echo "expected linuxcnc_cutter_comp_wait_input_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot wait for digital input with cutter radius compensation on" \
"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_wait_input_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_cutter_comp_g71_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_g71_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_g71_error.err"; then
echo "expected linuxcnc_cutter_comp_g71_error.ngc to fail" >&2
exit 1
fi
grep -q "G71.0 cannot be used with cutter compensation enabled" \
"$output_dir/cnc_sim_linuxcnc_source_cutter_comp_g71_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle_g98_retract_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g98_retract_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g98_retract_error.err"; then
echo "expected linuxcnc_canned_cycle_g98_retract_error.ngc to fail" >&2
exit 1
fi
grep -q "Cannot change retract mode with cutter radius compensation on" \
"$output_dir/cnc_sim_linuxcnc_source_canned_cycle_g98_retract_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_nested_subroutine_definition_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_nested_subroutine_definition_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_nested_subroutine_definition_error.err"; then
echo "expected linuxcnc_nested_subroutine_definition_error.ngc to fail" >&2
exit 1
fi
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_ccomp_arcexit_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_ccomp_arcexit_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_ccomp_arcexit_error.err"; then
echo "expected linuxcnc_ccomp_arcexit_error.ngc to fail" >&2
exit 1
fi
grep -q "The move just after exiting cutter compensation mode must be straight, not an arc" \
"$output_dir/cnc_sim_linuxcnc_source_ccomp_arcexit_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_abort_hot_comment.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_abort_hot_comment.json" 2>"$output_dir/cnc_sim_linuxcnc_source_abort_hot_comment.err"; then
echo "expected linuxcnc_abort_hot_comment.ngc to fail" >&2
exit 1
fi
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_ccomp_gouging_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_ccomp_gouging_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_ccomp_gouging_error.err"; then
echo "expected linuxcnc_ccomp_gouging_error.ngc to fail" >&2
exit 1
fi
grep -q "Straight feed in concave corner cannot be reached by the tool without gouging" \
"$output_dir/cnc_sim_linuxcnc_source_ccomp_gouging_error.err"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rotary_probe_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_rotary_probe_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_multi_rotary_probe_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_multi_rotary_probe_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_info_zero_parameter.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_tool_info_zero_parameter.json"
CNC_SIM_TOOL_IN_SPINDLE=1 CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_spindle_tool_info_parameter.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_spindle_tool_info_parameter.json"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_readonly_numbered_parameter_assign_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_readonly_numbered_parameter_assign_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_readonly_numbered_parameter_assign_error.err"; then
echo "expected linuxcnc_readonly_numbered_parameter_assign_error.ngc to fail" >&2
exit 1
fi
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g28_g30_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g28_g30_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rotary_g28_g30_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_rotary_g28_g30_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g92_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g92_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rotary_g92_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_rotary_g92_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g52_g92_numbered_interaction.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g52_g92_numbered_interaction.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g5x_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g5x_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g59_3_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g59_3_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g59_3_rotary_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g59_3_rotary_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g5x_rotary_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g5x_rotary_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g54_rotary_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g54_rotary_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_debug_level_parameter.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_debug_level_parameter.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_m66_result_parameter.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_m66_result_parameter.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_offset_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_tool_offset_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rotary_tool_offset_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_rotary_tool_offset_numbered_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_current_position_numbered_parameters.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_current_position_numbered_parameters.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_persistent_parameters_set.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_persistent_parameters_set.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_persistent_parameters_check.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_persistent_parameters_check.json"
rotary_persistent_var_file="$build_dir/rs274ngc-rotary-persistent.var"
: > "$rotary_persistent_var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$rotary_persistent_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rotary_persistent_parameters_set.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_rotary_persistent_parameters_set.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$rotary_persistent_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rotary_persistent_parameters_check.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_rotary_persistent_parameters_check.json"
g54_persistent_var_file="$build_dir/rs274ngc-g54-persistent.var"
: > "$g54_persistent_var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$g54_persistent_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g54_persistent_parameters_set.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g54_persistent_parameters_set.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$g54_persistent_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g54_persistent_parameters_check.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g54_persistent_parameters_check.json"
empty_var_file="$build_dir/rs274ngc-empty.var"
: > "$empty_var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$empty_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_user_persistent_parameter_set.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_set.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$empty_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_user_persistent_parameter_check.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_check.json"
existing_user_var_file="$build_dir/rs274ngc-existing-user.var"
printf '5001\t17.000000\n' > "$existing_user_var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$existing_user_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_user_persistent_parameter_set.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_user_existing_persistent_parameter_set.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$existing_user_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_user_persistent_parameter_existing_check.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_user_existing_persistent_parameter_check.json"
boundary_user_var_file="$build_dir/rs274ngc-boundary-user.var"
printf '5001\t17.000000\n5030\t18.000000\n5060\t19.000000\n' > "$boundary_user_var_file"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$boundary_user_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_user_persistent_parameter_boundary_set.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_boundary_set.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$boundary_user_var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_user_persistent_parameter_boundary_check.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_boundary_check.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_volatile_global_parameter_set.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_volatile_global_parameter_set.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_volatile_global_parameter_check.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_volatile_global_parameter_check.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_arc_center_tolerance_good_imperial.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_arc_center_tolerance_good_imperial.json"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_arc_center_tolerance_bad_metric.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_arc_center_tolerance_bad_metric.json" 2>"$output_dir/cnc_sim_linuxcnc_source_arc_center_tolerance_bad_metric.err"; then
echo "expected linuxcnc_arc_center_tolerance_bad_metric.ngc to fail" >&2
exit 1
fi
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_extended_plane_arc_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_extended_plane_arc_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_extended_plane_arc_error.err"; then
echo "expected linuxcnc_extended_plane_arc_error.ngc to fail" >&2
exit 1
fi
if ! grep -q "Cannot do an arc in planes G17.1, G18.1, or G19.1" "$output_dir/cnc_sim_linuxcnc_source_extended_plane_arc_error.err"; then
echo "unexpected linuxcnc_extended_plane_arc_error.ngc error" >&2
cat "$output_dir/cnc_sim_linuxcnc_source_extended_plane_arc_error.err" >&2
exit 1
fi
if CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g62_extended_plane_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g62_extended_plane_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_g62_extended_plane_error.err"; then
echo "expected linuxcnc_g62_extended_plane_error.ngc to fail" >&2
exit 1
fi
if ! grep -q "one plane must be selected for nurbs: XY, YZ, ZX" "$output_dir/cnc_sim_linuxcnc_source_g62_extended_plane_error.err"; then
echo "unexpected linuxcnc_g62_extended_plane_error.ngc error" >&2
cat "$output_dir/cnc_sim_linuxcnc_source_g62_extended_plane_error.err" >&2
exit 1
fi
# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc
# convert_nurbs() validates G5.2/G5.3/G6.2 control point, weight, order,
# knot, mode, and feed requirements before issuing NURBS canon output.
nurbs_error_cases=(
"linuxcnc_g52_missing_y_control_point_error|You must specify both X and Y coordinates for Control Points"
"linuxcnc_g52_p_without_xy_after_start_error|Can specify P without X and Y only for the first control point"
"linuxcnc_g52_nonpositive_p_error|Must specify positive weight P for every Control Point"
"linuxcnc_g52_missing_subsequent_weight_error|Must specify positive weight P for every Control Point"
"linuxcnc_g52_noninteger_l_error|Non integer value for integer"
"linuxcnc_g52_zero_feed_error|Cannot make a NURBS with 0 feedrate"
"linuxcnc_g53_without_g52_error|Cannot use G5.3 without G5.2 first"
"linuxcnc_g53_short_control_points_error|You must specify a number of control points at least equal to the order L = 3"
"linuxcnc_g53_after_intervening_motion_error|Cannot use G5.3 without G5.2 first"
"linuxcnc_g62_missing_p_order_error|Program the nurbs order P in the first block of instruction"
"linuxcnc_g62_p_non_integer_error|nurbs order P number is not an integer"
"linuxcnc_g62_missing_q_mode_error|Program the nurbs Q value (1,2,3) in the first block of nurbs instruction"
"linuxcnc_g62_q_out_of_range_error|nurbs Q value not in range 1 to 3"
"linuxcnc_g62_q_non_integer_error|nurbs Q number is not an integer"
"linuxcnc_g62_k_non_integer_error|nurbs K number is not an integer"
"linuxcnc_g62_zero_feed_error|Cannot make a nurbs with 0 feedrate"
)
for case in "${nurbs_error_cases[@]}"; do
fixture=${case%%|*}
expected=${case#*|}
if 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
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g76only.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g76only.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_coordinate_offsets.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_coordinate_offsets.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_coordinate_l20.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_coordinate_l20.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_coordinate_p0.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_coordinate_p0.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_coordinate_select_all.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_coordinate_select_all.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g92_restore.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g92_restore.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g52_offset.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g52_offset.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g52_xz_nurbs.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g52_xz_nurbs.json"
cp "$base_var_file" "$var_file"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g62_xz_nurbs.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_g62_xz_nurbs.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_n_number()
# accepts and ignores the fractional suffix after an N word, preserves leading
# zero line numbers, and has the >99999 range check disabled; execute_block()
# in src/emc/rs274ngc/interp_execute.cc still tags canon output with the
# interpreter sequence number.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_fractional_linenumbers.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_fractional_linenumbers.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_extended_linenumbers.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_extended_linenumbers.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_text()
# calls close_and_downcase() to downcase words and remove spaces/tabs outside
# comments before read_items() dispatches the words.
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_close_and_downcase_words.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_close_and_downcase_words.json"
# Source basis: LinuxCNC src/emc/rs274ngc/rs274ngc_pre.cc open() enables
# percent-file mode when the first nonblank line is '%'; read_text() in
# src/emc/rs274ngc/interp_read.cc returns INTERP_ENDFILE at the matching '%',
# so later lines are ignored.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_percent_file_ignores_trailing.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_percent_file_ignores_trailing.json"
CNC_SIM_RS274_SOURCE_OUTPUT_DIR="$output_dir" python3 - <<'PY'
import json
import os
from pathlib import Path
OUTPUT_DIR = Path(os.environ["CNC_SIM_RS274_SOURCE_OUTPUT_DIR"])
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}
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",
"rapid",
"set-feed",
"linear-feed",
"arc-feed",
"dwell",
"program-end",
}
check_motion("cnc_sim_linuxcnc_source_basic_motion.json", required_motion)
check_motion("cnc_sim_linuxcnc_source_basic_mill.json", required_motion | {"tool-change"})
fractional_linenumbers = load("cnc_sim_linuxcnc_source_fractional_linenumbers.json")
fractional_spindle_states = [
(event["line"], event["spindle"])
for event in fractional_linenumbers
if event["type"] == "set-spindle"
]
if fractional_spindle_states[:3] != [(1, 300), (2, 600), (3, 1200)]:
raise SystemExit(
"unexpected source-linked fractional N-word spindle sequence: "
f"{fractional_spindle_states!r}"
)
extended_linenumbers = load("cnc_sim_linuxcnc_source_extended_linenumbers.json")
extended_spindle_states = [
(event["line"], event["spindle"])
for event in extended_linenumbers
if event["type"] == "set-spindle"
]
if extended_spindle_states[:3] != [(1, 111), (2, 222), (3, 333)]:
raise SystemExit(
"unexpected source-linked extended N-word spindle sequence: "
f"{extended_spindle_states!r}"
)
close_and_downcase_words = load("cnc_sim_linuxcnc_source_close_and_downcase_words.json")
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 3 and
event["end"]["y"] == 4
for event in close_and_downcase_words
):
raise SystemExit("missing source-linked close_and_downcase mixed-case spaced-word move")
percent_file = load("cnc_sim_linuxcnc_source_percent_file_ignores_trailing.json")
percent_file_feeds = [
(event["line"], event["end"]["x"])
for event in percent_file
if event["type"] == "linear-feed"
]
if percent_file_feeds != [(4, 1)]:
raise SystemExit(
"unexpected source-linked percent-file feed sequence: "
f"{percent_file_feeds!r}"
)
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
):
raise SystemExit("expected source-linked disabled block-delete line to execute")
block_delete_on = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_block_delete_on.json").read_text())
if any(
event["type"] == "linear-feed" and event["line"] == 2 and event["end"]["x"] == 5
for event in block_delete_on
):
raise SystemExit("expected source-linked block-delete line to be skipped")
if not any(
event["type"] == "linear-feed" and event["line"] == 3 and event["end"]["x"] == 2
for event in block_delete_on
):
raise SystemExit("expected source-linked block-delete followup line to execute")
controls = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_rtcp_controls.json").read_text())
kin = [event for event in controls if event["type"] == "kinematics-switch"]
if [event["reserved"] for event in kin] != [1, 0, 2]:
raise SystemExit("unexpected source-linked kinematics switch sequence")
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((OUTPUT_DIR / "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")
spindle_modes = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_spindle_modes.json").read_text())
spindle_mode_states = [
(event["line"], event["reserved"], event["feed"], event["tool"])
for event in spindle_modes
if event["type"] == "comment" and event["line"] in {2, 3, 4} and event["reserved"] in {960, 970}
]
expected_spindle_mode_states = [
(2, 970, 0, 0),
(3, 960, 2500, 0),
(4, 970, 0, 0),
]
if spindle_mode_states != expected_spindle_mode_states:
raise SystemExit(f"unexpected source-linked G96/G97 spindle mode states: {spindle_mode_states!r}")
spindle_orient = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_spindle_orient.json").read_text())
if not any(
event["type"] == "comment" and
event["line"] == 2 and
event["reserved"] == 1901 and
event["tool"] == 0 and
event["feed"] == 45 and
event["arcTurns"] == 1
for event in spindle_orient
):
raise SystemExit("missing source-linked M19 spindle orient state")
if not any(
event["type"] == "comment" and
event["line"] == 2 and
event["reserved"] == 1902 and
event["tool"] == 0 and
event["dwellSeconds"] == 2
for event in spindle_orient
):
raise SystemExit("missing source-linked M19 spindle orient wait state")
io_controls = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_io_controls.json").read_text())
io_states = [
(event["line"], event["reserved"], event["tool"], event["feed"], event["arcTurns"], event["dwellSeconds"])
for event in io_controls
if event["type"] == "comment" and event["reserved"] in {62, 63, 64, 65, 66, 67, 68}
]
expected_io_states = [
(2, 62, 1, 1, 0, 0),
(3, 63, 1, 0, 0, 0),
(4, 64, 2, 1, 0, 0),
(5, 65, 2, 0, 0, 0),
(6, 66, 0, 3, 1, 5),
(7, 66, 1, 0, 0, 0),
(8, 67, 0, 1.25, 0, 0),
(9, 68, 1, 2.5, 0, 0),
]
if io_states != expected_io_states:
raise SystemExit(f"unexpected source-linked M62-M68 I/O states: {io_states!r}")
override_controls = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_override_controls.json").read_text())
override_states = [
(event["line"], event["reserved"], event["tool"], event["feed"])
for event in override_controls
if event["type"] == "comment" and event["reserved"] in {50, 51, 52, 53}
]
expected_override_states = [
(2, 50, 0, 1),
(2, 51, 0, 1),
(3, 50, 0, 0),
(3, 51, 0, 0),
(4, 50, 0, 1),
(5, 50, 0, 0),
(6, 51, 0, 1),
(7, 51, 0, 0),
(8, 52, 0, 1),
(9, 52, 0, 0),
(10, 53, 0, 1),
(11, 53, 0, 0),
(12, 50, 0, 1),
]
if override_states != expected_override_states:
raise SystemExit(f"unexpected source-linked M48-M53 override states: {override_states!r}")
control_mode_tolerances = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_control_mode_tolerances.json").read_text())
control_mode_tolerance_states = [
(event["line"], event["reserved"], event["feed"])
for event in control_mode_tolerances
if event["type"] == "comment" and event["reserved"] in {611, 612, 640, 641}
]
expected_control_mode_tolerance_states = [
(2, 640, 0.05),
(2, 641, 0.02),
(3, 640, 0.03),
(3, 641, 0.03),
(4, 611, 0),
(5, 612, 0),
]
if control_mode_tolerance_states != expected_control_mode_tolerance_states:
raise SystemExit(f"unexpected source-linked G64 P/Q control mode tolerance states: {control_mode_tolerance_states!r}")
modal_state = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_modal_state.json").read_text())
if not any(
event["type"] == "rapid" and
event["line"] == 7 and
event["end"]["x"] == 2 and
event["end"]["y"] == 0 and
event["end"]["z"] == 2
for event in modal_state
):
raise SystemExit("missing source-linked M72 restored absolute millimeter move")
if not any(
event["type"] == "arc-feed" and
event["line"] == 8 and
event["plane"] == 17 and
event["end"]["x"] == 4 and
event["end"]["y"] == 0
for event in modal_state
):
raise SystemExit("missing source-linked M72 restored XY plane arc")
modal_autorestore = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_modal_autorestore.json").read_text())
if not any(
event["type"] == "rapid" and
event["line"] == 9 and
event["end"]["x"] == 10
for event in modal_autorestore
):
raise SystemExit("missing source-linked M73 subroutine changed modal state move")
if not any(
event["type"] == "rapid" and
event["line"] == 4 and
event["start"]["x"] == 10 and
event["end"]["x"] == 12
for event in modal_autorestore
):
raise SystemExit("missing source-linked M73 autorestored incremental caller move")
threading_sync = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_threading_sync.json").read_text())
sync_states = [
(event["line"], event["reserved"], event["feed"], event["tool"])
for event in threading_sync
if event["type"] == "comment" and event["reserved"] in {3300, 3301, 3302}
]
expected_sync_states = [
(4, 3301, 1, 0),
(4, 3300, 0, 0),
(6, 3301, 1, 0),
(6, 3300, 0, 0),
]
if sync_states != expected_sync_states:
raise SystemExit(f"unexpected source-linked G33/G33.1 sync states: {sync_states!r}")
if not any(
event["type"] == "linear-feed" and event["line"] == 6 and event["end"]["z"] == 0
for event in threading_sync
):
raise SystemExit("missing source-linked G33.1 rigid tap motion line")
threading_cycle = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_threading_cycle.json").read_text())
if not any(
event["type"] == "comment" and
event["line"] == 4 and
event["reserved"] == 3301 and
event["feed"] == 0.05
for event in threading_cycle
):
raise SystemExit("missing source-linked G76 threading sync start")
if not any(event["type"] == "comment" and event["line"] == 4 and event["reserved"] == 3300 for event in threading_cycle):
raise SystemExit("missing source-linked G76 threading sync stop")
if not any(
event["type"] == "linear-feed" and event["line"] == 4 and event["end"]["z"] == -1
for event in threading_cycle
):
raise SystemExit("missing source-linked G76 final threading pass")
if not any(event["type"] == "program-end" and event["line"] == 5 for event in threading_cycle):
raise SystemExit("missing source-linked G76 program end line number")
lathe_diameter_mode = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_lathe_diameter_mode.json").read_text())
lathe_feeds = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in lathe_diameter_mode
if event["type"] == "linear-feed"
]
expected_lathe_feeds = [
(3, 5, 0),
(5, 5, 1),
(7, 6, 1),
(9, 6, 2),
]
if lathe_feeds != expected_lathe_feeds:
raise SystemExit(f"unexpected source-linked G7/G8 lathe diameter-mode feeds: {lathe_feeds!r}")
lathe_g76 = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_lathe_diameter_g76.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
abs(event["end"]["x"] - 0.98125) < 1e-9 and
event["end"]["z"] == -1
for event in lathe_g76
):
raise SystemExit("missing source-linked G7 diameter-mode G76 final threading pass")
if not any(
event["type"] == "comment" and
event["line"] == 4 and
event["reserved"] == 3301 and
abs(event["feed"] - 0.0515388) < 1e-7
for event in lathe_g76
):
raise SystemExit("missing source-linked G7 diameter-mode G76 taper sync pitch")
tool_number = json.loads((OUTPUT_DIR / "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((OUTPUT_DIR / "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}")
for output_name, label in [
("cnc_sim_linuxcnc_source_program_end_m2.json", "M2"),
("cnc_sim_linuxcnc_source_program_end_m99.json", "M99"),
]:
events = load(output_name)
line4 = [event for event in events if event["line"] == 4]
line4_types = {event["type"] for event in line4}
for expected_type in {"set-g5x-offset", "set-xy-rotation", "set-feed", "set-spindle", "program-end"}:
if expected_type not in line4_types:
raise SystemExit(f"missing source-linked {label} reset event {expected_type}")
program_end_states = [
event["reserved"]
for event in line4
if event["type"] == "program-end"
]
if program_end_states != [0]:
raise SystemExit(f"unexpected source-linked {label} program-end states: {program_end_states!r}")
if any(event["type"] == "program-end" and event["reserved"] == 3 for event in line4):
raise SystemExit(f"unexpected source-linked {label} pallet shuttle event")
g4_boundaries = load("cnc_sim_linuxcnc_source_g4_dwell_boundaries.json")
g4_dwell_states = [
(event["line"], event["dwellSeconds"])
for event in g4_boundaries
if event["type"] == "dwell"
]
expected_g4_dwell_states = [(4, -1.001), (5, -0.9999), (6, 3)]
if g4_dwell_states != expected_g4_dwell_states:
raise SystemExit(f"unexpected source-linked G4 dwell boundary states: {g4_dwell_states!r}")
coolant = json.loads((OUTPUT_DIR / "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((OUTPUT_DIR / "cnc_sim_linuxcnc_source_feed_modes.json").read_text())
feed_mode_comments = [
(event["line"], event["reserved"])
for event in feed_modes
if event["type"] == "comment"
]
for expected in [(2, 93), (3, 94), (4, 95)]:
if expected not in feed_mode_comments:
raise SystemExit(f"missing source-linked feed mode comment state {expected!r}")
feed_mode_events = [
(event["line"], event["reserved"])
for event in feed_modes
if event["type"] == "set-feed"
]
for expected in [(3, 0), (4, 0)]:
if expected not in feed_mode_events:
raise SystemExit(f"missing source-linked feed mode event {expected!r}")
motion_modes = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_motion_modes.json").read_text())
motion_mode_states = [
(event["line"], event["reserved"], event["feed"])
for event in motion_modes
if event["type"] == "comment"
]
for expected in [(2, 611, 0), (3, 612, 0), (4, 640, 0.05)]:
if expected not in motion_mode_states:
raise SystemExit(f"missing source-linked motion mode state {expected!r}")
tool_length = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_tool_length.json").read_text())
if not any(
event["type"] == "comment" and
event["line"] == 2 and
event["reserved"] == 430 and
event["start"]["z"] == 12.5
for event in tool_length
):
raise SystemExit("missing source-linked G43 H1 tool length offset event")
if not any(
event["type"] == "comment" and
event["line"] == 3 and
event["reserved"] == 430 and
event["start"]["z"] == 0
for event in tool_length
):
raise SystemExit("missing source-linked G49 tool length clear event")
dynamic_tool_length = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_dynamic_tool_length.json").read_text())
dynamic_offsets = [
(event["line"], event["start"]["x"], event["start"]["z"])
for event in dynamic_tool_length
if event["type"] == "comment" and event["reserved"] == 430
]
expected_dynamic_offsets = [(2, 1, 2), (3, 1.25, 2.5), (4, 1.25, 15), (5, 0, 0)]
if dynamic_offsets != expected_dynamic_offsets:
raise SystemExit(f"unexpected source-linked G43.1/G43.2 tool length offsets: {dynamic_offsets!r}")
cycle = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_canned_cycle.json").read_text())
motions = [event for event in cycle if event["type"] in {"rapid", "linear-feed"}]
expected_cycle = [
("rapid", 0, 0, 5),
("rapid", 20, 0, 5),
("rapid", 20, 0, 3),
("linear-feed", 20, 0, -2),
("rapid", 20, 0, 3),
]
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}")
cycle_planes = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_canned_cycle_planes.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1 and
event["end"]["y"] == -2 and
event["end"]["z"] == 4
for event in cycle_planes
):
raise SystemExit("missing source-linked G18 G81 feed along Y depth axis")
if not any(
event["type"] == "rapid" and
event["line"] == 4 and
event["end"]["x"] == 1 and
event["end"]["y"] == 3 and
event["end"]["z"] == 4
for event in cycle_planes
):
raise SystemExit("missing source-linked G18 G81 retract to Y R plane")
if not any(
event["type"] == "linear-feed" and
event["line"] == 7 and
event["end"]["x"] == -2 and
event["end"]["y"] == 3 and
event["end"]["z"] == 4
for event in cycle_planes
):
raise SystemExit("missing source-linked G19 G82 feed along X depth axis")
if not any(
event["type"] == "dwell" and
event["line"] == 7 and
event["dwellSeconds"] == 0.2
for event in cycle_planes
):
raise SystemExit("missing source-linked G19 G82 dwell at bottom")
if not any(
event["type"] == "rapid" and
event["line"] == 7 and
event["end"]["x"] == 2 and
event["end"]["y"] == 3 and
event["end"]["z"] == 4
for event in cycle_planes
):
raise SystemExit("missing source-linked G19 G82 retract to X R plane")
def plane_cycle_signature(event):
if event["type"] in {"rapid", "linear-feed"}:
return (event["type"], event["end"]["x"], event["end"]["y"], event["end"]["z"])
if event["type"] == "set-spindle":
return ("set-spindle", event["spindle"], event["reserved"])
if event["type"] == "dwell":
return ("dwell", event["dwellSeconds"])
if event["type"] == "program-end":
return ("program-end", event["reserved"])
return None
plane_g84_sequence = [
plane_cycle_signature(event)
for event in cycle_planes
if event["line"] == 11 and event["type"] in {"rapid", "linear-feed", "set-spindle", "dwell"}
]
expected_plane_g84_sequence = [
("rapid", 1, 5, 4),
("rapid", 1, 3, 4),
("linear-feed", -2, 4, 1),
("set-spindle", 0, 0),
("set-spindle", 600, 2),
("dwell", 0.05),
("linear-feed", 3, 4, 1),
("set-spindle", 0, 0),
("set-spindle", 600, 1),
]
if plane_g84_sequence != expected_plane_g84_sequence:
raise SystemExit(f"unexpected source-linked G18 G84 plane sequence: {plane_g84_sequence!r}")
plane_g74_sequence = [
plane_cycle_signature(event)
for event in cycle_planes
if event["line"] == 15 and event["type"] in {"rapid", "linear-feed", "set-spindle", "dwell"}
]
expected_plane_g74_sequence = [
("rapid", 5, 3, 4),
("rapid", 2, 3, 4),
("linear-feed", 4, -2, 3),
("set-spindle", 0, 0),
("set-spindle", 500, 1),
("dwell", 0.04),
("linear-feed", 4, 2, 3),
("set-spindle", 0, 0),
("set-spindle", 500, 2),
]
if plane_g74_sequence != expected_plane_g74_sequence:
raise SystemExit(f"unexpected source-linked G19 G74 plane sequence: {plane_g74_sequence!r}")
plane_g86_sequence = [
plane_cycle_signature(event)
for event in cycle_planes
if event["line"] == 19 and event["type"] in {"rapid", "linear-feed", "set-spindle", "dwell"}
]
expected_plane_g86_sequence = [
("rapid", 1, 5, 4),
("rapid", 1, 3, 4),
("linear-feed", 1, -2, 4),
("dwell", 0.1),
("set-spindle", 0, 0),
("rapid", 1, 3, 4),
("set-spindle", 900, 1),
]
if plane_g86_sequence != expected_plane_g86_sequence:
raise SystemExit(f"unexpected source-linked G18 G86 plane sequence: {plane_g86_sequence!r}")
plane_g88_sequence = [
plane_cycle_signature(event)
for event in cycle_planes
if event["line"] == 23 and event["type"] in {"rapid", "linear-feed", "set-spindle", "dwell", "program-end"}
]
expected_plane_g88_sequence = [
("rapid", 5, 3, 4),
("rapid", 2, 3, 4),
("linear-feed", -2, 3, 4),
("dwell", 0.07),
("set-spindle", 0, 0),
("program-end", 1),
("set-spindle", 700, 1),
]
if plane_g88_sequence != expected_plane_g88_sequence:
raise SystemExit(f"unexpected source-linked G19 G88 plane sequence: {plane_g88_sequence!r}")
plane_g87_sequence = [
plane_cycle_signature(event)
for event in cycle_planes
if event["line"] == 27 and event["type"] in {"rapid", "linear-feed", "set-spindle"}
]
expected_plane_g87_sequence = [
("rapid", 5, 1, 2),
("rapid", 2, 1, 2),
("rapid", 2, 1.2, 2.3),
("set-spindle", 0, 0),
("rapid", -4, 1.2, 2.3),
("rapid", -4, 1, 2),
("set-spindle", 800, 1),
("linear-feed", -2, 1, 2),
("linear-feed", -4, 1, 2),
("set-spindle", 0, 0),
("rapid", -4, 1.2, 2.3),
("rapid", 2, 1.2, 2.3),
("rapid", 2, 1, 2),
("set-spindle", 800, 1),
]
if plane_g87_sequence != expected_plane_g87_sequence:
raise SystemExit(f"unexpected source-linked G19 G87 plane sequence: {plane_g87_sequence!r}")
extended_plane_cycle = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_extended_plane_cycle.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["u"] == 1 and
event["end"]["v"] == 2 and
event["end"]["w"] == -1
for event in extended_plane_cycle
):
raise SystemExit("missing source-linked G17.1 G81 feed along W depth axis")
if not any(
event["type"] == "rapid" and
event["line"] == 3 and
event["end"]["u"] == 1 and
event["end"]["v"] == 2 and
event["end"]["w"] == 1
for event in extended_plane_cycle
):
raise SystemExit("missing source-linked G17.1 G81 retract to W R plane")
if not any(
event["type"] == "set-plane" and event["line"] == 7 and event["plane"] == 171
for event in extended_plane_cycle
):
raise SystemExit("missing source-linked cutter-comp-active G17.1 plane selection")
extended_cycle = json.loads((OUTPUT_DIR / "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")
def g84_signature(event):
if event["type"] == "linear-feed":
return ("linear-feed", event["end"]["x"], event["end"]["z"])
if event["type"] == "set-spindle":
return ("set-spindle", event["spindle"], event["reserved"])
if event["type"] == "dwell":
return ("dwell", event["dwellSeconds"])
if event["type"] == "program-end":
return ("program-end", event["reserved"])
return None
g84_sequence = [
g84_signature(event)
for event in extended_cycle
if event["line"] == 7 and event["type"] in {"linear-feed", "set-spindle", "dwell"}
]
expected_g84_sequence = [
("linear-feed", 30, -2),
("set-spindle", 0, 0),
("set-spindle", 600, 2),
("dwell", 0.05),
("linear-feed", 30, 2),
("set-spindle", 0, 0),
("set-spindle", 600, 1),
]
if g84_sequence != expected_g84_sequence:
raise SystemExit(f"unexpected source-linked G84 tapping sequence: {g84_sequence!r}")
g74_sequence = [
g84_signature(event)
for event in extended_cycle
if event["line"] == 9 and event["type"] in {"linear-feed", "set-spindle", "dwell"}
]
expected_g74_sequence = [
("linear-feed", 40, -2),
("set-spindle", 0, 0),
("set-spindle", 500, 1),
("dwell", 0.04),
("linear-feed", 40, 2),
("set-spindle", 0, 0),
("set-spindle", 500, 2),
]
if g74_sequence != expected_g74_sequence:
raise SystemExit(f"unexpected source-linked G74 tapping sequence: {g74_sequence!r}")
g88_sequence = [
g84_signature(event)
for event in extended_cycle
if event["line"] == 11 and event["type"] in {"linear-feed", "set-spindle", "dwell", "program-end"}
]
expected_g88_sequence = [
("linear-feed", 50, -2),
("dwell", 0.07),
("set-spindle", 0, 0),
("program-end", 1),
("set-spindle", 700, 1),
]
if g88_sequence != expected_g88_sequence:
raise SystemExit(f"unexpected source-linked G88 manual-out sequence: {g88_sequence!r}")
if any(
event["type"] == "rapid" and
event["line"] == 11 and
event["start"]["x"] == 50 and
event["start"]["z"] == -2 and
event["end"]["x"] == 50 and
event["end"]["z"] == 2
for event in extended_cycle
):
raise SystemExit("unexpected source-linked G88 automatic retract")
def g87_signature(event):
if event["type"] in {"rapid", "linear-feed"}:
return (event["type"], event["end"]["x"], event["end"]["y"], event["end"]["z"])
if event["type"] == "set-spindle":
return ("set-spindle", event["spindle"], event["reserved"])
return None
g87_sequence = [
g87_signature(event)
for event in extended_cycle
if event["line"] == 14 and event["type"] in {"rapid", "linear-feed", "set-spindle"}
]
expected_g87_sequence = [
("rapid", 60, 0, 5),
("rapid", 60, 0, 2),
("rapid", 60.2, 0.3, 2),
("set-spindle", 0, 0),
("rapid", 60.2, 0.3, -4),
("rapid", 60, 0, -4),
("set-spindle", 800, 1),
("linear-feed", 60, 0, -2),
("linear-feed", 60, 0, -4),
("set-spindle", 0, 0),
("rapid", 60.2, 0.3, -4),
("rapid", 60.2, 0.3, 2),
("rapid", 60, 0, 2),
("set-spindle", 800, 1),
]
if g87_sequence != expected_g87_sequence:
raise SystemExit(f"unexpected source-linked G87 back-boring sequence: {g87_sequence!r}")
g73_feed_depths = [
event["end"]["z"]
for event in extended_cycle
if event["type"] == "linear-feed" and event["line"] == 15
]
if g73_feed_depths != [1, 0, -1, -2, -3]:
raise SystemExit(f"unexpected source-linked G73 peck depths: {g73_feed_depths!r}")
g73_rapid_depths = [
event["end"]["z"]
for event in extended_cycle
if event["type"] == "rapid" and event["line"] == 15 and event["end"]["x"] == 70
]
if g73_rapid_depths != [2, 2, 1, 0, -1, 2]:
raise SystemExit(f"unexpected source-linked G73 short-retract depths: {g73_rapid_depths!r}")
g85_sequence = [
g84_signature(event)
for event in extended_cycle
if event["line"] == 16 and event["type"] == "linear-feed"
]
expected_g85_sequence = [
("linear-feed", 80, -2),
("linear-feed", 80, 2),
]
if g85_sequence != expected_g85_sequence:
raise SystemExit(f"unexpected source-linked G85 feed-out sequence: {g85_sequence!r}")
g86_sequence = [
g84_signature(event)
for event in extended_cycle
if event["line"] == 17 and event["type"] in {"linear-feed", "set-spindle", "dwell"}
]
expected_g86_sequence = [
("linear-feed", 90, -2),
("dwell", 0.06),
("set-spindle", 0, 0),
("set-spindle", 800, 1),
]
if g86_sequence != expected_g86_sequence:
raise SystemExit(f"unexpected source-linked G86 stop/restart sequence: {g86_sequence!r}")
if not any(
event["type"] == "rapid" and event["line"] == 17 and event["end"]["x"] == 90 and event["end"]["z"] == 2
for event in extended_cycle
):
raise SystemExit("missing source-linked G86 rapid retract")
g89_sequence = [
g84_signature(event)
for event in extended_cycle
if event["line"] == 18 and event["type"] in {"linear-feed", "dwell"}
]
expected_g89_sequence = [
("linear-feed", 100, -2),
("dwell", 0.08),
("linear-feed", 100, 2),
]
if g89_sequence != expected_g89_sequence:
raise SystemExit(f"unexpected source-linked G89 dwell/feed-out sequence: {g89_sequence!r}")
arc_planes = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_arc_planes.json").read_text())
if not any(
event["type"] == "arc-feed" and
event["line"] == 5 and
event["plane"] == 18 and
event["start"]["x"] == 0 and
event["start"]["z"] == 0 and
event["end"]["x"] == 10 and
event["end"]["z"] == 0 and
event["center"]["x"] == 5 and
event["center"]["z"] == 0 and
event["arcTurns"] == -1
for event in arc_planes
):
raise SystemExit("missing source-linked G18 XZ plane arc-feed mapping")
if not any(
event["type"] == "arc-feed" and
event["line"] == 8 and
event["plane"] == 19 and
event["start"]["y"] == 0 and
event["start"]["z"] == 0 and
event["end"]["y"] == 10 and
event["end"]["z"] == 0 and
event["center"]["y"] == 5 and
event["center"]["z"] == 0 and
event["arcTurns"] == 1
for event in arc_planes
):
raise SystemExit("missing source-linked G19 YZ plane arc-feed mapping")
arc_distance = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_arc_distance_modes.json").read_text())
arc_centers = [
(event["line"], event["center"]["x"], event["center"]["y"])
for event in arc_distance
if event["type"] == "arc-feed"
]
expected_arc_centers = [(5, 5, 0), (7, 15, 0), (9, 25, 0)]
if arc_centers != expected_arc_centers:
raise SystemExit(f"unexpected source-linked G90.1/G91.1 arc centers: {arc_centers!r}")
incremental_r_arc = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_incremental_and_r_arc.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["start"]["x"] == 0 and
event["end"]["x"] == 10
for event in incremental_r_arc
):
raise SystemExit("missing source-linked G91 incremental X feed move")
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["start"]["y"] == 0 and
event["end"]["y"] == 10
for event in incremental_r_arc
):
raise SystemExit("missing source-linked modal incremental Y feed move")
if not any(
event["type"] == "arc-feed" and
event["line"] == 7 and
event["start"]["x"] == 10 and
event["start"]["y"] == 10 and
event["end"]["x"] == 20 and
event["end"]["y"] == 10 and
event["center"]["x"] == 15 and
event["center"]["y"] == 10 and
event["arcTurns"] == -1
for event in incremental_r_arc
):
raise SystemExit("missing source-linked absolute R-format clockwise arc")
polar_coordinates = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_polar_coordinates.json").read_text())
polar_linear_events = [
event
for event in polar_coordinates
if event["type"] == "linear-feed"
]
expected_polar_linear_ends = [(3, 10, 0), (4, 0, 10)]
if len(polar_linear_events) != len(expected_polar_linear_ends) or any(
event["line"] != line or
abs(event["end"]["x"] - x) > 1e-9 or
abs(event["end"]["y"] - y) > 1e-9
for event, (line, x, y) in zip(polar_linear_events, expected_polar_linear_ends)
):
polar_linear_ends = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in polar_linear_events
]
raise SystemExit(f"unexpected source-linked polar-coordinate endpoints: {polar_linear_ends!r}")
polar_coordinate_variants = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_polar_coordinate_variants.json").read_text())
polar_variant_linear_events = [
event
for event in polar_coordinate_variants
if event["type"] == "linear-feed"
]
expected_polar_variant_ends = [(3, 6, 8), (4, 10, 0), (6, 15, 0), (7, 0, 15)]
if len(polar_variant_linear_events) != len(expected_polar_variant_ends) or any(
event["line"] != line or
abs(event["end"]["x"] - x) > 1e-9 or
abs(event["end"]["y"] - y) > 1e-9
for event, (line, x, y) in zip(polar_variant_linear_events, expected_polar_variant_ends)
):
polar_variant_linear_ends = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in polar_variant_linear_events
]
raise SystemExit(f"unexpected source-linked polar-coordinate variant endpoints: {polar_variant_linear_ends!r}")
predefined = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_predefined_positions.json").read_text())
predefined_rapids = [
(
event["line"],
event["start"]["x"], event["start"]["y"], event["start"]["z"],
event["end"]["x"], event["end"]["y"], event["end"]["z"],
)
for event in predefined
if event["type"] == "rapid" and event["line"] in {5, 9}
]
expected_predefined_rapids = [
(5, 10, 20, 30, 10, 20, 5),
(5, 10, 20, 5, 10, 20, 3),
(9, 40, 50, 60, 40, 50, 60),
(9, 40, 50, 60, 4, 5, 6),
]
if predefined_rapids != expected_predefined_rapids:
raise SystemExit(f"unexpected source-linked G28/G30 rapid sequence: {predefined_rapids!r}")
machine_coords = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_machine_coordinates.json").read_text())
machine_moves = [
(
event["type"], event["line"],
event["start"]["x"], event["start"]["y"], event["start"]["z"],
event["end"]["x"], event["end"]["y"], event["end"]["z"],
)
for event in machine_coords
if event["type"] in {"rapid", "linear-feed"} and event["line"] in {3, 4, 6}
]
expected_machine_moves = [
("rapid", 3, 5, 6, 7, 0, 6, 1),
("rapid", 4, 0, 6, 1, 2, 6, 1),
("linear-feed", 6, 2, 6, 1, 2, 3, 1),
]
if machine_moves != expected_machine_moves:
raise SystemExit(f"unexpected source-linked G53 machine-coordinate moves: {machine_moves!r}")
cutter_comp = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_cutter_comp.json").read_text())
cutter_comp_motions = [
event
for event in cutter_comp
if event["type"] in {"rapid", "linear-feed", "arc-feed"}
]
expected_cutter_comp = [
("rapid", 2, 0, 0),
("linear-feed", 6, 17, 3),
("linear-feed", 7, 17, 20),
("linear-feed", 8, 0, 0),
("linear-feed", 11, 17, -3),
("linear-feed", 12, 17, -20),
("linear-feed", 13, 0, 0),
("linear-feed", 16, 17, 3),
("linear-feed", 17, 17, 20),
("linear-feed", 18, 0, 0),
("linear-feed", 21, 17, -3),
("linear-feed", 22, 17, -20),
("linear-feed", 23, 0, 0),
]
actual_cutter_comp = [
(event["type"], event["line"], event["end"]["x"], event["end"]["y"])
for event in cutter_comp_motions
]
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"])
for event in probe
if event["type"] == "probe"
]
expected_probe_events = [
(4, 0, 5, 4),
(6, 1, 5, 3),
(8, 2, 5, 2),
(10, 3, 5, 1),
(12, 1, 5, 0),
]
if probe_events != expected_probe_events:
raise SystemExit(f"unexpected source-linked G38 probe variants: {probe_events!r}")
if any(event["type"] == "linear-feed" and event["line"] in {4, 6, 8, 10, 12} for event in probe):
raise SystemExit("source-linked G38 probe moves should not be emitted as linear-feed")
if not any(
event["type"] == "linear-feed" and
event["line"] == 14 and
event["end"]["x"] == 1
for event in probe
):
raise SystemExit("missing source-linked #5070 probe-tripped conditional motion")
oword = json.loads((OUTPUT_DIR / "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")
m98_subprogram = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_m98_subprogram.json").read_text())
m98_sub_moves = [
(event["line"], event["start"]["x"], event["end"]["x"])
for event in m98_subprogram
if event["type"] == "linear-feed" and event["line"] == 8
]
if m98_sub_moves != [(8, 0, 5), (8, 5, 10)]:
raise SystemExit(f"unexpected source-linked M98 repeated subprogram moves: {m98_sub_moves!r}")
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["start"]["x"] == 10 and
event["end"]["x"] == 20
for event in m98_subprogram
):
raise SystemExit("missing source-linked M98 return-to-caller motion")
named_oword = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_named_oword_subprogram.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 9 and
event["start"]["x"] == 0 and
event["end"]["x"] == 10
for event in named_oword
):
raise SystemExit("missing source-linked named O-word expression motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 10 and
event["start"]["y"] == 0 and
event["end"]["y"] == 6
for event in named_oword
):
raise SystemExit("missing source-linked named O-word #2 argument motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["start"]["x"] == 10 and
event["end"]["x"] == 20
for event in named_oword
):
raise SystemExit("missing source-linked named O-word return-to-caller motion")
if any(
event["type"] == "linear-feed" and
event["line"] == 12 and
event["end"]["x"] == 99
for event in named_oword
):
raise SystemExit("source-linked named O-word return should skip remaining subprogram body")
oword_flow = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_oword_control_flow.json").read_text())
if not any(event["type"] == "linear-feed" and event["line"] == 7 and event["end"]["x"] == 2 for event in oword_flow):
raise SystemExit("missing source-linked O-word elseif branch motion")
if any(
event["type"] == "linear-feed" and event["line"] in {5, 9} and event["end"]["x"] in {98, 99}
for event in oword_flow
):
raise SystemExit("source-linked O-word conditional should skip inactive branches")
while_values = [
event["end"]["y"]
for event in oword_flow
if event["type"] == "linear-feed" and event["line"] == 13
]
if while_values != [0, 1, 2]:
raise SystemExit(f"unexpected source-linked O-word while values: {while_values!r}")
repeat_values = [
event["end"]["z"]
for event in oword_flow
if event["type"] == "linear-feed" and event["line"] == 19
]
if repeat_values != [1, 2, 3]:
raise SystemExit(f"unexpected source-linked O-word repeat values: {repeat_values!r}")
do_values = [
event["end"]["a"]
for event in oword_flow
if event["type"] == "linear-feed" and event["line"] == 24
]
if do_values != [1, 2, 3]:
raise SystemExit(f"unexpected source-linked O-word do/while values: {do_values!r}")
break_values = [
event["end"]["b"]
for event in oword_flow
if event["type"] == "linear-feed" and event["line"] == 32
]
if break_values != [1]:
raise SystemExit(f"unexpected source-linked O-word do/break body values: {break_values!r}")
if not any(
event["type"] == "linear-feed" and
event["line"] == 34 and
event["end"]["c"] == 2
for event in oword_flow
):
raise SystemExit("missing source-linked O-word do/break final loop counter motion")
continue_values = [
event["end"]["u"]
for event in oword_flow
if event["type"] == "linear-feed" and event["line"] == 43
]
if continue_values != [2, 3]:
raise SystemExit(f"unexpected source-linked O-word do/continue body values: {continue_values!r}")
if not any(
event["type"] == "linear-feed" and
event["line"] == 45 and
event["end"]["v"] == 3
for event in oword_flow
):
raise SystemExit("missing source-linked O-word do/continue final loop counter motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 46 and
event["end"]["w"] == 2
for event in oword_flow
):
raise SystemExit("missing source-linked O-word do/continue skipped-body counter motion")
exists = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_named_parameter_exists.json").read_text())
exists_moves = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in exists
if event["type"] == "linear-feed"
]
expected_exists_moves = [(5, 1, 0), (8, 1, 1)]
if exists_moves != expected_exists_moves:
raise SystemExit(f"unexpected source-linked EXISTS named parameter branch motions: {exists_moves!r}")
indexed = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_indexed_parameters.json").read_text())
indexed_moves = [
(
event["line"],
event["end"]["x"], event["end"]["y"], event["end"]["z"],
event["end"]["a"], event["end"]["b"], event["end"]["c"],
event["end"]["u"], event["end"]["v"], event["end"]["w"],
)
for event in indexed
if event["type"] == "linear-feed"
]
expected_indexed_moves = [
(7, 17, 0, 0, 0, 0, 0, 0, 0, 0),
(8, 17, 22, 0, 0, 0, 0, 0, 0, 0),
(10, 17, 22, 1, 0, 0, 0, 0, 0, 0),
(13, 17, 22, 1, 21, 0, 0, 0, 0, 0),
(14, 17, 22, 1, 21, 9, 0, 0, 0, 0),
(16, 17, 22, 1, 21, 9, 9, 2, 0, 0),
(17, 17, 22, 1, 21, 9, 9, 2, 4, 9),
(18, 4, 22, 1, 21, 9, 9, 2, 4, 9),
(19, 4, 12, 4, 21, 9, 9, 2, 4, 9),
(20, 4, 12, 4, 12, 9, 9, 2, 4, 9),
(21, 4, 12, 4, 12, 14, 9, 2, 4, 9),
]
if indexed_moves != expected_indexed_moves:
raise SystemExit(f"unexpected source-linked indexed/indirect parameter motions: {indexed_moves!r}")
normalized = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_named_parameter_normalization.json").read_text())
normalized_moves = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in normalized
if event["type"] == "linear-feed"
]
expected_normalized_moves = [(4, 12, 0), (6, 12, 1)]
if normalized_moves != expected_normalized_moves:
raise SystemExit(f"unexpected source-linked normalized named parameter motions: {normalized_moves!r}")
ini_named = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_ini_named_parameter.json").read_text())
ini_named_moves = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in ini_named
if event["type"] == "linear-feed"
]
expected_ini_named_moves = [(3, 3.25, 0), (5, 3.25, 1)]
if ini_named_moves != expected_ini_named_moves:
raise SystemExit(f"unexpected source-linked INI named parameter motions: {ini_named_moves!r}")
readonly_common = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_readonly_named_parameters.json").read_text())
readonly_common_moves = [
(event["line"], event["end"]["x"], event["end"]["y"], event["end"]["z"])
for event in readonly_common
if event["type"] == "linear-feed"
]
expected_readonly_common_moves = [
(4, 1, 0, 0),
(8, 0.0393701, 1, 0),
(12, 1, 25.4, 1),
(16, 2, 25.4, 1),
(22, 2, 3, 1),
(25, 2, 3, 2),
]
if readonly_common_moves != expected_readonly_common_moves:
raise SystemExit(f"unexpected source-linked readonly named parameter motions: {readonly_common_moves!r}")
readonly_named = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_readonly_named_parameters_extra.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1
for event in readonly_named
):
raise SystemExit("missing source-linked #<_spindle_rpm_mode> / #<_spindle_css_mode> G97 branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 8 and
event["end"]["y"] == 1
for event in readonly_named
):
raise SystemExit("missing source-linked #<_ccomp> left-compensation branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 13 and
event["end"]["x"] == 2
for event in readonly_named
):
raise SystemExit("missing source-linked #<_ccomp> right-compensation branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 18 and
event["end"]["a"] == 1
for event in readonly_named
):
raise SystemExit("missing source-linked #<_spindle_rpm_mode> / #<_spindle_css_mode> G96 branch motion")
value_returned = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_value_returned.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 11 and
event["end"]["x"] == 1
for event in value_returned
):
raise SystemExit("missing source-linked initial #<_value_returned> clear branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 15 and
event["end"]["y"] == 1
for event in value_returned
):
raise SystemExit("missing source-linked #<_value_returned> endsub[value] branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 19 and
event["end"]["z"] == 1
for event in value_returned
):
raise SystemExit("missing source-linked #<_value_returned> cleared-procedure branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 23 and
event["end"]["a"] == 1
for event in value_returned
):
raise SystemExit("missing source-linked #<_value_returned> return[value] branch motion")
call_level = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_call_level.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 15 and
event["end"]["x"] == 1
for event in call_level
):
raise SystemExit("missing source-linked main-program #<_call_level> branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 8 and
event["end"]["y"] == 1
for event in call_level
):
raise SystemExit("missing source-linked outer O-word #<_call_level> branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["z"] == 1
for event in call_level
):
raise SystemExit("missing source-linked inner O-word #<_call_level>/#<_remap_level> branch motion")
exists_word_value = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_exists_word_value.json").read_text())
if not any(
event["type"] == "rapid" and
event["line"] == 2 and
event["end"]["x"] == 1 and
event["end"]["y"] == 0 and
event["end"]["z"] == 1 and
event["end"]["a"] == 0
for event in exists_word_value
):
raise SystemExit("missing source-linked direct EXISTS word-value motion")
if not any(
event["type"] == "rapid" and
event["line"] == 5 and
event["end"]["x"] == 1 and
event["end"]["y"] == 0 and
event["end"]["z"] == 0
for event in exists_word_value
):
raise SystemExit("missing source-linked indirect EXISTS word-value motion")
lowercase_numeric_oword = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_lowercase_numeric_oword.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 9 and
event["end"]["x"] == 6
for event in lowercase_numeric_oword
):
raise SystemExit("missing source-linked lowercase numeric O-word return[value] motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 11 and
event["end"]["y"] == 7
for event in lowercase_numeric_oword
):
raise SystemExit("missing source-linked lowercase numeric O-word endsub[value] motion")
parameter_expression_assignment = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_parameter_expression_assignment.json").read_text())
if not any(
event["type"] == "rapid" and
event["line"] == 5 and
event["end"]["x"] == 2 and
event["end"]["y"] == 3 and
event["end"]["z"] == 4
for event in parameter_expression_assignment
):
raise SystemExit("missing source-linked parameter expression assignment motion")
if not any(
event["type"] == "rapid" and
event["line"] == 8 and
event["end"]["a"] == 7
for event in parameter_expression_assignment
):
raise SystemExit("missing source-linked parameter reference expression-index motion")
if not any(
event["type"] == "rapid" and
event["line"] == 9 and
event["end"]["b"] == 5
for event in parameter_expression_assignment
):
raise SystemExit("missing source-linked word parameter unary expression-index motion")
if not any(
event["type"] == "rapid" and
event["line"] == 11 and
event["end"]["c"] == 5
for event in parameter_expression_assignment
):
raise SystemExit("missing source-linked word parameter signed expression-index motion")
if not any(
event["type"] == "rapid" and
event["line"] == 13 and
event["end"]["u"] == 6
for event in parameter_expression_assignment
):
raise SystemExit("missing source-linked parameter assignment signed expression-index motion")
if not any(
event["type"] == "rapid" and
event["line"] == 14 and
event["end"]["v"] == 6
for event in parameter_expression_assignment
):
raise SystemExit("missing source-linked whitespace-insensitive parameter expression-index motion")
if not any(
event["type"] == "rapid" and
event["line"] == 15 and
event["end"]["w"] == 3
for event in parameter_expression_assignment
):
raise SystemExit("missing source-linked whitespace-insensitive word value motion")
expression_operators = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_expression_operators.json").read_text())
if not any(
event["type"] == "rapid" and
event["line"] == 6 and
event["end"]["x"] == 3 and
event["end"]["y"] == 16 and
event["end"]["z"] == 1 and
event["end"]["a"] == 1
for event in expression_operators
):
raise SystemExit("missing source-linked expression mod/power/logical/relational motion")
if not any(
event["type"] == "rapid" and
event["line"] == 10 and
event["end"]["b"] == 19 and
event["end"]["c"] == 2 and
event["end"]["u"] == 1
for event in expression_operators
):
raise SystemExit("missing source-linked expression precedence and relational branch motion")
word_bracket_whitespace = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_word_bracket_whitespace.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 3
for event in word_bracket_whitespace
):
raise SystemExit("missing source-linked spaced bracket word X motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["y"] == 3
for event in word_bracket_whitespace
):
raise SystemExit("missing source-linked plus-spaced bracket word Y motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == -3
for event in word_bracket_whitespace
):
raise SystemExit("missing source-linked minus-spaced bracket word X motion")
m98_mixed_styles = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_m98_mixed_styles_variables.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 13.01 and
event["end"]["y"] == 13.3 and
event["end"]["z"] == 13.31
for event in m98_mixed_styles
):
raise SystemExit("missing source-linked M98 mixed-style global-parameter motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 10 and
event["end"]["a"] == 42.01 and
event["end"]["b"] == 42.3 and
event["end"]["c"] == 13.31
for event in m98_mixed_styles
):
raise SystemExit("missing source-linked O-word mixed-style local-parameter motion")
arc_center_tolerance_good_imperial = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_arc_center_tolerance_good_imperial.json").read_text())
if not any(
event["type"] == "arc-feed" and
event["line"] == 4 and
event["end"]["x"] == 5
for event in arc_center_tolerance_good_imperial
):
raise SystemExit("missing source-linked small imperial center-format arc within tolerance")
g76only = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g76only.json").read_text())
if not any(
event["type"] == "comment" and
event["line"] == 8 and
event["reserved"] == 3301
for event in g76only
):
raise SystemExit("missing source-linked G76 speed-feed sync start in g76only fixture")
if not any(
event["type"] == "program-end" and
event["line"] == 13
for event in g76only
):
raise SystemExit("missing source-linked G76-only program end")
numbered_parameters = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 6 and
event["end"]["x"] == 1
for event in numbered_parameters
):
raise SystemExit("missing source-linked numbered tool/position parameter branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 10 and
event["end"]["y"] == 1
for event in numbered_parameters
):
raise SystemExit("missing source-linked numbered probe parameter branch motion")
rotary_probe_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_rotary_probe_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1 and
event["end"]["a"] == 5
for event in rotary_probe_numbered
):
raise SystemExit("missing source-linked numbered rotary probe parameter branch motion")
multi_rotary_probe_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_multi_rotary_probe_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1 and
event["end"]["a"] == 5 and
event["end"]["b"] == 6 and
event["end"]["c"] == 7 and
event["end"]["u"] == 8 and
event["end"]["v"] == 9 and
event["end"]["w"] == 10
for event in multi_rotary_probe_numbered
):
raise SystemExit("missing source-linked numbered multi-axis rotary probe parameter branch motion")
tool_info_zero_parameter = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_tool_info_zero_parameter.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1
for event in tool_info_zero_parameter
):
raise SystemExit("missing source-linked zeroed #5400/#5410/#5411/#5412/#5413 branch motion")
spindle_tool_info_parameter = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_spindle_tool_info_parameter.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1
for event in spindle_tool_info_parameter
):
raise SystemExit("missing source-linked preloaded spindle-tool #5400/#5410/#5411/#5412/#5413 branch motion")
g28_g30_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g28_g30_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 7 and
event["end"]["x"] == 10
for event in g28_g30_numbered
):
raise SystemExit("missing source-linked G28/G30 numbered parameter branch motion")
rotary_g28_g30_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_rotary_g28_g30_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 7 and
event["end"]["x"] == 1 and
event["end"]["a"] == 7 and
event["end"]["b"] == 8 and
event["end"]["c"] == 9 and
event["end"]["u"] == 10 and
event["end"]["v"] == 11 and
event["end"]["w"] == 12
for event in rotary_g28_g30_numbered
):
raise SystemExit("missing source-linked rotary G28/G30 numbered parameter branch motion")
g92_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g92_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1
for event in g92_numbered
):
raise SystemExit("missing source-linked G92 numbered parameter branch motion")
rotary_g92_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_rotary_g92_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1
for event in rotary_g92_numbered
):
raise SystemExit("missing source-linked rotary G92 numbered parameter branch motion")
g52_g92_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g52_g92_numbered_interaction.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 6 and
event["end"]["x"] == 1
for event in g52_g92_numbered
):
raise SystemExit("missing source-linked G52 X0 Y0 #5210/#5211/#5212 branch motion")
g5x_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g5x_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1
for event in g5x_numbered
):
raise SystemExit("missing source-linked G5X numbered parameter branch motion")
g593_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g59_3_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1
for event in g593_numbered
):
raise SystemExit("missing source-linked G59.3 numbered parameter branch motion")
g593_rotary_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g59_3_rotary_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1
for event in g593_rotary_numbered
):
raise SystemExit("missing source-linked rotary G59.3 numbered parameter branch motion")
g5x_rotary_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g5x_rotary_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1
for event in g5x_rotary_numbered
):
raise SystemExit("missing source-linked rotary G5X numbered parameter branch motion")
g54_rotary_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g54_rotary_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1
for event in g54_rotary_numbered
):
raise SystemExit("missing source-linked rotary G54 numbered parameter branch motion")
debug_level_parameter = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_debug_level_parameter.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 1
for event in debug_level_parameter
):
raise SystemExit("missing source-linked #5599 enabled debug-level branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 8 and
event["end"]["y"] == 1
for event in debug_level_parameter
):
raise SystemExit("missing source-linked #5599 disabled debug-level branch motion")
if any(
event["type"] == "comment" and event["line"] in {5, 10}
for event in debug_level_parameter
):
raise SystemExit("unexpected source-linked generic comment event for DEBUG hot comment")
m66_result_parameter = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_m66_result_parameter.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1
for event in m66_result_parameter
):
raise SystemExit("missing source-linked #5399 digital M66 result branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 9 and
event["end"]["y"] == 1
for event in m66_result_parameter
):
raise SystemExit("missing source-linked #5399 analog M66 result branch motion")
tool_offset_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_tool_offset_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == -1 and
event["end"]["y"] == 1 and
event["end"]["z"] == -2
for event in tool_offset_numbered
):
raise SystemExit("missing source-linked numbered tool-offset/current-position parameter branch motion")
rotary_tool_offset_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_rotary_tool_offset_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1 and
event["end"]["a"] == -1 and
event["end"]["b"] == -2 and
event["end"]["c"] == -3 and
event["end"]["u"] == -4 and
event["end"]["v"] == -5 and
event["end"]["w"] == -6
for event in rotary_tool_offset_numbered
):
raise SystemExit("missing source-linked numbered rotary tool-offset/current-position parameter branch motion")
current_position_numbered = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_current_position_numbered_parameters.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 10 and
event["end"]["y"] == 2 and
event["end"]["z"] == 3 and
event["end"]["a"] == 4 and
event["end"]["b"] == 5 and
event["end"]["c"] == 6 and
event["end"]["u"] == 7 and
event["end"]["v"] == 8 and
event["end"]["w"] == 9
for event in current_position_numbered
):
raise SystemExit("missing source-linked numbered current-position parameter branch motion")
persistent_parameters_check = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_persistent_parameters_check.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1
for event in persistent_parameters_check
):
raise SystemExit("missing source-linked persistent parameter reload branch motion")
rotary_persistent_parameters_check = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_rotary_persistent_parameters_check.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 1
for event in rotary_persistent_parameters_check
):
raise SystemExit("missing source-linked rotary persistent parameter reload branch motion")
g54_persistent_parameters_check = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g54_persistent_parameters_check.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 4 and
event["end"]["x"] == 1
for event in g54_persistent_parameters_check
):
raise SystemExit("missing source-linked G54 persistent parameter reload branch motion")
user_persistent_parameter_check = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_user_persistent_parameter_check.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 1
for event in user_persistent_parameter_check
):
raise SystemExit("missing source-linked empty-var #5001 non-persistence branch motion")
user_existing_persistent_parameter_check = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_user_existing_persistent_parameter_check.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 1
for event in user_existing_persistent_parameter_check
):
raise SystemExit("missing source-linked existing-var #5001 persistence branch motion")
user_persistent_parameter_boundary_check = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_user_persistent_parameter_boundary_check.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 1
for event in user_persistent_parameter_boundary_check
):
raise SystemExit("missing source-linked #5000/#5001/#5030/#5060 persistence boundary branch motion")
volatile_global_parameter_check = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_volatile_global_parameter_check.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["x"] == 1
for event in volatile_global_parameter_check
):
raise SystemExit("missing source-linked volatile global #31 reset branch motion")
coords = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_coordinate_offsets.json").read_text())
g5x = [event for event in coords if event["type"] == "set-g5x-offset"]
g92 = [event for event in coords if event["type"] == "set-g92-offset"]
rot = [event for event in coords if event["type"] == "set-xy-rotation"]
if not any(
event["line"] == 2 and
event["tool"] == 1 and
event["start"]["x"] == 12.5 and
event["start"]["y"] == -3 and
event["start"]["z"] == 4
for event in g5x
):
raise SystemExit("missing source-linked G10 L2 G5X offset event")
if not any(event["feed"] == 30 for event in rot):
raise SystemExit("missing source-linked G10 L2 XY rotation event")
if not any(
event["line"] == 4 and
event["start"]["x"] == 0 and
event["start"]["y"] == 0 and
event["start"]["z"] == 0
for event in g92
):
raise SystemExit("missing source-linked G92.1 clear offset event")
if not any(event["type"] == "program-end" and event["line"] == 5 for event in coords):
raise SystemExit("missing source-linked coordinate program end line number")
l20 = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_coordinate_l20.json").read_text())
if not any(
event["type"] == "set-g5x-offset" and
event["line"] == 4 and
event["tool"] == 2 and
event["start"]["x"] == 4 and
event["start"]["y"] == 4 and
event["start"]["z"] == 4
for event in l20
):
raise SystemExit("missing source-linked G10 L20 P2 offset event after G55 selection")
if not any(event["type"] == "program-end" and event["line"] == 5 for event in l20):
raise SystemExit("missing source-linked G10 L20 program end line number")
p0 = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_coordinate_p0.json").read_text())
if not any(
event["type"] == "set-g5x-offset" and
event["line"] == 3 and
event["tool"] == 2 and
event["start"]["x"] == 7 and
event["start"]["y"] == 8 and
event["start"]["z"] == 9
for event in p0
):
raise SystemExit("missing source-linked G10 L2 P0 active G55 offset event")
if not any(event["type"] == "program-end" and event["line"] == 4 for event in p0):
raise SystemExit("missing source-linked G10 P0 program end line number")
select_all = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_coordinate_select_all.json").read_text())
select_events = [
(event["line"], event["tool"], event["start"]["x"])
for event in select_all
if event["type"] == "set-g5x-offset" and event["line"] in set(range(11, 20))
]
expected_select_events = [
(11, 2, 2),
(12, 1, 1),
(13, 3, 3),
(14, 4, 4),
(15, 5, 5),
(16, 6, 6),
(17, 7, 7),
(18, 8, 8),
(19, 9, 9),
]
if select_events != expected_select_events:
raise SystemExit(f"unexpected source-linked G54-G59.3 selection events: {select_events!r}")
g92_restore = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g92_restore.json").read_text())
g92_states = [
(event["line"], event["start"]["x"], event["start"]["y"], event["start"]["z"])
for event in g92_restore
if event["type"] == "set-g92-offset" and event["line"] > 0
]
expected_g92_states = [
(2, -1, -2, -3),
(3, 0, 0, 0),
(4, -1, -2, -3),
(5, 0, 0, 0),
(6, 0, 0, 0),
]
if g92_states != expected_g92_states:
raise SystemExit(f"unexpected source-linked G92.2/G92.3 restore sequence: {g92_states!r}")
if not any(event["type"] == "program-end" and event["line"] == 7 for event in g92_restore):
raise SystemExit("missing source-linked G92 restore program end line number")
g52_offset = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g52_offset.json").read_text())
g52_states = [
(event["line"], event["start"]["x"], event["start"]["y"], event["start"]["z"])
for event in g52_offset
if event["type"] == "set-g92-offset" and event["line"] > 0
]
expected_g52_states = [
(2, 1, 2, 0),
(3, 1, 3, 0),
(4, 0, 0, 0),
(5, 1, 3, 0),
(6, 0, 0, 0),
]
if g52_states != expected_g52_states:
raise SystemExit(f"unexpected source-linked G52 shared offset sequence: {g52_states!r}")
if not any(event["type"] == "program-end" and event["line"] == 7 for event in g52_offset):
raise SystemExit("missing source-linked G52 offset program end line number")
g52_xz_nurbs = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g52_xz_nurbs.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 6 and
event["plane"] == 18 and
event["end"]["x"] == 3 and
event["end"]["y"] == 0 and
event["end"]["z"] == 3
for event in g52_xz_nurbs
):
raise SystemExit("missing source-linked G18/XZ NURBS endpoint mapped to X/Z axes")
g62_xz_nurbs = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_g62_xz_nurbs.json").read_text())
if not any(
event["type"] == "linear-feed" and
event["line"] == 16 and
event["plane"] == 18 and
event["end"]["x"] == 100 and
event["end"]["y"] == 0 and
event["end"]["z"] == 10
for event in g62_xz_nurbs
):
raise SystemExit("missing source-linked G18/XZ G6.2 NURBS point mapped to X/Z axes")
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_incremental_and_r_arc.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rtcp_controls.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_spindle_direction.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_spindle_modes.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_spindle_orient.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_io_controls.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_override_controls.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_modal_state.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_modal_autorestore.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_threading_sync.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_threading_cycle.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_lathe_diameter_mode.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_lathe_diameter_g76.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_tool_number.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_program_stops.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_program_end_m2.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_program_end_m99.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_coolant.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_feed_modes.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_motion_modes.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_tool_length.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_dynamic_tool_length.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_canned_cycle.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_canned_cycles_extended.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_canned_cycle_planes.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_extended_plane_cycle.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_arc_planes.json"
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"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_m98_subprogram.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_oword_control_flow.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_named_parameter_exists.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_indexed_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_named_parameter_normalization.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_ini_named_parameter.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_readonly_named_parameters_extra.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_value_returned.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_call_level.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_exists_word_value.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_lowercase_numeric_oword.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_parameter_expression_assignment.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_word_bracket_whitespace.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_m98_mixed_styles_variables.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_arc_center_tolerance_good_imperial.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g76only.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rotary_probe_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_multi_rotary_probe_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_tool_info_zero_parameter.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_spindle_tool_info_parameter.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g28_g30_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rotary_g28_g30_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g92_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rotary_g92_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g52_g92_numbered_interaction.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g5x_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g59_3_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g59_3_rotary_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g5x_rotary_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g54_rotary_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_debug_level_parameter.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_m66_result_parameter.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_tool_offset_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rotary_tool_offset_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_current_position_numbered_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_persistent_parameters_set.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_persistent_parameters_check.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rotary_persistent_parameters_set.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_rotary_persistent_parameters_check.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g54_persistent_parameters_set.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g54_persistent_parameters_check.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_set.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_check.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_user_existing_persistent_parameter_set.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_user_existing_persistent_parameter_check.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_boundary_set.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_user_persistent_parameter_boundary_check.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_coordinate_offsets.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_coordinate_l20.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_coordinate_p0.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_coordinate_select_all.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g92_restore.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g52_offset.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g52_xz_nurbs.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_g62_xz_nurbs.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_fractional_linenumbers.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_extended_linenumbers.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_close_and_downcase_words.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_source_percent_file_ignores_trailing.json"