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

2
tests/hm2-idrom/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/halrun-stderr
/halrun-stdout

7
tests/hm2-idrom/README Normal file
View File

@@ -0,0 +1,7 @@
This is a test of the hm2_register() function in the hostmot2(9) driver.
It makes a fake AnyIO board (using the hm2_test driver) with a static
"register file" containing a test pattern. The fake AnyIO board is
passed to hm2_register(), and let's see if it panics.

View File

@@ -0,0 +1,4 @@
loadrt hostmot2 debug_idrom=1 debug_pin_descriptors=1 debug_module_descriptors=1
loadrt hm2_test test_pattern=$(TEST_PATTERN)

69
tests/hm2-idrom/check-dmesg.py Executable file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/env python3
#
# Here's the kind of output we're looking for:
#
# [87900.133189] hm2: loading Mesa HostMot2 driver version 0.14
# [87900.157678] hm2_test: loading HostMot2 test driver
# [87900.157715] hm2: no firmware specified in config modparam! the board had better have firmware configured already, or this won't work
# [87900.157724] hm2/hm2_test.0: invalid cookie, got 0x00000000, expected 0x55AACAFE
# [87900.157726] hm2/hm2_test.0: FPGA failed to initialize, or unexpected firmware?
# [87900.157731] hm2_test.0: hm2_test fails HM2 registration
# [87900.236858] hm2: unloading
import os
import sys
import re
import hal
hm2_test_load = 'loading HostMot2 test driver'
hm2_test_unload = 'hm2_test.0: hm2_test fails HM2 registration'
sought_error = sys.argv[1]
if sought_error == None:
print("supply an error message on the command line!")
sys.exit(1)
# is this how you do enum in python?
LOOKING_FOR_LOAD, LOOKING_FOR_ERROR = list(range(2))
if hal.is_kernelspace:
dmesg = os.popen('dmesg')
else:
dmesg = open("halrun-stderr")
output = ""
state = LOOKING_FOR_LOAD
result = 1
while 1:
line = dmesg.readline()
output += line
if line == "": break # eof
if state == LOOKING_FOR_LOAD:
if line.find(hm2_test_load) < 0: continue
state = LOOKING_FOR_ERROR
result = 1 # assume it's the wrong error for now
continue
if state == LOOKING_FOR_ERROR:
if re.search(sought_error, line) != None:
result = 0
state = LOOKING_FOR_LOAD
continue;
if line.find(hm2_test_unload) >= 0:
state = LOOKING_FOR_LOAD
if (result == 0):
print(sought_error)
else:
print("test pattern %s did not produce error '%s'" % (os.getenv("TEST_PATTERN"), sought_error))
print("actual output:")
print(output)
sys.exit(result)

15
tests/hm2-idrom/expected Normal file
View File

@@ -0,0 +1,15 @@
hm2/hm2_test\.0: invalid cookie
hm2/hm2_test\.0: invalid config name
hm2/hm2_test\.0: invalid IDROM type
hm2/hm2_test\.0: invalid IDROM type
hm2/hm2_test\.0: invalid IDROM PortWidth
hm2/hm2_test\.0: invalid IDROM PortWidth
hm2/hm2_test\.0: IDROM IOPorts is 0 but llio num_ioport_connectors is \d+
hm2/hm2_test\.0: IDROM IOWidth is \d+, but IDROM IOPorts is \d+ and IDROM PortWidth is \d+
hm2/hm2_test\.0: IDROM IOPorts is \d+ but llio num_ioport_connectors is \d+
hm2/hm2_test\.0: IDROM ClockLow is \d+, that's too low
hm2/hm2_test\.0: IDROM ClockHigh is \d+, that's too low
hm2/hm2_test\.0: pin 0 primary tag is 0 \(end-of-list sentinel\), expected 144 pins!
hm2/hm2_test\.0: [^:]+: invalid pin number 0
hm2/hm2_test\.0: invalid IDROM PortWidth 24, this board has 5 pins per connector, aborting load
hm2/hm2_test\.0: IDROM IOPorts is 0 but llio num_ioport_connectors is \d+

29
tests/hm2-idrom/test.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
Error[0]="hm2/hm2_test\.0: invalid cookie"
Error[1]="hm2/hm2_test\.0: invalid config name"
Error[2]="hm2/hm2_test\.0: invalid IDROM type"
Error[3]="hm2/hm2_test\.0: invalid IDROM type"
Error[4]="hm2/hm2_test\.0: invalid IDROM PortWidth"
Error[5]="hm2/hm2_test\.0: invalid IDROM PortWidth"
Error[6]="hm2/hm2_test\.0: IDROM IOPorts is 0 but llio num_ioport_connectors is \d+"
Error[7]="hm2/hm2_test\.0: IDROM IOWidth is \d+, but IDROM IOPorts is \d+ and IDROM PortWidth is \d+"
Error[8]="hm2/hm2_test\.0: IDROM IOPorts is \d+ but llio num_ioport_connectors is \d+"
Error[9]="hm2/hm2_test\.0: IDROM ClockLow is \d+, that's too low"
Error[10]="hm2/hm2_test\.0: IDROM ClockHigh is \d+, that's too low"
Error[11]="hm2/hm2_test\.0: pin 0 primary tag is 0 \(end-of-list sentinel\), expected 144 pins!"
Error[12]="hm2/hm2_test\.0: [^:]+: invalid pin number 0"
Error[13]="hm2/hm2_test\.0: invalid IDROM PortWidth 24, this board has 5 pins per connector, aborting load"
Error[14]="hm2/hm2_test\.0: IDROM IOPorts is 0 but llio num_ioport_connectors is \d+"
result=0
TEST_PATTERN=0
while [ -n "${Error[$TEST_PATTERN]}" ]; do
export TEST_PATTERN
halrun -f broken-load-test.hal >halrun-stdout 2>halrun-stderr
./check-dmesg.py "${Error[$TEST_PATTERN]}" || exit $?
TEST_PATTERN=$((TEST_PATTERN + 1))
done
exit $result