From: Nannan Lu <nannan.lu@intel.com>
To: dts@dpdk.org
Cc: Nannan Lu <nannan.lu@intel.com>
Subject: [dts] [PATCH V1 4/5] tests/rte_flow_common.py: add dcf check functions to tests/rte_flow_common.py
Date: Mon, 25 May 2020 18:10:02 +0000 [thread overview]
Message-ID: <20200525181003.25229-4-nannan.lu@intel.com> (raw)
In-Reply-To: <20200525181003.25229-1-nannan.lu@intel.com>
Add dcf check functions to tests/rte_flow_common.py.
Signed-off-by: Nannan Lu <nannan.lu@intel.com>
---
tests/rte_flow_common.py | 98 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 93 insertions(+), 5 deletions(-)
diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py
index 7592114..be0e434 100644
--- a/tests/rte_flow_common.py
+++ b/tests/rte_flow_common.py
@@ -35,7 +35,20 @@ import re
from utils import GREEN, RED
# switch filter common functions
-def get_packet_number(out,match_string):
+def get_suite_config(test_case):
+ """
+ get the suite config from conf/cvl_dcf_switch_filter.cfg.
+ """
+ suite_config = {}
+ if "ice_driver_file_location" in test_case.get_suite_cfg():
+ ice_driver_file_location = test_case.get_suite_cfg()["ice_driver_file_location"]
+ suite_config["ice_driver_file_location"] = ice_driver_file_location
+ if "os_default_package_file_location" in test_case.get_suite_cfg():
+ os_default_package_file_location = test_case.get_suite_cfg()["os_default_package_file_location"]
+ suite_config["os_default_package_file_location"] = os_default_package_file_location
+ return suite_config
+
+def get_rx_packet_number(out,match_string):
"""
get the rx packets number.
"""
@@ -55,7 +68,7 @@ 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_packet_number(out,match_string)
+ pkt_num = get_rx_packet_number(out,match_string)
return pkt_num
def get_queue_rx_packets_number(out, port_num, queue_id):
@@ -63,7 +76,7 @@ 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_packet_number(out,match_string)
+ pkt_num = get_rx_packet_number(out,match_string)
return pkt_num
def check_output_log_in_queue(out, func_param, expect_results):
@@ -195,14 +208,89 @@ def check_output_log_drop_mismatched(out, func_param, expect_results):
log_msg = "drop mismatched: port %d receive %d packets, should receive %d packet" % (expect_port, pkt_num, expect_pkts)
return False, log_msg
+def check_vf_rx_packets_number(out, func_param, expect_results, need_verify=True):
+ """
+ check the vf receives the correct number packets
+ """
+ expect_port = func_param["expect_port"]
+ expect_pkts = expect_results["expect_pkts"]
+
+ if isinstance(expect_port, list):
+ results = []
+ for i in range(0,len(expect_port)):
+ pkt_num = get_port_rx_packets_number(out, expect_port[i])
+ results.append(pkt_num)
+ if need_verify:
+ verify(results == expect_pkts, "failed: packets number not correct. expect %s, result %s" % (expect_pkts, results))
+ else:
+ return results
+ else:
+ pkt_num = get_port_rx_packets_number(out, expect_port)
+ if need_verify:
+ verify(pkt_num == expect_pkts, "failed: packets number not correct. expect %s, result %s" % (expect_pkts, pkt_num))
+ else:
+ return pkt_num
+
+def check_vf_rx_tx_packets_number(out, rx_func_param, rx_expect_results, tx_func_param, tx_expect_results):
+ """
+ check the vf receives and forwards the correct number packets
+ """
+ rx_expect_port = rx_func_param["expect_port"]
+ rx_expect_pkts = rx_expect_results["expect_pkts"]
+ tx_expect_port = tx_func_param["expect_port"]
+ tx_expect_pkts = tx_expect_results["expect_pkts"]
+
+ #check port receives and forwards the correct number packets
+ if isinstance(rx_expect_port, list):
+ results_rx_packets = []
+ results_tx_packets = []
+ for i in range(0,len(rx_expect_port)):
+ p = re.compile(
+ 'Forward\sstatistics\s+for\s+port\s+%d\s+.*\n.*RX-packets:\s(\d+)\s+RX-dropped:\s\d+\s+RX-total:\s\d+\s+.*\n.*TX-packets:\s(\d+)\s+TX-dropped:\s\d+\s+' % rx_expect_port[i])
+ pkt_li = p.findall(out)
+ results = list(map(int, list(pkt_li[0])))
+ results_rx_packets.append(results[0])
+ results_tx_packets.append(results[1])
+ verify(results_rx_packets == rx_expect_pkts and results_tx_packets == tx_expect_pkts, "failed: packets number not correct. expect_rx %s, result_rx %s, expect_tx %s, results_tx %s" % (rx_expect_pkts, results_rx_packets, tx_expect_pkts, results_tx_packets))
+ else:
+ p = re.compile(
+ 'Forward\sstatistics\s+for\s+port\s+%d\s+.*\n.*RX-packets:\s(\d+)\s+RX-dropped:\s\d+\s+RX-total:\s\d+\s+.*\n.*TX-packets:\s(\d+)\s+TX-dropped:\s\d+\s+' % rx_expect_port)
+ pkt_li = p.findall(out)
+ results = list(map(int, list(pkt_li[0])))
+ verify(results[0] == rx_expect_pkts and results[1] == tx_expect_pkts, "failed: packets number not correct. expect_rx %s, result_rx %s, expect_tx %s, result_tx %s" % (rx_expect_pkts, results[0], tx_expect_pkts, results[1]))
+
+ #check no packets are dropped for all ports
+ p = re.compile(
+ 'Accumulated\sforward\sstatistics\s+for\s+all\s+ports.*\n.*RX-packets:\s\d+\s+RX-dropped:\s\d+\s+RX-total:\s\d+\s+.*\n.*TX-packets:\s\d+\s+TX-dropped:\s(\d+)\s+')
+ pkt_li = p.findall(out)
+ results_dropped = int(pkt_li[0])
+ verify(results_dropped == 0, "failed: dropped packets should be 0.")
+
+def check_kernel_vf_rx_packets_number(out_vfs, expect_results):
+ """
+ check the kernel vf receives the correct number packets by command ifconfig
+ """
+ p = re.compile(r"RX\s+packets\s?(\d+)")
+ results = []
+ for out in out_vfs:
+ m = p.search(out)
+ if m:
+ pkt_num = int(m.group(1))
+ results.append(pkt_num)
+ else:
+ results.append(False)
+ verify(results == expect_results, "failed: packets number not correct. expect %s, result %s" % (expect_results, results))
+
def check_rule_in_list_by_id(out, rule_num, only_last=True):
"""
check if the rule with ID "rule_num" is in list, after
executing the command "flow list 0".
"""
- out_lines=out.splitlines()
- if len(out_lines) == 1:
+ p = re.compile(r"ID\s+Group\s+Prio\s+Attr\s+Rule")
+ m = p.search(out)
+ if not m:
return False
+ out_lines=out.splitlines()
if only_last:
last_rule = out_lines[len(out_lines)-1]
last_rule_list = last_rule.split('\t')
--
2.17.1
next prev parent reply other threads:[~2020-05-25 10:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-25 18:09 [dts] [PATCH V1 1/5] dep: add igmp.py to dep Nannan Lu
2020-05-25 18:10 ` [dts] [PATCH V1 2/5] packet.py: add igmp import Nannan Lu
2020-05-25 18:10 ` [dts] [PATCH V1 3/5] conf: add cvl_dcf_switch_filter.cfg to conf Nannan Lu
2020-05-25 18:10 ` Nannan Lu [this message]
2020-05-25 18:10 ` [dts] [PATCH V1 5/5] tests: add TestSuite_cvl_dcf_switch_filter.py to tests Nannan Lu
2020-05-25 11:12 ` Lu, Nannan
2020-06-01 3:13 ` [dts] [PATCH V1 1/5] dep: add igmp.py to dep 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=20200525181003.25229-4-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).