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 V1 2/3] tests/rte_flow_common.py: improve the check functions for cvl switch filter
Date: Tue, 25 Aug 2020 18:48:28 +0000	[thread overview]
Message-ID: <1598381309-753871-2-git-send-email-nannan.lu@intel.com> (raw)
In-Reply-To: <1598381309-753871-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 | 60 +++++++++++++++++++++---------------------------
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py
index 5728af0..25c3bd0 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
@@ -34,8 +34,6 @@ import time
 import re
 from utils import GREEN, RED
 
-CVL_TXQ_RXQ_NUMBER = 16
-
 # switch filter common functions
 def get_suite_config(test_case):
     """
@@ -59,37 +57,31 @@ 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):
     """
     check if the expect queue received the expected number packets.
@@ -127,7 +119,7 @@ def check_output_log_queue_region(out, func_param, expect_results):
     if packet_sumnum == expect_pkts:
         return True, log_msg
     else:
-        log_msg = "queue region: Not all packets are received in expect_queues"
+        log_msg = "Not all packets are received in expect_queues. expect %s, result %s." % (expect_pkts, packet_sumnum)
         return False, log_msg
 
 def check_output_log_queue_region_mismatched(out, func_param, expect_results):
@@ -405,7 +397,7 @@ def check_mark(out, pkt_num, check_param, stats=True):
             else:
                 raise Exception("got wrong output, not match pattern %s" % p.pattern)
             if mark_id is not None:
-                mark_list = set(int(i, CVL_TXQ_RXQ_NUMBER) for i in fdir_scanner.findall(out))
+                mark_list = set(int(i, 16) for i in fdir_scanner.findall(out))
                 verify(all([i == check_param["mark_id"] for i in mark_list]),
                        "failed: some packet mark id of %s not match" % mark_list)
             else:
@@ -429,11 +421,11 @@ def check_mark(out, pkt_num, check_param, stats=True):
 def verify_directed_by_rss(out, rxq=64, stats=True):
     p = re.compile('RSS\shash=(\w+)\s-\sRSS\squeue=(\w+)')
     pkt_info = p.findall(out)
-    pkt_queue = set([int(i[1], CVL_TXQ_RXQ_NUMBER) for i in pkt_info])
+    pkt_queue = set([int(i[1], 16) for i in pkt_info])
     if stats:
-        verify(all([int(i[0], CVL_TXQ_RXQ_NUMBER) % rxq == int(i[1], CVL_TXQ_RXQ_NUMBER) for i in pkt_info]), 'some pkt not directed by rss.')
+        verify(all([int(i[0], 16) % rxq == int(i[1], 16) for i in pkt_info]), 'some pkt not directed by rss.')
     else:
-        verify(not any([int(i[0], CVL_TXQ_RXQ_NUMBER) % rxq == int(i[1], CVL_TXQ_RXQ_NUMBER) for i in pkt_info]), 'some pkt directed by rss')
+        verify(not any([int(i[0], 16) % rxq == int(i[1], 16) for i in pkt_info]), 'some pkt directed by rss')
     return pkt_queue
 
 
@@ -463,23 +455,23 @@ def check_iavf_fdir_queue(out, pkt_num, check_param, stats=True):
                 verify(not any(q == queue for q in res_queue), "fail: queue id should not matched, expect queue %s, got %s" % (queue, res_queue))
                 print((GREEN("pass: queue id %s not matched" % res_queue)))
             elif isinstance(queue, list):
-                verify_iavf_fdir_directed_by_rss(out, rxq=CVL_TXQ_RXQ_NUMBER, stats=True)
+                verify_iavf_fdir_directed_by_rss(out, rxq=16, stats=True)
                 print((GREEN("pass: queue id %s not matched" % res_queue)))
             else:
                 raise Exception("wrong action value, expect queue_index or queue_group")
     else:
         raise Exception("got wrong output, not match pattern %s" % p.pattern)
 
-def verify_iavf_fdir_directed_by_rss(out, rxq=CVL_TXQ_RXQ_NUMBER, stats=True):
+def verify_iavf_fdir_directed_by_rss(out, rxq=16, stats=True):
     p = re.compile("RSS hash=(0x\w+) - RSS queue=(0x\w+)")
     pkt_info = p.findall(out)
     if stats:
         for i in pkt_info:
-            verify((int(i[0],CVL_TXQ_RXQ_NUMBER) % rxq == int(i[1],CVL_TXQ_RXQ_NUMBER)), "some packets are not directed by RSS")
+            verify((int(i[0],16) % rxq == int(i[1],16)), "some packets are not directed by RSS")
             print(GREEN("pass: queue id %s is redirected by RSS hash value %s" % (i[1], i[0])))
     else:
         for i in pkt_info:
-            verify((int(i[0],CVL_TXQ_RXQ_NUMBER) % rxq != int(i[1],CVL_TXQ_RXQ_NUMBER)), "some packets are not directed by RSS")
+            verify((int(i[0],16) % rxq != int(i[1],16)), "some packets are not directed by RSS")
 
 def check_iavf_fdir_passthru(out, pkt_num, check_param, stats=True):
     # check the actual queue is distributed by RSS
@@ -490,7 +482,7 @@ def check_iavf_fdir_passthru(out, pkt_num, check_param, stats=True):
     p = re.compile('RSS\shash=(\w+)\s-\sRSS\squeue=(\w+)')
     pkt_hash = p.findall(out)
     verify(pkt_num == len(pkt_hash), "fail: got wrong number of passthru packets, expect passthru packet number %s, got %s." % (pkt_num, len(pkt_hash)))
-    verify_iavf_fdir_directed_by_rss(out, rxq=CVL_TXQ_RXQ_NUMBER, stats=True)
+    verify_iavf_fdir_directed_by_rss(out, rxq=16, stats=True)
 
 def check_iavf_fdir_mark(out, pkt_num, check_param, stats=True):
     mark_scanner = "FDIR matched ID=(0x\w+)"
@@ -504,7 +496,7 @@ def check_iavf_fdir_mark(out, pkt_num, check_param, stats=True):
             mark_list = [i for i in res]
             print("mark list is: ", mark_list)
             verify(len(res) == pkt_num, "get wrong number of packet with mark_id")
-            verify(all([int(i, CVL_TXQ_RXQ_NUMBER) == check_param["mark_id"] for i in res]),
+            verify(all([int(i, 16) == check_param["mark_id"] for i in res]),
                         "failed: some packet mark id of %s not match" % mark_list)
             if check_param.get("queue") is not None:
                 check_iavf_fdir_queue(out, pkt_num, check_param, stats)
@@ -634,7 +626,7 @@ def check_iavf_packets_rss_queue(out, count, rss_match=True):
                 packet_sumnum = packet_sumnum + int(packet_num)
 
     if rss_match:
-        if queue_flag == CVL_TXQ_RXQ_NUMBER and packet_sumnum == count:
+        if queue_flag == 16 and packet_sumnum == count:
             log_msg = "Packets has send to %s queues" % queue_flag
             return True, log_msg
         else:
-- 
2.7.4


  reply	other threads:[~2020-08-25  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-25 18:48 [dts] [PATCH V1 1/3] conf/cvl_switch_filter.cfg: add cvl_switch_filter.cfg Nannan Lu
2020-08-25 18:48 ` Nannan Lu [this message]
2020-08-25 18:48 ` [dts] [PATCH V1 3/3] tests/TestSuite_cvl_switch_filter.py: add PPPOE cases and modify the format Nannan Lu

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=1598381309-753871-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).