test suite reviews and discussions
 help / color / mirror / Atom feed
From: Wei Ling <weix.ling@intel.com>
To: dts@dpdk.org
Cc: Wei Ling <weix.ling@intel.com>
Subject: [dts] [PATCH V2] tests/vswitch_sample_cbdma: fix script issues
Date: Thu, 29 Jul 2021 09:32:09 +0800	[thread overview]
Message-ID: <20210729013209.766590-1-weix.ling@intel.com> (raw)

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 <weix.ling@intel.com>
---
 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


             reply	other threads:[~2021-07-29  1:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29  1:32 Wei Ling [this message]
2021-07-29  1:41 ` Ling, WeiX
2021-07-29  5:03   ` Wang, Yinan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210729013209.766590-1-weix.ling@intel.com \
    --to=weix.ling@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).