Commit 90cacfe6 authored by Kirill Smelkov's avatar Kirill Smelkov

promise/plugin/check_cpri_lock: Fix it to work ok with Amarisoft 2022

Old Amarisoft versions emit data that is different compared to what 640c0130 expected:

- there can be trailing spaces after /dev/sdrX@Y
  fix: adjust /dev/sdr regex
- there is empty line coming in the end that fas failing in l.split(':', 1)
  fix: ignore empty lines and make detection of : in the line more
       robust with reporting which line is not valid instead of just
       "ERROR not enough values to unpack (expected 2, got 1)"
- there is CPRI key instead of CPRI_option, and the data in both are different.
  fix: detect automatically whether it is CPRI_option or CPRI option that is present.

/co-authored-by lu.xu <lu.xu@nexedi.com>
/reviewed-on !132
parent 8e269cd3
Pipeline #34111 failed with stage
in 0 seconds
...@@ -34,7 +34,7 @@ class RunPromise(JSONPromise): ...@@ -34,7 +34,7 @@ class RunPromise(JSONPromise):
return return
rf_info = rf_info[self.sdr_devchan] rf_info = rf_info[self.sdr_devchan]
icpri = rf_info.get('CPRI_option') icpri = rf_info.get('CPRI_option') or rf_info.get('CPRI')
if icpri is None: if icpri is None:
error("no CPRI feature") error("no CPRI feature")
return return
...@@ -70,7 +70,7 @@ class RunPromise(JSONPromise): ...@@ -70,7 +70,7 @@ class RunPromise(JSONPromise):
for l in rf_info_text.splitlines(): for l in rf_info_text.splitlines():
if not l.startswith(' '): # possibly start of new /dev entry if not l.startswith(' '): # possibly start of new /dev entry
cur = None cur = None
m = re.search(r' (/dev/sdr[^\s]+):$', l) m = re.search(r' (/dev/sdr[^\s]+):\s*$', l)
if m is None: # not so - ignore the line if m is None: # not so - ignore the line
continue continue
...@@ -83,6 +83,13 @@ class RunPromise(JSONPromise): ...@@ -83,6 +83,13 @@ class RunPromise(JSONPromise):
if cur is None: if cur is None:
continue continue
l = l.lstrip()
if not l:
continue # empty lines are ignore, e.g. empty trailing lines in 2022 format
if ':' not in l:
raise ValueError('invalid line %r' % (l,))
k, v = l.split(':', 1) k, v = l.split(':', 1)
k = k.strip() k = k.strip()
v = v.strip() v = v.strip()
......
...@@ -133,5 +133,34 @@ PCIe SDR /dev/sdr4@0: ...@@ -133,5 +133,34 @@ PCIe SDR /dev/sdr4@0:
with self.assertRaisesRegex(PromiseError, 'rf_info: stale data'): with self.assertRaisesRegex(PromiseError, 'rf_info: stale data'):
self.launcher.run() self.launcher.run()
def test_2022(self):
# Amarisoft software from 2022 has different format for rf_info
rf_info_data = self.rf_info_data.copy()
rf_info_data['rf_info'] = \
"""
TRX SDR driver 2022-10-26, API v15/18
PCIe CPRI /dev/sdr0@0:
Hardware ID: 0x4b12
DNA: [0x000841c20971b05c]
Serial: ''
FPGA revision: 2022-10-25 08:58:42
FPGA vccint: 0.98 V
FPGA vccaux: 1.77 V
FPGA vccbram: 0.99 V
FPGA temperature: 71.9 °C
Clock tune: -0.1 ppm
NUMA: 0
CPRI: x16 HW SW
DMA0: TX fifo: 66.67us Usage=16/65536 (0%)
DMA0: RX fifo: 66.67us Usage=864/65536 (1%)
DMA0 Underflows: 0
DMA0 Overflows: 0
""" # NOTE extra spaces in the end and trailing spaces after /dev/sdr0@:0
self.writeLog(rf_info_data)
self.writePromise(sdr_dev='0', sfp_port='0')
self.configureLauncher()
self.launcher.run()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment