test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] tests/userspace_ethtool: pull and check link status
@ 2019-12-04  6:29 michael.luo
  2019-12-04  6:44 ` [dts] [PATCH v2] " michael.luo
  0 siblings, 1 reply; 3+ messages in thread
From: michael.luo @ 2019-12-04  6:29 UTC (permalink / raw)
  To: dts

From: Gaoliang Luo <michael.luo@intel.com>

in test_port_config, pull and check the link status insteading of
using sleep to wait after DPDK ethtool app stop/open the port.

Signed-off-by: Gaoliang Luo <michael.luo@intel.com>
---
 tests/TestSuite_userspace_ethtool.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index e9b6ccf..70d1e8e 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -221,6 +221,17 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
 
         return status, msg
 
+    def ethapp_check_link_status(self, port_id, expected_status = 'Up'):
+        retries = 0
+        reg_str = 'Port\s+{}:\s+(Up|Down)'.format(port_id)
+        while retries < 5:
+            out = self.dut.send_expect("link", "EthApp> ", 10)
+            if out is not None:
+                status = re.search(reg_str, out).group(1)
+                if status == expected_status:
+                    return True
+        return False
+
     def test_dump_driver_info(self):
         """
         Test ethtool can dump basic information
@@ -519,7 +530,8 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             time.sleep(10)
             # stop port
             self.dut.send_expect("stop %d" % index, "EthApp>")
-            time.sleep(10)
+            self.verify(self.ethapp_check_link_status(index, 'Down') == True,
+                           'Fail to stop port{}'.format(index))
             # check packet not forwarded when port is stop
             pkt = Packet(pkt_type='UDP')
             tester_port = self.tester.get_local_port(port)
@@ -528,11 +540,11 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             rx_pkts, tx_pkts = self.strip_portstats(index)
             self.verify(rx_pkts == ori_rx_pkts, "Failed to stop port")
             # restart port and check packet can normally forwarded
-            time.sleep(2)
             self.dut.send_expect("open %d" % index, "EthApp>")
+            self.verify(self.ethapp_check_link_status(index, 'Up') == True,
+                         'Fail to Open port{}'.format(index))
             # wait few time for port ready
             rx_pkts, tx_pkts = self.strip_portstats(index)
-            time.sleep(2)
             pkt.send_pkt(self.tester, tx_port=intf, count=4)
             rx_pkts_open, tx_pkts_open = self.strip_portstats(index)
             self.verify(rx_pkts_open == rx_pkts + 4, "Failed to reopen port rx")
-- 
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dts] [PATCH v2] tests/userspace_ethtool: pull and check link status
  2019-12-04  6:29 [dts] [PATCH] tests/userspace_ethtool: pull and check link status michael.luo
@ 2019-12-04  6:44 ` michael.luo
  2019-12-05  1:41   ` Tu, Lijuan
  0 siblings, 1 reply; 3+ messages in thread
From: michael.luo @ 2019-12-04  6:44 UTC (permalink / raw)
  To: dts

From: Gaoliang Luo <michael.luo@intel.com>

in test_port_config, pull and check the link status insteading of
using sleep to wait after DPDK ethtool app stop/open the port.

Signed-off-by: Gaoliang Luo <michael.luo@intel.com>
---
 tests/TestSuite_userspace_ethtool.py | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index e9b6ccf..f5583f2 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -221,6 +221,18 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
 
         return status, msg
 
+    def ethapp_check_link_status(self, port_id, expected_status = 'Up'):
+        retries = 0
+        reg_str = 'Port\s+{}:\s+(Up|Down)'.format(port_id)
+        while retries < 5:
+            out = self.dut.send_expect("link", "EthApp> ", 10)
+            if out is not None:
+                status = re.search(reg_str, out).group(1)
+                if status == expected_status:
+                    return True
+            time.sleep(1)
+        return False
+
     def test_dump_driver_info(self):
         """
         Test ethtool can dump basic information
@@ -519,7 +531,8 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             time.sleep(10)
             # stop port
             self.dut.send_expect("stop %d" % index, "EthApp>")
-            time.sleep(10)
+            self.verify(self.ethapp_check_link_status(index, 'Down') == True,
+                           'Fail to stop port{}'.format(index))
             # check packet not forwarded when port is stop
             pkt = Packet(pkt_type='UDP')
             tester_port = self.tester.get_local_port(port)
@@ -528,11 +541,11 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
             rx_pkts, tx_pkts = self.strip_portstats(index)
             self.verify(rx_pkts == ori_rx_pkts, "Failed to stop port")
             # restart port and check packet can normally forwarded
-            time.sleep(2)
             self.dut.send_expect("open %d" % index, "EthApp>")
+            self.verify(self.ethapp_check_link_status(index, 'Up') == True,
+                         'Fail to Open port{}'.format(index))
             # wait few time for port ready
             rx_pkts, tx_pkts = self.strip_portstats(index)
-            time.sleep(2)
             pkt.send_pkt(self.tester, tx_port=intf, count=4)
             rx_pkts_open, tx_pkts_open = self.strip_portstats(index)
             self.verify(rx_pkts_open == rx_pkts + 4, "Failed to reopen port rx")
-- 
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH v2] tests/userspace_ethtool: pull and check link status
  2019-12-04  6:44 ` [dts] [PATCH v2] " michael.luo
