Skip to content

Commit

Permalink
interfaces/serial-port: allow RPMSG dev node (canonical#14169)
Browse files Browse the repository at this point in the history
Co-authored-by: Buğra Aydoğar <[email protected]>
  • Loading branch information
bugraaydogar and Buğra Aydoğar authored Jul 10, 2024
1 parent 08729d6 commit 5f116fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion interfaces/builtin/serial_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func (iface *serialPortInterface) String() string {
// - ttyHSX (Qualcomm GENI based QTI serial cores)
// - ttyGSX (USB gadget serial devices)
// - ttyLPX (NXP Layerscape SoC UART serial ports)
var serialDeviceNodePattern = regexp.MustCompile("^/dev/tty(mxc|USB|ACM|AMA|XRUSB|S|O|SC|MSM|HS|GS|LP)[0-9]+$")
// - ttyRPMSGX (RPMSG TTY driver serial ports)
var serialDeviceNodePattern = regexp.MustCompile("^/dev/tty(mxc|USB|ACM|AMA|XRUSB|S|O|SC|MSM|HS|GS|LP|RPMSG)[0-9]+$")

// Pattern that is considered valid for the udev symlink to the serial device,
// path attributes will be compared to this for validity when usb vid and pid
Expand Down
11 changes: 11 additions & 0 deletions interfaces/builtin/serial_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type SerialPortInterfaceSuite struct {
testSlot12 *interfaces.ConnectedSlot
testSlot13Info *snap.SlotInfo
testSlot13 *interfaces.ConnectedSlot
testSlot14Info *snap.SlotInfo
testSlot14 *interfaces.ConnectedSlot
testSlot12Info *snap.SlotInfo
testSlotCleaned *interfaces.ConnectedSlot
testSlotCleanedInfo *snap.SlotInfo
Expand Down Expand Up @@ -180,6 +182,9 @@ slots:
test-port-13:
interface: serial-port
path: /dev/ttyLP0
test-port-14:
interface: serial-port
path: /dev/ttyRPMSG0
test-port-unclean:
interface: serial-port
path: /dev/./././ttyS1////
Expand Down Expand Up @@ -260,6 +265,8 @@ slots:
s.testSlot12 = interfaces.NewConnectedSlot(s.testSlot12Info, appSet, nil, nil)
s.testSlot13Info = s.osSnapInfo.Slots["test-port-13"]
s.testSlot13 = interfaces.NewConnectedSlot(s.testSlot13Info, appSet, nil, nil)
s.testSlot14Info = s.osSnapInfo.Slots["test-port-14"]
s.testSlot14 = interfaces.NewConnectedSlot(s.testSlot14Info, appSet, nil, nil)
s.testSlotCleanedInfo = s.osSnapInfo.Slots["test-port-unclean"]
s.testSlotCleaned = interfaces.NewConnectedSlot(s.testSlotCleanedInfo, appSet, nil, nil)
s.missingPathSlotInfo = s.osSnapInfo.Slots["missing-path"]
Expand Down Expand Up @@ -418,6 +425,7 @@ func (s *SerialPortInterfaceSuite) TestSanitizeCoreSnapSlots(c *C) {
s.testSlot11Info,
s.testSlot12Info,
s.testSlot13Info,
s.testSlot14Info,
} {
c.Assert(interfaces.BeforePrepareSlot(s.iface, slot), IsNil)
}
Expand Down Expand Up @@ -610,6 +618,9 @@ func (s *SerialPortInterfaceSuite) TestConnectedPlugAppArmorSnippets(c *C) {
expectedSnippet13 := `/dev/ttyLP0 rwk,`
checkConnectedPlugSnippet(s.testPlugPort1, s.testSlot13, expectedSnippet13)

expectedSnippet14 := `/dev/ttyRPMSG0 rwk,`
checkConnectedPlugSnippet(s.testPlugPort1, s.testSlot14, expectedSnippet14)

expectedSnippet100 := `/dev/tty[A-Z]*[0-9] rwk,`
checkConnectedPlugSnippet(s.testPlugPort1, s.testUDev1, expectedSnippet100)

Expand Down

0 comments on commit 5f116fa

Please sign in to comment.