aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSugandha Gupta <sugandha.gupta@ettus.com>2018-08-02 14:48:12 -0700
committerBrent Stapleton <bstapleton@g.hmc.edu>2018-08-06 11:14:33 -0700
commit79cad066ab849bdb773f1716c54acf61e601f0e8 (patch)
tree8ee2b969cb702530b0eed1918d53f418b4cd9bab
parent89eac133eab2e4bcd5f67544fe0ca888f5e7df9e (diff)
downloaduhd-79cad066ab849bdb773f1716c54acf61e601f0e8.tar.gz
uhd-79cad066ab849bdb773f1716c54acf61e601f0e8.tar.bz2
uhd-79cad066ab849bdb773f1716c54acf61e601f0e8.zip
e320: bist: Add link_up test
- Returns true if the link of sfp0 is up (1G/10G)
-rwxr-xr-xmpm/python/e320_bist26
1 files changed, 26 insertions, 0 deletions
diff --git a/mpm/python/e320_bist b/mpm/python/e320_bist
index 99da3cd74..c9664ce00 100755
--- a/mpm/python/e320_bist
+++ b/mpm/python/e320_bist
@@ -797,6 +797,32 @@ class E320BIST(object):
}
return len(result) == 1, result
+ def bist_link_up(self):
+ """
+ BIST test for SFP link
+ Description: Checks if SFP link is up
+ External Equipment: 1G/10G cable connected to SFP port
+ Return dictionary:
+ - sfp0: status of link
+ Return status: True if link is UP
+ """
+ assert 'link_up' in self.tests_to_run
+ if self.args.dry_run:
+ return True, {'sfp0': 'UP'}
+ from pyroute2 import IPRoute
+ result = {}
+ with IPRoute() as ipr:
+ links = ipr.link_lookup(ifname='sfp0')
+ if not links:
+ return False, {'error_msg': "No interface found"}
+ link_info = next(iter(ipr.get_links(links)), None)
+ if link_info == None:
+ return False, {'error_msg': "Error on get_links for sfp0"}
+ result['sfp0'] = link_info.get_attr('IFLA_OPERSTATE')
+ if result['sfp0'] != 'UP':
+ result['error_msg'] = "Link not up for interface"
+ return 'error_msg' not in result, result
+
def gpio_set_all(gpio_bank, value, gpio_size, ddr_mask):
"""Helper function for set gpio.