diff mbox series

[V2] tests/multiprocess modify the regular expression

Message ID 20220830081231.1255-1-dukaix.yuan@intel.com (mailing list archive)
State Changes Requested
Headers show
Series [V2] tests/multiprocess modify the regular expression | expand

Checks

Context Check Description
ci/Intel-dts-suite-test success Testing OK
ci/Intel-dts-pylama-test success Testing OK
ci/Intel-dts-format-test success Testing OK

Commit Message

Dukai Yuan Aug. 30, 2022, 8:12 a.m. UTC
Modify re.search to re.findall to get all the list.

Signed-off-by: Dukai Yuan <dukaix.yuan@intel.com>
---
 tests/TestSuite_multiprocess.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Tu, Lijuan Sept. 2, 2022, 1:36 a.m. UTC | #1
> -----Original Message-----
> From: Dukai Yuan <dukaix.yuan@intel.com>
> Sent: Tuesday, August 30, 2022 4:13 PM
> To: dts@dpdk.org
> Cc: Yuan, DukaiX <dukaix.yuan@intel.com>
> Subject: [dts][PATCH V2] tests/multiprocess modify the regular expression
> 
> Modify re.search to re.findall to get all the list.
> 
> Signed-off-by: Dukai Yuan <dukaix.yuan@intel.com>
> ---
>  tests/TestSuite_multiprocess.py | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/TestSuite_multiprocess.py b/tests/TestSuite_multiprocess.py
> index da382a41..3d408ea9 100644
> --- a/tests/TestSuite_multiprocess.py
> +++ b/tests/TestSuite_multiprocess.py
> @@ -175,6 +175,7 @@ class TestMultiprocess(TestCase):
>                  pktnum=pkt_num,
>                  dstmac="00:11:22:33:44:55",
>              )
> +        time.sleep(3)

It's not a good idea to wait 3 second, another option is to wait for the specific event which it requires.
diff mbox series

Patch

diff --git a/tests/TestSuite_multiprocess.py b/tests/TestSuite_multiprocess.py
index da382a41..3d408ea9 100644
--- a/tests/TestSuite_multiprocess.py
+++ b/tests/TestSuite_multiprocess.py
@@ -175,6 +175,7 @@  class TestMultiprocess(TestCase):
                 pktnum=pkt_num,
                 dstmac="00:11:22:33:44:55",
             )
+        time.sleep(3)
         pkt.send_pkt(crb=self.tester, tx_port=self.tester_ifaces[0], count=1)
 
     def specify_packet(self, que_num):
@@ -1014,10 +1015,13 @@  class TestMultiprocess(TestCase):
                 self.logger.err("Error occured:{}".format(traceback.format_exc(e)))
             finally:
                 session_obj.close()
-        res = re.search(
-            r"Port \d+\s+-\s+rx:\s+(?P<rx>\d+)\s+tx:.*PORTS", out, re.DOTALL
+        res = re.findall(
+            r"Port \d+\s+-\s+rx:\s+\d+.*?Client\s+[1]\s+-.*?tx_drop:\s+\d+",
+            out,
+            re.DOTALL,
         )
-        rx_num = re.findall(r"Client\s+\d\s+-\s+rx:\s+(\d+)", res.group(0))
+        rx_num = re.findall(r"Client\s+\d\s+-\s+rx:\s+(\d+)", res[-1])
+
         for i in range(proc_num):
             self.verify(
                 int(rx_num[i]) > 0,