test suite reviews and discussions
 help / color / mirror / Atom feed
From: Hailin Xu <hailinx.xu@intel.com>
To: dts@dpdk.org, qi.fu@intel.com
Cc: Hailin Xu <hailinx.xu@intel.com>
Subject: [dts][PATCH v1 1/2] tests/rte_flow_common: add priority common interface
Date: Mon, 20 Dec 2021 21:50:57 +0800	[thread overview]
Message-ID: <20211220135058.3864-2-hailinx.xu@intel.com> (raw)
In-Reply-To: <20211220135058.3864-1-hailinx.xu@intel.com>

add flow priority common interface

Signed-off-by: Hailin Xu <hailinx.xu@intel.com>
---
 tests/rte_flow_common.py | 61 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py
index 969d3222..1fca08ad 100644
--- a/tests/rte_flow_common.py
+++ b/tests/rte_flow_common.py
@@ -1297,3 +1297,64 @@ class FdirProcessing(object):
             if not v:
                 failed_cases.append(k)
         self.verify(all(test_results.values()), "{} failed".format(failed_cases))
+
+    def send_pkt_get_out(self, pkts, port_id=0, count=1, interval=0):
+        tx_port = self.tester_ifaces[0] if port_id == 0 else self.tester_ifaces[1]
+        self.logger.info('----------send packet-------------')
+        self.logger.info('{}'.format(pkts))
+        self.pmd_output.execute_cmd("start")
+        self.pmd_output.execute_cmd("clear port stats all")
+        self.pkt.update_pkt(pkts)
+        self.pkt.send_pkt(crb=self.test_case.tester, tx_port=tx_port, count=count, interval=interval)
+
+        out1 = self.pmd_output.get_output(timeout=1)
+        out2 = self.pmd_output.execute_cmd("stop")
+        return out1 + out2
+
+    def check_rx_packets(self, out, check_param, expect_pkt, stats=True):
+        queue = check_param['queue']
+        p = 'Forward\s+statistics\s+for\s+port\s+0.*\n.*?RX-packets:\s(\d+)\s+'
+        if queue == 'null':
+            pkt_num = re.search(p, out).group(1)
+            if stats:
+                self.verify(int(pkt_num) == 0, "receive %s packets, expect receive 0 packets" % pkt_num)
+            else:
+                self.verify(int(pkt_num) == expect_pkt, "receive {} packets, expect receive {} packets".format(pkt_num, expect_pkt))
+        else:
+            check_queue(out, check_param, stats=stats)
+
+    def handle_priority_cases(self, vectors):
+        rule = vectors['rule']
+        packets = vectors['packet']
+        check_param = vectors['check_param']
+        self.validate_rule(rule)
+        rule_list = self.create_rule(rule)
+        self.check_rule(rule_list=rule_list)
+        out = self.send_pkt_get_out(packets['matched'])
+        self.check_rx_packets(out, check_param['check_0'], len(packets['matched']))
+        out = self.send_pkt_get_out(packets['mismatched'])
+        self.check_rx_packets(out, check_param['check_0'], len(packets['mismatched']), stats=False)
+
+        # destroy rule with priority 0
+        self.destroy_rule(rule_id=rule_list[0])
+        self.check_rule(rule_list=rule_list[1:])
+        out = self.send_pkt_get_out(packets['matched'])
+        self.check_rx_packets(out, check_param['check_1'], len(packets['matched']))
+        out = self.send_pkt_get_out(packets['mismatched'])
+        self.check_rx_packets(out, check_param['check_0'], len(packets['mismatched']), stats=False)
+        self.check_rx_packets(out, check_param['check_1'], len(packets['mismatched']), stats=False)
+
+        # destroy rule with priority 1
+        rule_id = self.create_rule(rule[0])
+        self.destroy_rule(rule_id=rule_list[1])
+        self.check_rule(rule_list=rule_id)
+        out = self.send_pkt_get_out(packets['matched'])
+        self.check_rx_packets(out, check_param['check_0'], len(packets['matched']))
+        out = self.send_pkt_get_out(packets['mismatched'])
+        self.check_rx_packets(out, check_param['check_0'], len(packets['mismatched']), stats=False)
+
+        # destroy all rule
+        self.destroy_rule(rule_id=rule_id)
+        out = self.send_pkt_get_out(packets['matched'])
+        self.check_rx_packets(out, check_param['check_0'], len(packets['matched']), stats=False)
+        self.check_rx_packets(out, check_param['check_1'], len(packets['matched']), stats=False)
-- 
2.17.1


  reply	other threads:[~2021-12-20  6:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 13:50 [dts][PATCH v1 0/2] add pf priority cases Hailin Xu
2021-12-20 13:50 ` Hailin Xu [this message]
2021-12-20 13:50 ` [dts][PATCH v1 2/2] tests/cvl_pf_flow_priority: add pf flow " Hailin Xu
2021-12-20 14:05 [dts][PATCH v1 0/2] add pf " Hailin Xu
2021-12-20 14:05 ` [dts][PATCH v1 1/2] tests/rte_flow_common: add priority common interface Hailin Xu

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=20211220135058.3864-2-hailinx.xu@intel.com \
    --to=hailinx.xu@intel.com \
    --cc=dts@dpdk.org \
    --cc=qi.fu@intel.com \
    /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).