From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C5D1EA034C; Fri, 25 Feb 2022 11:09:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA6A24115C; Fri, 25 Feb 2022 11:09:44 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 25A284068B for ; Fri, 25 Feb 2022 11:09:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645783783; x=1677319783; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=AxlS7VJilmztfR6SzbH+ukOKWpvNy8LaUhJyzyPZSjg=; b=Rx3JD1l4u9fcRehC4rAWn/tZ6zRAHbWqgconTb33GtGx6H1KG9lF7363 pxPWfEHKV1tSMCeaicXmQZ6KZNeVyx2YAcm6DopNiZSaK/f+7Pex3CPiW CdVVJWS+1/pX3uoIX2sJX10SpebC9ZuNEWN6Q+e/56aGRHuRzr9Oh3XDj OBALQwufGuaJFM5NgS5S9ge0tGbupd4watFnm8wvOSErNeVFjZKpuEunU 8uQ8ivXQPgHGZQjuunqqxlj82m9XPKBwKpWG1e1yzzdENkfwX7J5jC+56 XGxFWFv3cRLBFUu6pe58KpI3jcowXDedO+okC0+lwSrUxTIjhJ59wsMnZ A==; X-IronPort-AV: E=McAfee;i="6200,9189,10268"; a="233093491" X-IronPort-AV: E=Sophos;i="5.90,136,1643702400"; d="scan'208";a="233093491" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2022 02:09:42 -0800 X-IronPort-AV: E=Sophos;i="5.90,136,1643702400"; d="scan'208";a="491940127" Received: from unknown (HELO localhost.localdomain) ([10.239.251.226]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2022 02:09:40 -0800 From: Yu Jiang To: lijuan.tu@intel.com, dts@dpdk.org Cc: Yu Jiang Subject: [dts][PATCH V1] tests/vm_hotplug: optimize script by using existed function Date: Fri, 25 Feb 2022 18:09:13 +0000 Message-Id: <20220225180913.2691504-1-yux.jiang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 1, use existed function wait_link_status_up to check link's status. 2, use new method: is_interface_up to to ensure iface's link status before send_packets Signed-off-by: Yu Jiang --- tests/TestSuite_vm_hotplug.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/TestSuite_vm_hotplug.py b/tests/TestSuite_vm_hotplug.py index c3695b68..0b4c3476 100644 --- a/tests/TestSuite_vm_hotplug.py +++ b/tests/TestSuite_vm_hotplug.py @@ -237,28 +237,16 @@ class TestVmHotplug(TestCase): result.append(cap_num[0]) return result - def check_link_status(self, vm_info): - loop = 1 - while (loop <= 3): - out = vm_info.execute_cmd("show port info all", "testpmd> ", 120) - port_status = re.findall("Link\s*status:\s*([a-z]*)", out) - if ("down" not in port_status): - break - time.sleep(3) - loop += 1 - self.verify("down" not in port_status, "port can not up after start") - def verify_rxtx_only(self): # rxonly self.vm_testpmd.execute_cmd('set fwd rxonly') self.vm_testpmd.execute_cmd('set verbose 1') self.vm_testpmd.execute_cmd('port start all') self.vm_testpmd.execute_cmd('start') - self.check_link_status(self.vm_testpmd) + self.vm_testpmd.wait_link_status_up('all') self.send_packet() - out = self.vm0_dut.get_session_output() - time.sleep(1) + out = self.vm0_dut.get_session_output(timeout=20) self.verify(self.vf0_mac in out, 'vf0 receive packet fail') if self.device == 2: self.verify(self.vf1_mac in out, 'vf1 receive packet fail') @@ -271,7 +259,7 @@ class TestVmHotplug(TestCase): iface_list.append(self.tester_intf1) self.start_tcpdump(iface_list) self.vm_testpmd.execute_cmd('start') - time.sleep(1) + self.vm_testpmd.wait_link_status_up('all') self.vm_testpmd.execute_cmd('stop') out = self.get_tcpdump_package(iface_list) for pkt_num in out: @@ -303,6 +291,9 @@ class TestVmHotplug(TestCase): time.sleep(1) def send_packet(self): + # check tester's link status before send packet + for iface in [self.tester_intf0, self.tester_intf1]: + self.verify(self.tester.is_interface_up(intf=iface), "Wrong link status, should be up") self.vf0_mac = self.vm_testpmd.get_port_mac(0) pkts = [] pkt1 = r'sendp([Ether(dst="%s")/IP()/UDP()/Raw(load="P"*26)], iface="%s")' % (self.vf0_mac, self.tester_intf) -- 2.25.1