From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 42C76A04EF; Mon, 1 Jun 2020 10:59:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3A2901C19F; Mon, 1 Jun 2020 10:59:07 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 3D96D1C10B for ; Mon, 1 Jun 2020 10:59:05 +0200 (CEST) IronPort-SDR: 8CpUxH21ETZJTOeROBMPIMo/hKEPXvpr2VUoTFB13UGDzrPKq8fu0U1HPDEBoRD0jLTMlxnnLB 7atkZFo6m9aA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2020 01:59:04 -0700 IronPort-SDR: BZKzrjJe7ld4EPAKWdOs5SkWN6O/xW9Jgg24qlN3jx5Br3ukD4hj2NzgqzvuA8Cl2HU6G33sRK 3SQxVYbZctag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,460,1583222400"; d="scan'208";a="346972049" Received: from unknown (HELO xqm-virtio_tester.sh.intel.com) ([10.240.183.52]) by orsmga001.jf.intel.com with ESMTP; 01 Jun 2020 01:59:03 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Mon, 1 Jun 2020 16:51:09 +0800 Message-Id: <1591001469-51901-4-git-send-email-qimaix.xiao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591001469-51901-1-git-send-email-qimaix.xiao@intel.com> References: <1591001469-51901-1-git-send-email-qimaix.xiao@intel.com> Subject: [dts] [PATCH V1 3/3]rte_flow_common: update tests/rte_flow_common.py for cvl fdir update 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" Signed-off-by: Xiao Qimai --- tests/rte_flow_common.py | 101 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 31 deletions(-) diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py index be0e434..aba05c2 100644 --- a/tests/rte_flow_common.py +++ b/tests/rte_flow_common.py @@ -318,35 +318,37 @@ def verify(passed, description): if not passed: raise AssertionError(description) -def check_queue(out, pkt_num, check_param, stats=True): + +def check_queue(out, check_param, stats=True): port_id = check_param["port_id"] if check_param.get("port_id") is not None else 0 queue = check_param["queue"] - p = re.compile( - r"Forward Stats for RX Port= %s/Queue=(\s?\d+)\s.*\n.*RX-packets:(\s?\d+)\s+TX-packets" % port_id) + p = re.compile(r"port\s+%s/queue(.+?):\s+received\s+(\d+)\s+packets" % port_id) res = p.findall(out) if res: - res_queue = [int(i[0]) for i in res] - pkt_li = [int(i[1]) for i in res] - res_num = sum(pkt_li) - verify(res_num == pkt_num, "fail: got wrong number of packets, expect pakcet number %s, got %s." % (pkt_num, res_num)) + pkt_queue = set([int(i[0]) for i in res]) if stats: if isinstance(queue, int): - verify(all(q == queue for q in res_queue), "fail: queue id not matched, expect queue %s, got %s" % (queue, res_queue)) - print((GREEN("pass: queue id %s matched" % res_queue))) + verify(all(q == queue for q in pkt_queue), + "fail: queue id not matched, expect queue %s, got %s" % (queue, pkt_queue)) + print((GREEN("pass: queue id %s matched" % pkt_queue))) elif isinstance(queue, list): - verify(all(q in queue for q in res_queue), "fail: queue id not matched, expect queue %s, got %s" % (queue, res_queue)) - print((GREEN("pass: queue id %s matched" % res_queue))) + verify(all(q in queue for q in pkt_queue), + "fail: queue id not matched, expect queue %s, got %s" % (queue, pkt_queue)) + print((GREEN("pass: queue id %s matched" % pkt_queue))) else: raise Exception("wrong queue value, expect int or list") else: if isinstance(queue, int): - 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))) + verify(not any(q == queue for q in pkt_queue), + "fail: queue id should not matched, expect queue %s, got %s" % (queue, pkt_queue)) + print((GREEN("pass: queue id %s not matched" % pkt_queue))) elif isinstance(queue, list): - verify(not any(q in queue for q in res_queue), "fail: each queue in %s should not in queue %s" % (res_queue, queue)) - print((GREEN("pass: queue id %s not matched" % res_queue))) + verify(not any(q in queue for q in pkt_queue), + "fail: each queue in %s should not in queue %s" % (pkt_queue, queue)) + print((GREEN("pass: queue id %s not matched" % pkt_queue))) else: raise Exception("wrong action value, expect queue_index or queue_group") + return pkt_queue else: raise Exception("got wrong output, not match pattern %s" % p.pattern) @@ -359,34 +361,71 @@ def check_drop(out, pkt_num, check_param, stats=True): pkt_li = p.findall(out) if pkt_li: res = {k: v for k, v in zip(title_li, list(map(int, list(pkt_li[0]))))} - verify(pkt_num == res["rx-total"], "failed: get wrong amount of packet %d, expected %d" % (res["rx-total"], pkt_num)) + verify(pkt_num == res["rx-total"], + "failed: get wrong amount of packet %d, expected %d" % (res["rx-total"], pkt_num)) if stats: verify(res["rx-dropped"] == pkt_num, "failed: dropped packets number %s not match" % res["rx-dropped"]) else: - verify(res["rx-dropped"] == 0 and res["rx-packets"] == pkt_num, "failed: dropped packets number should be 0") + verify(res["rx-dropped"] == 0 and res["rx-packets"] == pkt_num, + "failed: dropped packets number should be 0") else: raise Exception("got wrong output, not match pattern %s" % p.pattern) def check_mark(out, pkt_num, check_param, stats=True): - mark_scanner = "FDIR matched ID=(0x\w+)" - res = re.findall(mark_scanner, out[0]) + mark_id = check_param.get("mark_id") + queue = check_param.get("queue") + rss_flag = check_param.get("rss") + rxq = check_param['rxq'] if check_param.get("rxq") is not None else 64 + drop_flag = check_param.get("drop") + port_id = check_param["port_id"] if check_param.get("port_id") is not None else 0 + fdir_scanner = re.compile("FDIR matched ID=(0x\w+)") + fdir_flag = fdir_scanner.search(out) + pkt_queue = None if stats: - if check_param.get("queue") is not None: - check_queue(out[1], pkt_num, check_param, stats) - mark_list = [i[0] for i in res] - verify(len(res) == pkt_num, "get wrong number of packet with mark_id") - 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 drop_flag is None: + p = re.compile(r"port\s+%s/queue(.+?):\s+received\s+(\d+)\s+packets" % port_id) + res = p.findall(out) + if res: + pkt_li = [int(i[1]) for i in res] + res_num = sum(pkt_li) + verify(res_num == pkt_num, + "fail: got wrong number of packets, expect pakcet number %s, got %s." % (pkt_num, res_num)) + else: + raise Exception("got wrong output, not match pattern %s" % p.pattern) + if mark_id is not None: + 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: + verify(not fdir_flag, "output should not include mark id") + if queue is not None: + pkt_queue = check_queue(out, check_param, stats) + if rss_flag: + verify_directed_by_rss(out, rxq, stats=True) else: - check_drop(out[1], pkt_num, check_param, stats) - verify(not res, "should has no mark_id in %s" % res) + check_drop(out, pkt_num, check_param, stats) + verify(not fdir_flag, "should has no mark_id in %s" % out) else: - if check_param.get("queue") is not None: - check_queue(out[1], pkt_num, check_param, stats) + if drop_flag is None: + if queue is not None: + pkt_queue = verify_directed_by_rss(out, rxq, stats=True) else: - check_drop(out[1], pkt_num, check_param, stats) - verify(not res, "should has no mark_id in %s" % res) + check_drop(out, pkt_num, check_param, stats) + verify(not fdir_flag, "should has no mark_id in %s" % out) + return pkt_queue + + +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], 16) for i in pkt_info]) + if stats: + 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], 16) % rxq == int(i[1], 16) for i in pkt_info]), 'some pkt directed by rss') + return pkt_queue + # rss common functions def check_packets_of_each_queue(out): -- 1.8.3.1