test suite reviews and discussions
 help / color / mirror / Atom feed
From: michael.luo@intel.com
To: dts@dpdk.org
Subject: [dts] [PATCH v2] tests/userspace_ethtool: pull and check link status
Date: Wed,  4 Dec 2019 14:44:31 +0800	[thread overview]
Message-ID: <1575441871-6234-1-git-send-email-michael.luo@intel.com> (raw)
In-Reply-To: <1575440957-5752-1-git-send-email-michael.luo@intel.com>

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


  reply	other threads:[~2019-12-04  6:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04  6:29 [dts] [PATCH] " michael.luo
2019-12-04  6:44 ` michael.luo [this message]
2019-12-05  1:41   ` [dts] [PATCH v2] " Tu, Lijuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1575441871-6234-1-git-send-email-michael.luo@intel.com \
    --to=michael.luo@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).