From patchwork Tue Aug 25 18:48:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Nannan" X-Patchwork-Id: 75913 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CD949A04B1; Tue, 25 Aug 2020 11:58:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B8A371C222; Tue, 25 Aug 2020 11:58:00 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 741DA1C1F5 for ; Tue, 25 Aug 2020 11:57:58 +0200 (CEST) IronPort-SDR: 5h6zUMPPcun9pucSmHLyeQBoEwICgJD7wrTxl7nA8pEtoNix1PNjKK2IIs33n5fPjEjPtrtnGk tywUgtx6w+MQ== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="153501179" X-IronPort-AV: E=Sophos;i="5.76,352,1592895600"; d="scan'208";a="153501179" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2020 02:57:58 -0700 IronPort-SDR: 0OgIebq4U+xbDK3QtjRMD/KT3F6pBp0DY3owzvZzLPdWsLMyJXKqmwHzjwEGybbtoWZptPySnT TbZkzR1jCerw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,352,1592895600"; d="scan'208";a="299045417" Received: from dpdk-lunannan.sh.intel.com ([10.67.111.68]) by orsmga006.jf.intel.com with ESMTP; 25 Aug 2020 02:57:57 -0700 From: Nannan Lu To: dts@dpdk.org Cc: Nannan Lu Date: Tue, 25 Aug 2020 18:48:28 +0000 Message-Id: <1598381309-753871-2-git-send-email-nannan.lu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598381309-753871-1-git-send-email-nannan.lu@intel.com> References: <1598381309-753871-1-git-send-email-nannan.lu@intel.com> Subject: [dts] [PATCH V1 2/3] tests/rte_flow_common.py: improve the check functions for cvl switch filter X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" tests/rte_flow_common.py: improve the check function for cvl switch filter Signed-off-by: Nannan Lu --- 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: