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 5BBD8A04B5; Wed, 4 Dec 2019 07:50:35 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 343BE1BE84; Wed, 4 Dec 2019 07:50:35 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A8A431BE83 for ; Wed, 4 Dec 2019 07:50:33 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2019 22:50:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,276,1571727600"; d="scan'208";a="412475766" Received: from dhcpserver.sh.intel.com ([10.239.183.2]) by fmsmga006.fm.intel.com with ESMTP; 03 Dec 2019 22:50:32 -0800 From: michael.luo@intel.com To: dts@dpdk.org Date: Wed, 4 Dec 2019 14:44:31 +0800 Message-Id: <1575441871-6234-1-git-send-email-michael.luo@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575440957-5752-1-git-send-email-michael.luo@intel.com> References: <1575440957-5752-1-git-send-email-michael.luo@intel.com> Subject: [dts] [PATCH v2] 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 | 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