test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1]tests/cvl_switch_filter:optimization_cvl_switch_filter
@ 2020-06-05 14:47 Zeng Xiaoxiao
  2020-06-05  6:39 ` Zeng, XiaoxiaoX
  2020-06-08  3:00 ` Lu, Nannan
  0 siblings, 2 replies; 3+ messages in thread
From: Zeng Xiaoxiao @ 2020-06-05 14:47 UTC (permalink / raw)
  To: dts; +Cc: Zeng Xiaoxiao

*.Avoid that with different dpdk code, packet default queue same as
queue that rule set, realize dynamic set rule in testpmd.

Signed-off-by: Zeng Xiaoxiao <xiaoxiaox.zeng@intel.com>
---
 tests/TestSuite_cvl_switch_filter.py | 68 +++++++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)

diff --git a/tests/TestSuite_cvl_switch_filter.py b/tests/TestSuite_cvl_switch_filter.py
index ffd9af4..9731c37 100644
--- a/tests/TestSuite_cvl_switch_filter.py
+++ b/tests/TestSuite_cvl_switch_filter.py
@@ -34,6 +34,7 @@ import json
 import time
 import re
 import copy
+import random
 
 from test_case import TestCase
 from pmd_output import PmdOutput
@@ -2571,6 +2572,35 @@ class SwitchFilterTest(TestCase):
         result_flag, log_msg = dic["check_func"]["func"](out, dic["check_func"]["param"], dic["expect_results"])
         return result_flag, log_msg
 
+    def send_packet_get_queue(self, dic):
+        """
+        general packets processing workflow.
+        """
+        self.dut.send_expect("start", "testpmd> ")
+        # send packets
+        for per_packet in dic["scapy_str"]:
+            pkt = Packet(pkt_str=per_packet)
+            pkt.send_pkt(self.tester, tx_port=self.__tx_iface, count=1)
+        out = self.dut.send_expect("stop", "testpmd> ")
+        p = re.compile(r"Forward Stats for RX Port= \d+/Queue=(\s?\d+)")
+        res = p.findall(out)
+        default_queue = [int(i) for i in res]
+        return default_queue
+
+    def get_available_queue_num(self, default_queue):
+        """
+        general packets processing workflow.
+        """
+        queue_list = [1, 2, 3, 4, 5, 6]
+        for q in default_queue:
+            if q in queue_list:
+                queue_list.remove(q)
+            if (q - 1) in queue_list:
+                queue_list.remove(q - 1)
+
+        set_queue = random.choice(queue_list)
+        return int(set_queue)
+
     def save_results(self, pattern_name, flag, result_flag, log_msg, overall_result):
         """
         save results to dictionary: test_results.
@@ -2598,10 +2628,46 @@ class SwitchFilterTest(TestCase):
         overall_result = True
         test_results.clear()
         for tv in test_vectors:
+            # get packet default_queue number
+            mismatched_dic = tv["mismatched"]
+            default_queue = self.send_packet_get_queue(mismatched_dic)
+
+            # check if default_queue same with expect_queue
+            expect_queue = tv["mismatched"]["check_func"]["param"]["expect_queues"]
+            if expect_queue != "null":
+                if isinstance(expect_queue, int):
+                    eq_list = []
+                    eq_list.append(expect_queue)
+                elif isinstance(expect_queue, list):
+                    eq_list = expect_queue
+                recover_flag = list(set(eq_list) & set(default_queue))
+            else:
+                recover_flag = None
+
+            # if default_queue has same one with expect_queue, recover rule
+            if recover_flag:
+                # exclude defult_queue number and get set_queue
+                set_queue_num = self.get_available_queue_num(default_queue)
+                # recover rule command and check queue
+                if isinstance(expect_queue, int):
+                    rule_command = tv["rte_flow_pattern"].replace("/ end actions queue index %s" % str(expect_queue),
+                                                                  "/ end actions queue index %s" % str(set_queue_num))
+                    tv["matched"]["check_func"]["param"]["expect_queues"] = set_queue_num
+                    tv["mismatched"]["check_func"]["param"]["expect_queues"] = set_queue_num
+                elif isinstance(expect_queue, list):
+                    q = [str(i) for i in expect_queue]
+                    expect_queue_str = " ".join(q)
+                    rule_command = tv["rte_flow_pattern"].replace("/ end actions rss queues %s" % expect_queue_str,
+                                                                  "/ end actions rss queues %s" % (str(set_queue_num) + " " + str(set_queue_num + 1)))
+                    tv["matched"]["check_func"]["param"]["expect_queues"] = [set_queue_num, set_queue_num + 1]
+                    tv["mismatched"]["check_func"]["param"]["expect_queues"] = [set_queue_num, set_queue_num + 1]
+            else:
+                rule_command = tv["rte_flow_pattern"]
+
             pattern_name = tv["name"]
             test_results[pattern_name] = OrderedDict()
 
-            out = self.dut.send_expect(tv["rte_flow_pattern"], "testpmd> ", 15)  #create a rule
+            out = self.dut.send_expect(rule_command, "testpmd> ", 15)  #create a rule
             #get the rule number
             rule_num = self.get_rule_number(out)
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-08  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 14:47 [dts] [PATCH V1]tests/cvl_switch_filter:optimization_cvl_switch_filter Zeng Xiaoxiao
2020-06-05  6:39 ` Zeng, XiaoxiaoX
2020-06-08  3:00 ` Lu, Nannan

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).