增加G1零进给错误fixture验证

结论:新增 g1_zero_feed 负向 fixture,固定 G1 在 feed rate 为 0 时返回 INTERP_ERROR=5、输出 LinuxCNC 对应错误文本、不产生 STRAIGHT_FEED,且失败前不更新当前位置和 #5420/#5421/#5422。检查:git diff --check 通过;wasm-port/tests/native/verify_native_probes.sh 通过。
This commit is contained in:
cnc
2026-06-06 23:03:32 +08:00
parent 7d71e3bc6d
commit 15b04e8758
5 changed files with 57 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
execute_line_1=5
error_text=Cannot do g1 with zero feed rate
setup.current_x=0
setup.current_y=0
setup.current_z=0
setup.parameter_5420=0
setup.parameter_5421=0
setup.parameter_5422=0
absent=canon_event=STRAIGHT_FEED

View File

@@ -0,0 +1 @@
G1 X1.0

View File

@@ -5,6 +5,8 @@ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
BUILD_DIR="$ROOT_DIR/build/native"
GCODE_FIXTURE_DIR="$ROOT_DIR/tests/fixtures/gcode"
CANON_FIXTURE_DIR="$ROOT_DIR/tests/fixtures/canon"
GCODE_ERROR_FIXTURE_DIR="$ROOT_DIR/tests/fixtures/gcode_errors"
CANON_ERROR_FIXTURE_DIR="$ROOT_DIR/tests/fixtures/canon_errors"
"$ROOT_DIR/tools/build_native_probes.sh"
@@ -77,4 +79,34 @@ for fixture in "$GCODE_FIXTURE_DIR"/*.ngc; do
check_fixture_output "$fixture" "$expected" "$stdout_file"
done
for fixture in "$GCODE_ERROR_FIXTURE_DIR"/*.ngc; do
name="$(basename "$fixture" .ngc)"
expected="$CANON_ERROR_FIXTURE_DIR/$name.expected"
if [[ ! -f "$expected" ]]; then
echo "missing expected error fixture: $expected" >&2
exit 1
fi
stdout_file="$BUILD_DIR/linuxcnc_interp_minimal_harness.$name.stdout.log"
stderr_file="$BUILD_DIR/linuxcnc_interp_minimal_harness.$name.stderr.log"
"$BUILD_DIR/linuxcnc_interp_minimal_harness" "$fixture" \
>"$stdout_file" \
2>"$stderr_file"
while IFS= read -r expected_line; do
[[ -z "$expected_line" ]] && continue
if [[ "$expected_line" == absent=* ]]; then
forbidden="${expected_line#absent=}"
if grep -Fq "$forbidden" "$stdout_file"; then
echo "unexpected output in $stdout_file: $forbidden" >&2
exit 1
fi
elif [[ "$expected_line" == error_text=* ]]; then
grep -Fq "${expected_line#error_text=}" "$stderr_file"
else
grep -Fq "$expected_line" "$stdout_file"
fi
done < "$expected"
done
echo "native probe validation complete"