From patchwork Tue Jul 27 06:36:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ling, WeiX" X-Patchwork-Id: 96308 X-Patchwork-Delegate: lijuan.tu@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1A410A0C4D; Tue, 27 Jul 2021 08:43:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D4DC0410ED; Tue, 27 Jul 2021 08:43:45 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 6F986410EC for ; Tue, 27 Jul 2021 08:43:43 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10057"; a="209270725" X-IronPort-AV: E=Sophos;i="5.84,272,1620716400"; d="scan'208";a="209270725" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2021 23:43:42 -0700 X-IronPort-AV: E=Sophos;i="5.84,272,1620716400"; d="scan'208";a="516698505" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2021 23:43:40 -0700 From: Wei Ling To: dts@dpdk.org Cc: Wei Ling Date: Tue, 27 Jul 2021 14:36:59 +0800 Message-Id: <20210727063659.4090002-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [dts] [PATCH V1] tests/vswitch_sample_cbdma: fix script issues 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.Move self.vm_dut and self.vm from set_up_all to setup. 2.Add bind_dev parameter in start_vms method to make diff case can bind the NIC into DPDK or not. 3.Add stop_all_apps and use it in tear_down to stop all apps. Signed-off-by: Wei Ling Tested-by: Wei Ling Acked-by: Yinan Wang --- tests/TestSuite_vswitch_sample_cbdma.py | 32 ++++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/tests/TestSuite_vswitch_sample_cbdma.py b/tests/TestSuite_vswitch_sample_cbdma.py index 08422ea3..62ff8de9 100644 --- a/tests/TestSuite_vswitch_sample_cbdma.py +++ b/tests/TestSuite_vswitch_sample_cbdma.py @@ -81,8 +81,6 @@ class TestVswitchSampleCBDMA(TestCase): self.vm_dst_mac0 = '52:54:00:00:00:01' self.vm_dst_mac1 = '52:54:00:00:00:02' self.vm_num = 2 - self.vm_dut = [] - self.vm = [] self.app_testpmd_path = self.dut.apps_name['test-pmd'] # create an instance to set stream field setting self.pktgen_helper = PacketGeneratorHelper() @@ -107,6 +105,8 @@ class TestVswitchSampleCBDMA(TestCase): """ self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#") self.dut.send_expect("killall -I qemu-system-x86_64", '#', 20) + self.vm_dut = [] + self.vm = [] def set_max_queues(self, max_queues=512): self.logger.info("Configure MAX_QUEUES to {}".format(max_queues)) @@ -172,7 +172,7 @@ class TestVswitchSampleCBDMA(TestCase): pmd_session.start_testpmd(cores=cores, param=params, eal_param=eal_params, no_pci=True, ports=[], prefix=prefix, fixed_prefix=True) - def start_vms(self, mode=0, mergeable=True, server_mode=False, set_target=True): + def start_vms(self, mode=0, mergeable=True, server_mode=False, set_target=True, bind_dev=True): """ start two VM, each VM has one virtio device """ @@ -202,7 +202,7 @@ class TestVswitchSampleCBDMA(TestCase): vm_info.set_vm_device(**vm_params) time.sleep(3) try: - vm_dut = vm_info.start(set_target=set_target) + vm_dut = vm_info.start(set_target=set_target, bind_dev=bind_dev) if vm_dut is None: raise Exception("Set up VM ENV failed") except Exception as e: @@ -370,8 +370,6 @@ class TestVswitchSampleCBDMA(TestCase): for table_row in perf_result: self.result_table_add(table_row) self.result_table_print() - self.virtio_user0_pmd.execute_cmd("quit", "#") - self.vhost_user.send_expect("^C", "# ", 20) def config_stream_imix(self, frame_sizes, port_num, dst_mac_list): tgen_input = [] @@ -473,9 +471,6 @@ class TestVswitchSampleCBDMA(TestCase): for table_row in perf_result: self.result_table_add(table_row) self.result_table_print() - self.virtio_user0_pmd.execute_cmd("quit", "#") - self.virtio_user1_pmd.execute_cmd("quit", "#") - self.vhost_user.send_expect("^C", "# ", 20) def get_receive_throughput(self, pmd_session, count=10): i = 0 @@ -569,9 +564,6 @@ class TestVswitchSampleCBDMA(TestCase): for table_row in perf_result: self.result_table_add(table_row) self.result_table_print() - self.virtio_user0_pmd.execute_cmd("quit", "# ") - self.virtio_user1_pmd.execute_cmd("quit", "# ") - self.vhost_user.send_expect("^C", "# ", 20) def vm2vm_check_with_two_vhost_device(self): rx_throughput = {} @@ -589,7 +581,7 @@ class TestVswitchSampleCBDMA(TestCase): def start_vms_testpmd_and_test(self, need_start_vm=True): if need_start_vm: - self.start_vms(mode=2, mergeable=True, server_mode=True) + self.start_vms(mode=2, mergeable=True, server_mode=True, set_target=True, bind_dev=True) self.vm0_pmd = PmdOutput(self.vm_dut[0]) self.vm1_pmd = PmdOutput(self.vm_dut[1]) self.start_vm_testpmd(self.vm0_pmd) @@ -622,9 +614,6 @@ class TestVswitchSampleCBDMA(TestCase): # repeat bind 50 time from virtio-pci to vfio-pci self.repeat_bind_driver(dut=self.vm_dut[0], repeat_times=50) self.repeat_bind_driver(dut=self.vm_dut[1], repeat_times=50) - for i in range(len(self.vm)): - self.vm[i].stop() - self.vhost_user.send_expect("^C", "# ", 20) self.table_header = ['Frame Size(Byte)', 'Before/After Bind VM Driver', 'Throughput(Mpps)'] self.result_table_create(self.table_header) @@ -712,7 +701,7 @@ class TestVswitchSampleCBDMA(TestCase): def start_iperf_and_scp_test_in_vms(self, need_start_vm=True, mode=0, mergeable=False, server_mode=False): if need_start_vm: - self.start_vms(mode=mode, mergeable=mergeable, server_mode=server_mode, set_target=False) + self.start_vms(mode=mode, mergeable=mergeable, server_mode=server_mode, set_target=True, bind_dev=False) self.vm0_pmd = PmdOutput(self.vm_dut[0]) self.vm1_pmd = PmdOutput(self.vm_dut[1]) self.config_vm_env() @@ -790,10 +779,19 @@ class TestVswitchSampleCBDMA(TestCase): if getattr(self, 'virtio-user1', None): self.dut.close_session(self.virtio_user1) + def stop_all_apps(self): + for i in range(len(self.vm)): + self.vm[i].stop() + self.virtio_user0_pmd.quit() + self.virtio_user1_pmd.quit() + self.vhost_user.send_expect("^C", "# ", 20) + def tear_down(self): """ Run after each test case. """ + self.stop_all_apps() + self.dut.kill_all() self.bind_cbdma_device_to_kernel() def tear_down_all(self):