diff mbox series

[V1] tests/vswitch_sample_cbdma: fix script issues

Message ID 20210727063659.4090002-1-weix.ling@intel.com (mailing list archive)
State Superseded
Delegated to: LIjuan Tu
Headers show
Series [V1] tests/vswitch_sample_cbdma: fix script issues | expand

Commit Message

Ling, WeiX July 27, 2021, 6:36 a.m. UTC
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 <weix.ling@intel.com>
---
 tests/TestSuite_vswitch_sample_cbdma.py | 32 ++++++++++++-------------
 1 file changed, 15 insertions(+), 17 deletions(-)

Comments

Ling, WeiX July 27, 2021, 8:24 a.m. UTC | #1
> -----Original Message-----
> From: Ling, WeiX <weix.ling@intel.com>
> Sent: Tuesday, July 27, 2021 02:37 PM
> To: dts@dpdk.org
> Cc: Ling, WeiX <weix.ling@intel.com>
> Subject: [dts][PATCH V1] tests/vswitch_sample_cbdma: fix script issues
> 
Tested-by: Wei Ling <weix.ling@intel.com>
Wang, Yinan July 29, 2021, 5:04 a.m. UTC | #2
Acked-by:  Yinan Wang <yinan.wang@intel.com>

> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of Ling, WeiX
> Sent: 2021?7?27? 16:25
> To: dts@dpdk.org
> Subject: Re: [dts] [PATCH V1] tests/vswitch_sample_cbdma: fix script issues
> 
> > -----Original Message-----
> > From: Ling, WeiX <weix.ling@intel.com>
> > Sent: Tuesday, July 27, 2021 02:37 PM
> > To: dts@dpdk.org
> > Cc: Ling, WeiX <weix.ling@intel.com>
> > Subject: [dts][PATCH V1] tests/vswitch_sample_cbdma: fix script issues
> >
> Tested-by: Wei Ling <weix.ling@intel.com>
diff mbox series

Patch

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):