test suite reviews and discussions
 help / color / mirror / Atom feed
From: Nannan Lu <nannan.lu@intel.com>
To: dts@dpdk.org
Cc: Nannan Lu <nannan.lu@intel.com>
Subject: [dts] [PATCH V2 2/3] tests/rte_flow_common.py: improve the check functions for cvl switch filter
Date: Thu, 27 Aug 2020 13:47:00 +0000	[thread overview]
Message-ID: <1598536021-771221-2-git-send-email-nannan.lu@intel.com> (raw)
In-Reply-To: <1598536021-771221-1-git-send-email-nannan.lu@intel.com>

tests/rte_flow_common.py: improve the check function for cvl switch filter

Signed-off-by: Nannan Lu <nannan.lu@intel.com>
---
 tests/rte_flow_common.py | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py
index e80575e..8a4cded 100644
--- a/tests/rte_flow_common.py
+++ b/tests/rte_flow_common.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2019 Intel Corporation. All rights reserved.
+# Copyright(c) 2019-2020 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -59,35 +59,28 @@ def get_suite_config(test_case):
         suite_config["package_file_location"] = package_file_location
     return suite_config
 
-def get_rx_packet_number(out,match_string):
-    """
-    get the rx packets number.
-    """
-    out_lines=out.splitlines()
-    pkt_num =0
-    for i in range(len(out_lines)):
-        if  match_string in out_lines[i]:
-            result_scanner = r'RX-packets:\s?(\d+)'
-            scanner = re.compile(result_scanner, re.DOTALL)
-            m = scanner.search(out_lines[i+1])
-            pkt_num = int(m.group(1))
-            break
-    return pkt_num
-
 def get_port_rx_packets_number(out,port_num):
     """
     get the port rx packets number.
     """
-    match_string="---------------------- Forward statistics for port %d" % port_num
-    pkt_num = get_rx_packet_number(out,match_string)
+    p = re.compile(
+        'Forward\sstatistics\s+for\s+port\s+%s\s+.*\n.*RX-packets:\s(\d+)\s+' % port_num)
+    m = p.search(out)
+    pkt_num = 0
+    if m:
+        pkt_num = int(m.group(1))
     return pkt_num
 
 def get_queue_rx_packets_number(out, port_num, queue_id):
     """
     get the queue rx packets number.
     """
-    match_string="------- Forward Stats for RX Port= %d/Queue= %d" % (port_num, queue_id)
-    pkt_num = get_rx_packet_number(out,match_string)
+    p = re.compile(
+        'Forward\sStats\s+for\s+RX\s+Port=\s*%d/Queue=\s*%d\s+.*\n.*RX-packets:\s(\d+)\s+' % (port_num, queue_id))
+    m = p.search(out)
+    pkt_num = 0
+    if m:
+        pkt_num = int(m.group(1))
     return pkt_num
 
 def check_output_log_in_queue(out, func_param, expect_results):
-- 
2.7.4


  reply	other threads:[~2020-08-27  4:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27 13:46 [dts] [PATCH V2 1/3] conf: add cvl_switch_filter.cfg Nannan Lu
2020-08-27 13:47 ` Nannan Lu [this message]
2020-08-27 13:47 ` [dts] [PATCH V2 3/3] tests/TestSuite_cvl_switch_filter.py: add PPPOE cases and modify the format Nannan Lu
2020-08-27  5:03   ` Tu, Lijuan

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=1598536021-771221-2-git-send-email-nannan.lu@intel.com \
    --to=nannan.lu@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).