Handle old NMEA serial port name format
During an upgrade, or due a missconfiguration the ts2phc NMEA port can be configured in the old name format, tty_GNSS_xxxx_x. Handling the old name format to avoid crashes an ptp-notification missbehavior. A new unit test case was created to cover this case. Test plan: PASS: Verify helm chart and container build PASS: Verify ptp-notification deployment using old configuration. PASS: Verify ptp-notification deployment and basic operation using new configuration. PASS: Verify unit tests. Story: 2011056 Task: 51051 Change-Id: I5bc28cb04241684de52834e9819e8401677f05dd Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
This commit is contained in:
parent
b8fa66daa5
commit
a63f4d31a2
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2022-2023 Wind River Systems, Inc.
|
||||
# Copyright (c) 2022-2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -65,16 +65,17 @@ class CguHandler:
|
||||
|
||||
def get_cgu_path_from_pci_addr(self):
|
||||
# Search for a cgu file using the given pci address
|
||||
cgu_path = "/ice/ice/" + self.pci_addr + "/cgu"
|
||||
if os.path.exists(cgu_path):
|
||||
LOG.debug("PCI address %s has cgu path %s" %
|
||||
(self.pci_addr, cgu_path))
|
||||
self.cgu_path = cgu_path
|
||||
return
|
||||
else:
|
||||
LOG.error("Could not find cgu path for PCI address %s" %
|
||||
self.pci_addr)
|
||||
raise FileNotFoundError
|
||||
if self.pci_addr:
|
||||
cgu_path = "/ice/ice/" + self.pci_addr + "/cgu"
|
||||
if os.path.exists(cgu_path):
|
||||
LOG.debug("PCI address %s has cgu path %s" %
|
||||
(self.pci_addr, cgu_path))
|
||||
self.cgu_path = cgu_path
|
||||
return
|
||||
else:
|
||||
LOG.error("Could not find cgu path for PCI address %s" %
|
||||
self.pci_addr)
|
||||
raise FileNotFoundError
|
||||
|
||||
def read_cgu(self):
|
||||
# Read a given cgu path and return the output in a parseable structure
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2022-2023 Wind River Systems, Inc.
|
||||
# Copyright (c) 2022-2024 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -15,6 +15,7 @@ class CguHandlerTests(unittest.TestCase):
|
||||
testCguHandler = CguHandler(testpath + "test_input_files/ts2phc_valid.conf")
|
||||
missingCguHandler = CguHandler("./no_such_file.conf")
|
||||
invalidCguHandler = CguHandler(testpath + "test_input_files/ts2phc_invalid.conf")
|
||||
oldConfigCguHandler = CguHandler(testpath + "test_input_files/ts2phc_old.conf")
|
||||
|
||||
def test_get_gnss_nmea_serialport(self):
|
||||
# Test success path
|
||||
@ -57,6 +58,11 @@ class CguHandlerTests(unittest.TestCase):
|
||||
self.testCguHandler.get_cgu_path_from_pci_addr()
|
||||
self.assertEqual(self.testCguHandler.cgu_path, "/ice/ice/0000:18:00.0/cgu")
|
||||
|
||||
self.oldConfigCguHandler.get_gnss_nmea_serialport_from_ts2phc_config()
|
||||
self.oldConfigCguHandler.convert_nmea_serialport_to_pci_addr()
|
||||
self.oldConfigCguHandler.get_cgu_path_from_pci_addr()
|
||||
self.assertEqual(self.oldConfigCguHandler.cgu_path, None)
|
||||
|
||||
mock_path.exists.return_value = False
|
||||
with self.assertRaises(FileNotFoundError):
|
||||
self.testCguHandler.get_cgu_path_from_pci_addr()
|
||||
|
@ -0,0 +1,25 @@
|
||||
[global]
|
||||
##
|
||||
## Default Data Set
|
||||
##
|
||||
leapfile /usr/share/zoneinfo/leap-seconds.list
|
||||
logging_level 7
|
||||
ts2phc.nmea_serialport /dev/tty_GNSS_5100_0
|
||||
ts2phc.pulsewidth 100000000
|
||||
|
||||
|
||||
[ens1f0]
|
||||
##
|
||||
## Associated interface: oam0
|
||||
##
|
||||
ts2phc.extts_polarity rising
|
||||
|
||||
|
||||
|
||||
|
||||
[ens2f0]
|
||||
##
|
||||
## Associated interface: data0
|
||||
##
|
||||
ts2phc.extts_polarity rising
|
||||
|
Loading…
x
Reference in New Issue
Block a user