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 B2729A0C40; Thu, 29 Jul 2021 03:39:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9046940040; Thu, 29 Jul 2021 03:39:10 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 9494F4003C for ; Thu, 29 Jul 2021 03:39:08 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10059"; a="200000657" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="200000657" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 18:39:06 -0700 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="506852569" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 18:39:05 -0700 From: Wei Ling To: dts@dpdk.org Cc: Wei Ling Date: Thu, 29 Jul 2021 09:32:09 +0800 Message-Id: <20210729013209.766590-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dts] [PATCH V2] 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" v1: 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. v2: Remove testcase 1 quit vhost and testpmd steps, because tear_down already have these steps. Signed-off-by: Wei Ling --- tests/TestSuite_vswitch_sample_cbdma.py | 34 +++++++++++-------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/tests/TestSuite_vswitch_sample_cbdma.py b/tests/TestSuite_vswitch_sample_cbdma.py index 08422ea3..e8be13de 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: @@ -358,8 +358,6 @@ class TestVswitchSampleCBDMA(TestCase): self.start_virtio_testpmd(pmd_session=self.virtio_user0_pmd, dev_mac=self.virtio_dst_mac0, dev_id=0, cores=self.vuser0_core_list, prefix='testpmd0', nb_cores=1, used_queues=1) split_ring_reult = self.pvp_test_with_cbdma() - self.virtio_user0_pmd.execute_cmd("quit", "#") - self.vhost_user.send_expect("^C", "# ", 20) self.table_header = ['Frame Size(Byte)', 'Mode', 'Throughput(Mpps)'] self.result_table_create(self.table_header) @@ -370,8 +368,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 +469,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 +562,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 +579,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 +612,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 +699,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 +777,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): -- 2.25.1