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 133B5A0567; Wed, 10 Mar 2021 08:57:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C2764068C; Wed, 10 Mar 2021 08:57:15 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 1F04D4068C for ; Wed, 10 Mar 2021 08:57:12 +0100 (CET) IronPort-SDR: KmM8B23WBsLyG+MtXouAW6eGz0rRrjh3GJ8zZeFBQ8LDD97p5z8rjlHS/YIpZ1gN3AQggOLyMU 0X4l84xXcYnw== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="167685251" X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="167685251" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2021 23:57:12 -0800 IronPort-SDR: 7IsJHrxrXW0Xpo+yPhzPiepT5gmrtsCCvZgiSNkeAmOyRHF+Dqu4V//P8FjfA8SPHxXNvv5EJJ 14ooj1kdi1cg== X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="410084560" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2021 23:57:10 -0800 From: Ling Wei To: dts@dpdk.org Cc: Ling Wei Date: Wed, 10 Mar 2021 15:55:28 +0800 Message-Id: <20210310075528.2197433-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dts] [PATCH V1] tests/vhost_pmd_xstats: add allow pci param to support tester and dut in same server and optimize code 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 Sender: "dts" 1.Add -a option to support tester and dut in same server. 2.Use pmd.start_testpmd() to replace session.send_expect() to start testpmd. 3.Move create dut ssh session from set_up to set_up_all to reduce the number of creation. 4.Add close dut session in tear_down_all to close session when suite execute over. Signed-off-by: Ling Wei --- tests/TestSuite_vhost_pmd_xstats.py | 65 +++++++++++++---------------- 1 file changed, 29 insertions(+), 36 deletions(-) mode change 100755 => 100644 tests/TestSuite_vhost_pmd_xstats.py diff --git a/tests/TestSuite_vhost_pmd_xstats.py b/tests/TestSuite_vhost_pmd_xstats.py old mode 100755 new mode 100644 index a3b0a2f3..016348d1 --- a/tests/TestSuite_vhost_pmd_xstats.py +++ b/tests/TestSuite_vhost_pmd_xstats.py @@ -43,6 +43,7 @@ from test_case import TestCase from settings import HEADER_SIZE from qemu_kvm import QEMUKvm from packet import Packet +from pmd_output import PmdOutput ETHER_JUMBO_FRAME_MTU = 9000 DEFAULT_JUMBO_FRAME_MTU = 1500 @@ -63,17 +64,18 @@ class TestVhostPmdXstats(TestCase): self.virtio1_mac = "52:54:00:00:00:01" self.core_config = "1S/6C/1T" self.ports_socket = self.dut.get_numa_id(self.dut_ports[0]) - self.cores_num = len([n for n in self.dut.cores if int(n['socket']) - == self.ports_socket]) - self.verify(self.cores_num >= 6, - "There has not enough cores to test this case") - self.core_list = self.dut.get_core_list( - self.core_config, socket=self.ports_socket) + self.cores_num = len([n for n in self.dut.cores if int(n['socket']) == self.ports_socket]) + self.verify(self.cores_num >= 6, "There has not enough cores to test this case") + self.core_list = self.dut.get_core_list(self.core_config, socket=self.ports_socket) self.core_list_user = self.core_list[0:3] self.core_list_host = self.core_list[3:6] self.dst_mac = self.dut.get_mac_address(self.dut_ports[0]) self.app_testpmd_path = self.dut.apps_name['test-pmd'] self.testpmd_name=self.app_testpmd_path.split("/")[-1] + self.vhost_user = self.dut.new_session(suite="vhost-user") + self.virtio_user0 = self.dut.new_session(suite="virtio-user0") + self.vhost_user_pmd = PmdOutput(self.dut, self.vhost_user) + self.virtio_user0_pmd = PmdOutput(self.dut, self.virtio_user0) def set_up(self): """ @@ -82,8 +84,6 @@ class TestVhostPmdXstats(TestCase): """ self.dut.send_expect("rm -rf ./vhost-net*", "#") self.dut.send_expect("killall -s INT %s" % self.testpmd_name, "#") - self.vhost_user = self.dut.new_session(suite="vhost-user") - self.virtio_user = self.dut.new_session(suite="virtio-user") @property def check_2M_env(self): @@ -103,49 +103,42 @@ class TestVhostPmdXstats(TestCase): """ according the scope to check results """ - out = self.vhost_user.send_expect( - "show port xstats 1", "testpmd>", 60) + out = self.vhost_user_pmd.execute_cmd("show port xstats 1") packet_rx = re.search("rx_%s_packets:\s*(\d*)" % scope, out) sum_packet_rx = packet_rx.group(1) packet_tx = re.search("tx_%s_packets:\s*(\d*)" % scope, out) sum_packet_tx = packet_tx.group(1) - self.verify(int(sum_packet_rx) >= mun, - "Insufficient the received packets from nic") - self.verify(int(sum_packet_tx) >= mun, - "Insufficient the received packets from virtio") + self.verify(int(sum_packet_rx) >= mun, "Insufficient the received packets from nic") + self.verify(int(sum_packet_tx) >= mun, "Insufficient the received packets from virtio") def start_vhost_testpmd(self): """ start testpmd on vhost """ - eal_param = self.dut.create_eal_parameters(socket=self.ports_socket, cores=self.core_list_host, prefix='vhost', - vdevs=['net_vhost0,iface=vhost-net,queues=2,client=0']) - command_line_client = "./%s " % self.app_testpmd_path + eal_param + ' -- -i --nb-cores=2 --rxq=2 --txq=2 --rss-ip' - self.vhost_user.send_expect(command_line_client, "testpmd> ", 120) - self.vhost_user.send_expect("set fwd io", "testpmd> ", 120) - self.vhost_user.send_expect("start", "testpmd> ", 120) + vdevs = ['net_vhost0,iface=vhost-net,queues=2,client=0'] + param = "--nb-cores=2 --rxq=2 --txq=2" + self.vhost_user_pmd.start_testpmd(cores=self.core_list_host, param=param, vdevs=vdevs,ports=[0], prefix="vhost") + self.vhost_user_pmd.execute_cmd("set fwd io") + self.vhost_user_pmd.execute_cmd("start") def start_virtio_testpmd(self, args): """ start testpmd on virtio """ - eal_param = self.dut.create_eal_parameters(socket=self.ports_socket, cores=self.core_list_user, prefix='virtio', - no_pci=True, vdevs=[ - 'net_virtio_user0,mac=00:01:02:03:04:05,path=./vhost-net,queues=2,%s' % args["version"]]) + eal_param = "" if self.check_2M_env: eal_param += " --single-file-segments" - command_line_user = "./%s " % self.app_testpmd_path + eal_param + " -- -i %s --rss-ip --nb-cores=2 --rxq=2 --txq=2" % \ - args["path"] - self.virtio_user.send_expect(command_line_user, "testpmd> ", 120) - self.virtio_user.send_expect("set fwd io", "testpmd> ", 120) - self.virtio_user.send_expect("start", "testpmd> ", 120) + vdevs = ['net_virtio_user0,mac=00:01:02:03:04:05,path=./vhost-net,queues=2,%s' % args["version"]] + param = "%s --rss-ip --nb-cores=2 --rxq=2 --txq=2" % args["path"] + self.virtio_user0_pmd.start_testpmd(cores=self.core_list_user, eal_param=eal_param, param=param, vdevs=vdevs, no_pci=True, prefix="virtio") + self.virtio_user0_pmd.execute_cmd("set fwd io") + self.virtio_user0_pmd.execute_cmd("start") def xstats_number_and_type_verify(self): """ Verify receiving and transmitting packets correctly in the Vhost PMD xstats """ - out = self.vhost_user.send_expect( - "show port xstats 1", "testpmd>", 60) + out = self.vhost_user_pmd.execute_cmd("show port xstats 1") p = re.compile(r'rx_size_[0-9]+_[to_\w+]*packets') categories = p.findall(out) categories = categories[:-1] @@ -330,14 +323,13 @@ class TestVhostPmdXstats(TestCase): """ close all testpmd of vhost and virtio """ - self.vhost_user.send_expect("quit", "#", 60) - self.virtio_user.send_expect("quit", "#", 60) + self.vhost_user_pmd.quit() + self.virtio_user0_pmd.quit() def clear_port_xstats(self, scope): - self.vhost_user.send_expect("clear port xstats 1", "testpmd>", 60) - out = self.vhost_user.send_expect( - "show port xstats 1", "testpmd>", 60) + self.vhost_user_pmd.execute_cmd("clear port xstats 1") + out = self.vhost_user_pmd.execute_cmd("show port xstats 1") packet = re.search("rx_%s_packets:\s*(\d*)" % scope, out) sum_packet = packet.group(1) self.verify(int(sum_packet) == 0, "Insufficient the received package") @@ -352,4 +344,5 @@ class TestVhostPmdXstats(TestCase): """ Run after each test suite. """ - pass + self.dut.close_session(self.vhost_user) + self.dut.close_session(self.virtio_user0) -- 2.25.1