@ 2019-12-05  1:41   ` Tu, Lijuan
  0 siblings, 0 replies; 3+ messages in thread
From: Tu, Lijuan @ 2019-12-05  1:41 UTC (permalink / raw)
  To: Luo, Michael, dts

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of
> michael.luo@intel.com
> Sent: Wednesday, December 4, 2019 2:45 PM
> To: dts@dpdk.org
> Subject: [dts] [PATCH v2] tests/userspace_ethtool: pull and check link status
> 
> From: Gaoliang Luo <michael.luo@intel.com>
> 
> in test_port_config, pull and check the link status insteading of using sleep to
> wait after DPDK ethtool app stop/open the port.
> 
> Signed-off-by: Gaoliang Luo <michael.luo@intel.com>
> ---
>  tests/TestSuite_userspace_ethtool.py | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/TestSuite_userspace_ethtool.py
> b/tests/TestSuite_userspace_ethtool.py
> index e9b6ccf..f5583f2 100644
> --- a/tests/TestSuite_userspace_ethtool.py
> +++ b/tests/TestSuite_userspace_ethtool.py
> @@ -221,6 +221,18 @@ class TestUserspaceEthtool(TestCase,
> IxiaPacketGenerator):
> 
>          return status, msg
> 
> +    def ethapp_check_link_status(self, port_id, expected_status = 'Up'):
> +        retries = 0
> +        reg_str = 'Port\s+{}:\s+(Up|Down)'.format(port_id)
> +        while retries < 5:
> +            out = self.dut.send_expect("link", "EthApp> ", 10)
> +            if out is not None:
> +                status = re.search(reg_str, out).group(1)
> +                if status == expected_status:
> +                    return True
> +            time.sleep(1)
> +        return False
> +
>      def test_dump_driver_info(self):
>          """
>          Test ethtool can dump basic information @@ -519,7 +531,8 @@ class
> TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
>              time.sleep(10)
>              # stop port
>              self.dut.send_expect("stop %d" % index, "EthApp>")
> -            time.sleep(10)
> +            self.verify(self.ethapp_check_link_status(index, 'Down') == True,
> +                           'Fail to stop port{}'.format(index))
>              # check packet not forwarded when port is stop
>              pkt = Packet(pkt_type='UDP')
>              tester_port = self.tester.get_local_port(port) @@ -528,11 +541,11
> @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
>              rx_pkts, tx_pkts = self.strip_portstats(index)
>              self.verify(rx_pkts == ori_rx_pkts, "Failed to stop port")
>              # restart port and check packet can normally forwarded
> -            time.sleep(2)
>              self.dut.send_expect("open %d" % index, "EthApp>")
> +            self.verify(self.ethapp_check_link_status(index, 'Up') == True,
> +                         'Fail to Open port{}'.format(index))
>              # wait few time for port ready
>              rx_pkts, tx_pkts = self.strip_portstats(index)
> -            time.sleep(2)
>              pkt.send_pkt(self.tester, tx_port=intf, count=4)
>              rx_pkts_open, tx_pkts_open = self.strip_portstats(index)
>              self.verify(rx_pkts_open == rx_pkts + 4, "Failed to reopen port rx")
> --
> 2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-05  1:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04  6:29 [dts] [PATCH] tests/userspace_ethtool: pull and check link status michael.luo
2019-12-04  6:44 ` [dts] [PATCH v2] " michael.luo
2019-12-05  1:41   ` 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).