Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

16
tests/interp/bad/README Normal file
View File

@@ -0,0 +1,16 @@
This directory consists of snippets of gcode that should be rejected because
they are not valid. All files that match the glob '*.ngc' are tested.
The first line should consist of a ";" followed by the exact English
error string that the interpreter should show. This is followed
by zero or more lines of test gcode.
An individual file is considered to be a failure if
* it is accepted by the interpreter
* or the error message does not exactly match the specification
An individual file is considered to be bad if
* it does not contain a parseable error specification
* the error message cannot be isolated in the interpreter's output
If any file is a failure or is bad, then the test as a whole fails and will
count as 1 failure in the testsuite.

View File

@@ -0,0 +1,36 @@
There are three components to the radius error tolerance for center-format
arcs.
The "absolute error" is the difference between the radius at the starting
point and the radius at the ending point. The "relative error" is the
absolute error divided by the maximum arc radius.
The absolute error threshold for imperial arcs is:
2 * 0.001 inch * sqrt(2)
The absolute error threshold for metric arcs is:
2 * 0.01 mm * sqrt(2)
The relative error threshold for all arcs is 0.001 (0.1%)
An arc fails the radius tolerance test if either of these conditions
is true:
* The absolute error is greater than 100 * the absolute error
threshold,
OR
* The absolute error is greater than the absolute error
threshold AND the relative error is greater than the relative
error threshold.
This yields three error regions:
r_big < t_abs/t_rel (2.828 inch or 28.28 mm ): r_small > r_big - t_abs
r_big < 100 t_abs/t_rel (282.8 inch or 2828 mm): r_small > (1-t_rel) r_big
r_big > 100 t_abs/t_rel: r_small > r_big - 100 t_abs

View File

@@ -0,0 +1,3 @@
;Cannot put an a in canned cycle
g81 x0 y0 z-1 r0 f12
a90

View File

@@ -0,0 +1,2 @@
;Cannot put an a in canned cycle
g81 x0 y0 z-1 r0 a90 f12

View File

@@ -0,0 +1,6 @@
;Radius to end of arc differs from radius to start: start=(X0.0000,Y0.0000) center=(X300.1428,Y0.0000) end=(X600.0000,Y0.0000) r1=300.1428 r2=299.8572 abs_err=0.2857 rel_err=0.0952%
g20
f1
g0x0y0z0
g2 x600 i[300 + [100 * [0.00101 * sqrt[2]]]]

View File

@@ -0,0 +1,6 @@
;Radius to end of arc differs from radius to start: start=(X0.0000,Y0.0000) center=(X3001.4284,Y0.0000) end=(X6000.0000,Y0.0000) r1=3001.4284 r2=2998.5716 abs_err=2.857 rel_err=0.0952%
g21
f1
g0x0y0z0
g2 x6000 i[3000 + [100 * [0.0101 * sqrt[2]]]]

View File

@@ -0,0 +1,6 @@
;Radius to end of arc differs from radius to start: start=(X0.0000,Y0.0000) center=(X99.8500,Y0.0000) end=(X200.0000,Y0.0000) r1=99.8500 r2=100.1500 abs_err=0.3 rel_err=0.2996%
g20
f1
g0x0y0z0
g2 x200 i[0.9985 * 100]

View File

@@ -0,0 +1,6 @@
;Radius to end of arc differs from radius to start: start=(X0.0000,Y0.0000) center=(X998.5000,Y0.0000) end=(X2000.0000,Y0.0000) r1=998.5000 r2=1001.5000 abs_err=3 rel_err=0.2996%
g21
f1
g0x0y0z0
g2 x2000 i[0.9985 * 1000]

View File

@@ -0,0 +1,6 @@
;Radius to end of arc differs from radius to start: start=(X0.0000,Y0.0000) center=(X2.4986,Y0.0000) end=(X5.0000,Y0.0000) r1=2.4986 r2=2.5014 abs_err=0.002857 rel_err=0.1142%
g20
f1
g0x0y0z0
g2 x5.000 y0 i[2.500 - [0.00101 * sqrt[2]]]

View File

@@ -0,0 +1,6 @@
;Radius to end of arc differs from radius to start: start=(X0.0000,Y0.0000) center=(X24.9857,Y0.0000) end=(X50.0000,Y0.0000) r1=24.9857 r2=25.0143 abs_err=0.02857 rel_err=0.1142%
g21
f1
g0x0y0z0
g2 x50.00 y0 i[25.00 - [0.0101 * sqrt[2]]]

View File

@@ -0,0 +1,7 @@
;The move just after exiting cutter compensation mode must be straight, not an arc
g0x0y0z0
g41.1d.25
g1x1f1
g1x2
g40
g2i1

View File

@@ -0,0 +1,9 @@
;Straight feed in concave corner cannot be reached by the tool without gouging
g0x0y0z0
g41.1d.25
g1x1f1
g1x2
g1y.1
g1x1
g40
g1x2

2
tests/interp/bad/checkresult Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
true

View File

@@ -0,0 +1,3 @@
(Expected # reading parameter)
G0 X EXISTS[1]
M2

View File

@@ -0,0 +1,3 @@
(Expected ] reading bracketed parameter)
G0 X EXISTS[#1+#2]
M2

View File

@@ -0,0 +1,4 @@
(Parameter number out of range)
#2=99999
G0 X EXISTS[###2]
M2

View File

@@ -0,0 +1,3 @@
(Unknown word starting with f)
G0 X EXISTS[#foo]
M2

View File

@@ -0,0 +1,3 @@
(Named parameter not terminated)
G0 X EXISTS[#<foo]
M2

View File

@@ -0,0 +1,3 @@
;bad number format (conversion failed) parsing ''
G0 X EXISTS[#]
M2

View File

@@ -0,0 +1,3 @@
(Expected ] reading bracketed parameter)
G0 X EXISTS[#<foo>+1]
M2

View File

@@ -0,0 +1,2 @@
;R word is ambiguous on a line with both G64 and M19 - use separate lines
g64 m19 r90 s0

View File

@@ -0,0 +1,2 @@
;R word with no g code that uses it
g61 r0.5

View File

@@ -0,0 +1,14 @@
;Nested subroutine definition
O1 sub
G1 X0
O2 sub
G1 Y0
O2 endsub
O1 endsub
O1 call
M30
%

View File

@@ -0,0 +1,2 @@
;Cannot do g1 with zero feed rate
g1x1

View File

@@ -0,0 +1,2 @@
;R i j k words all missing for arc
g2f1x1

View File

@@ -0,0 +1,2 @@
;All axes missing with motion code
g38.2 f1

31
tests/interp/bad/test Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env python3
import glob, os, sys
fail = 0
for t in sorted(glob.glob('*.ngc')):
sys.stderr.write("# {}".format(t))
error = open(t).readline()
if error.startswith(';'): expected = error[1:-1]
elif error.startswith('('): expected = error[1:-2]
else: expected = "%s: Test does not specify expected error" % t
p = os.popen("rs274 -g %s 2>&1 > /dev/null" % t)
output = p.readlines()
r = p.close()
print("# -> {}".format(r))
if not r:
print("%s: Interpreter accepted bad gcode" % t)
fail += 1
continue
if len(output) < 2:
print("%s: Unexpected interpreter output: %r" % output)
fail += 1
continue
err = output[-2].strip()
if err != expected:
print("%s: Expected %r, got %r instead" % (t, expected, err))
fail += 1
if fail:
raise SystemExit("%d failures" % fail)