diff --git a/test-linuxcnc-rs274-native.sh b/test-linuxcnc-rs274-native.sh index 2dd9b40..3efb453 100755 --- a/test-linuxcnc-rs274-native.sh +++ b/test-linuxcnc-rs274-native.sh @@ -217,7 +217,12 @@ check_g_code_error_cases=( "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" ) @@ -232,6 +237,26 @@ for case in "${check_g_code_error_cases[@]}"; do fi grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$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_without_offsets_error|G10 L1 without offsets has no effect" + "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_dump" "tests/gcode/$fixture.ngc" \ + >"$output_dir/cnc_sim_linuxcnc_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_$fixture.err"; then + echo "expected $fixture.ngc to fail" >&2 + exit 1 + fi + grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err" +done # Source basis: LinuxCNC src/emc/rs274ngc/interp_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. diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index aff4e8a..6c84c60 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -661,7 +661,12 @@ check_g_code_error_cases=( "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" ) @@ -676,6 +681,26 @@ for case in "${check_g_code_error_cases[@]}"; do 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_without_offsets_error|G10 L1 without offsets has no effect" + "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" diff --git a/tests/gcode/linuxcnc_g10_l10_p_out_of_range_error.ngc b/tests/gcode/linuxcnc_g10_l10_p_out_of_range_error.ngc new file mode 100644 index 0000000..66dbeae --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l10_p_out_of_range_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L10 P0 X0 diff --git a/tests/gcode/linuxcnc_g10_l11_p_out_of_range_error.ngc b/tests/gcode/linuxcnc_g10_l11_p_out_of_range_error.ngc new file mode 100644 index 0000000..edc9ac2 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l11_p_out_of_range_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L11 P0 X0 diff --git a/tests/gcode/linuxcnc_g10_l1_without_offsets_error.ngc b/tests/gcode/linuxcnc_g10_l1_without_offsets_error.ngc new file mode 100644 index 0000000..dcca7f0 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l1_without_offsets_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L1 P1 diff --git a/tests/gcode/linuxcnc_g10_l20_i_word_error.ngc b/tests/gcode/linuxcnc_g10_l20_i_word_error.ngc new file mode 100644 index 0000000..f6d0518 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l20_i_word_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L20 P1 I2 diff --git a/tests/gcode/linuxcnc_g10_l20_p_missing_error.ngc b/tests/gcode/linuxcnc_g10_l20_p_missing_error.ngc new file mode 100644 index 0000000..28eee93 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l20_p_missing_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L20 X1 diff --git a/tests/gcode/linuxcnc_g10_l20_p_out_of_range_error.ngc b/tests/gcode/linuxcnc_g10_l20_p_out_of_range_error.ngc new file mode 100644 index 0000000..0feb6d8 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l20_p_out_of_range_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L20 P10 X1 diff --git a/tests/gcode/linuxcnc_g10_l20_r_word_error.ngc b/tests/gcode/linuxcnc_g10_l20_r_word_error.ngc new file mode 100644 index 0000000..231de82 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l20_r_word_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L20 P1 X1 R30 diff --git a/tests/gcode/linuxcnc_g10_l2_i_word_error.ngc b/tests/gcode/linuxcnc_g10_l2_i_word_error.ngc new file mode 100644 index 0000000..d09f207 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l2_i_word_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L2 P1 X1 I2 diff --git a/tests/gcode/linuxcnc_g10_l2_p_missing_error.ngc b/tests/gcode/linuxcnc_g10_l2_p_missing_error.ngc new file mode 100644 index 0000000..894e1b2 --- /dev/null +++ b/tests/gcode/linuxcnc_g10_l2_p_missing_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G10 L2 X1