* [dts] [PATCH V3] tests/link_status_interrupt: optimize the method of checking priv_flags
@ 2021-10-28 10:59 Jiale Song
2021-10-29 1:29 ` Tu, Lijuan
0 siblings, 1 reply; 2+ messages in thread
From: Jiale Song @ 2021-10-28 10:59 UTC (permalink / raw)
To: dts; +Cc: Jiale Song
Signed-off-by: Jiale Song <songx.jiale@intel.com>
---
framework/crb.py | 17 +++++++++++++++++
tests/TestSuite_link_status_interrupt.py | 20 +++++++-------------
2 files changed, 24 insertions(+), 13 deletions(-)
mode change 100644 => 100755 framework/crb.py
diff --git a/framework/crb.py b/framework/crb.py
old mode 100644
new mode 100755
index 9d78e51d..c9909add
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -890,3 +890,20 @@ class Crb(object):
def enable_promisc(self, intf):
if intf != 'N/A':
self.send_expect("ifconfig %s promisc" % intf, "# ", alt_session=True)
+
+ def get_priv_flags_state(self, intf, flag, timeout=TIMEOUT):
+ '''
+
+ :param intf: nic name
+ :param flag: priv-flags flag
+ :return: flag state
+ '''
+ check_flag = "ethtool --show-priv-flags %s" % intf
+ out = self.send_expect(check_flag, "# ", timeout)
+ p = re.compile('%s\s+:\s+(\w+)' % flag)
+ state = re.search(p, out)
+ if state:
+ return state.group(1)
+ else:
+ self.logger.info("NIC %s may be not find %s" % (intf, flag))
+ return False
diff --git a/tests/TestSuite_link_status_interrupt.py b/tests/TestSuite_link_status_interrupt.py
index bdb43f42..422f1f4e 100755
--- a/tests/TestSuite_link_status_interrupt.py
+++ b/tests/TestSuite_link_status_interrupt.py
@@ -75,18 +75,12 @@ class TestLinkStatusInterrupt(TestCase):
# check link-down-on-close flag
self.flag = "link-down-on-close"
for intf in self.intfs:
- check_flag = "ethtool --show-priv-flags %s" % intf
set_flag = "ethtool --set-priv-flags %s %s on" % (intf, self.flag)
- out = self.tester.send_expect(check_flag, "#")
- p = re.compile('%s\s+:\s+(\w+)' % self.flag)
- res = re.search(p, out).group(1)
- if res == "off":
- self.tester.send_expect(set_flag, "#")
+ self.flag_default_stats = self.tester.get_priv_flags_state(intf, self.flag)
+ if self.flag_default_stats == "off":
+ self.tester.send_expect(set_flag, "# ")
time.sleep(0.5)
- out = self.tester.send_expect(check_flag, "#")
- self.verify(re.search(p, out).group(1) == "on", "set %s %s on failed" % (intf, self.flag))
- elif not res:
- self.logger.info("NIC %s might not support this case" % intf)
+ self.verify(self.tester.get_priv_flags_state(intf, self.flag) == "on", "set %s %s on failed" % (intf, self.flag))
def set_link_status_and_verify(self, dutPort, status):
"""
@@ -94,7 +88,7 @@ class TestLinkStatusInterrupt(TestCase):
"""
self.intf = self.tester.get_interface(
self.tester.get_local_port(dutPort))
- if self.dut.get_os_type() != 'freebsd':
+ if self.dut.get_os_type() != 'freebsd' and self.flag_default_stats:
self.tester.send_expect("ethtool --set-priv-flags %s link-down-on-close on" % self.intf, "#", 10)
self.tester.send_expect("ifconfig %s %s" %
(self.intf, status.lower()), "# ", 10)
@@ -210,6 +204,6 @@ class TestLinkStatusInterrupt(TestCase):
"""
Run after each test suite.
"""
- if self.dut.get_os_type() != 'freebsd':
+ if self.dut.get_os_type() != 'freebsd' and self.flag_default_stats:
for intf in self.intfs:
- self.tester.send_expect("ethtool --set-priv-flags %s %s off" % (intf, self.flag), "#", 10)
+ self.tester.send_expect("ethtool --set-priv-flags %s %s %s" % (intf, self.flag, self.flag_default_stats), "# ")
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [PATCH V3] tests/link_status_interrupt: optimize the method of checking priv_flags
2021-10-28 10:59 [dts] [PATCH V3] tests/link_status_interrupt: optimize the method of checking priv_flags Jiale Song
@ 2021-10-29 1:29 ` Tu, Lijuan
0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2021-10-29 1:29 UTC (permalink / raw)
To: Jiale, SongX, dts; +Cc: Jiale, SongX
> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of Jiale Song
> Sent: 2021年10月28日 18:59
> To: dts@dpdk.org
> Cc: Jiale, SongX <songx.jiale@intel.com>
> Subject: [dts] [PATCH V3] tests/link_status_interrupt: optimize the method of
> checking priv_flags
>
> Signed-off-by: Jiale Song <songx.jiale@intel.com>
Applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-29 1:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 10:59 [dts] [PATCH V3] tests/link_status_interrupt: optimize the method of checking priv_flags Jiale Song
2021-10-29 1:29 ` Tu, Lijuan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).