test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts][PATCH V1] tests/ntb: add support host_ports and client_ports option in launch_ntb_fwd()
@ 2023-06-27  5:34 Wei Ling
  0 siblings, 0 replies; only message in thread
From: Wei Ling @ 2023-06-27  5:34 UTC (permalink / raw)
  To: dts; +Cc: Wei Ling

1.TestCase 1 and 2 only need NTB pci, but testcase 3 need NTB pci and
  NIC pci to start dpdk-ntb app, so modify the launch_ntb_fwd() function
  to support host_ports and client_ports option.

2.Optimize the send_file_and_verify() to check the print info after
  execute `ntb> send /tmp/ntb.txt` command on host ntb server and client
  ntb server to verify the send and receive file sucessed or not.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 tests/TestSuite_ntb.py | 53 ++++++++++++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/tests/TestSuite_ntb.py b/tests/TestSuite_ntb.py
index 38d36689..e9b2c2f7 100644
--- a/tests/TestSuite_ntb.py
+++ b/tests/TestSuite_ntb.py
@@ -114,7 +114,7 @@ class TestNtb(TestCase):
         ntb = self.get_ntb_port(self.ntb_client)
         ntb.bind_driver(driver)
 
-    def launch_ntb_fwd(self, **param):
+    def launch_ntb_fwd(self, host_ports, client_ports, **param):
         """
         launch ntb_fwd on ntb host and ntb client
         """
@@ -123,10 +123,10 @@ class TestNtb(TestCase):
         self.get_core_list()
         app = self.dut.apps_name["ntb"]
         eal_host = self.ntb_host.create_eal_parameters(
-            cores=self.host_core_list, ports=[self.get_ntb_port(self.ntb_host).pci]
+            cores=self.host_core_list, ports=host_ports
         )
         eal_client = self.ntb_client.create_eal_parameters(
-            cores=self.client_core_list, ports=[self.get_ntb_port(self.ntb_client).pci]
+            cores=self.client_core_list, ports=client_ports
         )
         host_cmd_line = " ".join([app, eal_host, cmd_opt])
         client_cmd_line = " ".join([app, eal_client, cmd_opt])
@@ -219,17 +219,34 @@ class TestNtb(TestCase):
         src_file = "{}/ntb.txt".format(self.out_path)
         base_dir = self.ntb_client.base_dir.replace("~", "/root")
         dst_file = "{}/ntb_recv_file0".format(base_dir)
-        content = "ntb!123"
+        host_content = "ntb!123"
         self.ntb_client.alt_session.send_expect("rm {}".format(dst_file), "# ")
         self.ntb_host.alt_session.send_expect(
-            "echo '{}' >{}".format(content, src_file), "# "
+            "echo '{}' >{}".format(host_content, src_file), "# "
         )
-        self.ntb_host.send_expect("send {}".format(src_file), "ntb> ", 30)
-        time.sleep(3)
+        # check the print info after send file on NTB host server
+        host_out = self.ntb_host.send_expect("send {}".format(src_file), "ntb> ", 30)
+        host_reg = (
+            "send {}\r\r\nSending file, size is \d+\r\nDone sending file.".format(
+                src_file
+            )
+        )
+        host_info = re.findall(host_reg, host_out)
+        self.verify(len(host_info) == 1, "Send File FAILED!")
+
+        # check the print info after send file on NTB client server
+        client_out = self.ntb_client.get_session_output()
+        client_reg = " Received file \(size: \d+\) from peer to ntb_recv_file0.\r\n"
+        client_info = re.findall(client_reg, client_out)
+        self.verify(len(client_info) == 1, "Recieve File FAILED!")
 
         # Check file received on client.
-        cnt = self.ntb_client.alt_session.send_expect("cat %s" % dst_file, "# ")
-        self.verify(cnt == content, "the content can't match with the sent")
+        client_content = self.ntb_client.alt_session.send_expect(
+            "cat %s" % dst_file, "# "
+        )
+        self.verify(
+            client_content == host_content, "the content can't match with the sent"
+        )
 
     def send_pkg_and_verify(self):
         for frame_size in self.frame_sizes:
@@ -255,7 +272,9 @@ class TestNtb(TestCase):
         self.set_driver(driver)
         self.ntb_bind_driver(driver)
 
-        self.launch_ntb_fwd(**{"buf-size": 65407})
+        host_ports = [self.get_ntb_port(self.ntb_host).pci]
+        client_ports = [self.get_ntb_port(self.ntb_client).pci]
+        self.launch_ntb_fwd(host_ports, client_ports, **{"buf-size": 65407})
         self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode="file-trans")
         self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode="file-trans")
         self.send_file_and_verify()
@@ -265,7 +284,9 @@ class TestNtb(TestCase):
         self.set_driver(driver)
         self.ntb_bind_driver(driver)
 
-        self.launch_ntb_fwd(**{"buf-size": 65407})
+        host_ports = [self.get_ntb_port(self.ntb_host).pci]
+        client_ports = [self.get_ntb_port(self.ntb_client).pci]
+        self.launch_ntb_fwd(host_ports, client_ports, **{"buf-size": 65407})
         self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode="rxonly")
         self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode="txonly")
         time.sleep(1)
@@ -278,7 +299,15 @@ class TestNtb(TestCase):
         self.port_bind_driver(driver)
 
         self.create_table()
-        self.launch_ntb_fwd(**{"burst": 32})
+        host_ports = [
+            self.get_ntb_port(self.ntb_host).pci,
+            self.ntb_host.ports_info[0]["pci"],
+        ]
+        client_ports = [
+            self.get_ntb_port(self.ntb_client).pci,
+            self.ntb_client.ports_info[0]["pci"],
+        ]
+        self.launch_ntb_fwd(host_ports, client_ports, **{"burst": 32})
         self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode="iofwd")
         self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode="iofwd")
         self.send_pkg_and_verify()
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-27  5:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27  5:34 [dts][PATCH V1] tests/ntb: add support host_ports and client_ports option in launch_ntb_fwd() Wei Ling

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