From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CBDC3A04B5; Wed, 4 Dec 2019 07:35:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8FE5B1BE84; Wed, 4 Dec 2019 07:35:22 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 58B7858C4 for ; Wed, 4 Dec 2019 07:35:21 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2019 22:35:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,276,1571727600"; d="scan'208";a="213678377" Received: from dhcpserver.sh.intel.com ([10.239.183.2]) by orsmga006.jf.intel.com with ESMTP; 03 Dec 2019 22:35:18 -0800 From: michael.luo@intel.com To: dts@dpdk.org Date: Wed, 4 Dec 2019 14:29:17 +0800 Message-Id: <1575440957-5752-1-git-send-email-michael.luo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH] tests/userspace_ethtool: pull and check link status X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" From: Gaoliang Luo 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 --- 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