test suite reviews and discussions
 help / color / mirror / Atom feed
From: Jiale Song <songx.jiale@intel.com>
To: dts@dpdk.org
Cc: Jiale Song <songx.jiale@intel.com>
Subject: [dts] [PATCH V2] tests/dcf_lifecycle: add a method to create and check acl rule
Date: Tue, 19 Oct 2021 16:49:56 +0800	[thread overview]
Message-ID: <1634633396-186116-1-git-send-email-songx.jiale@intel.com> (raw)

as the priority of switch rule becomes higher, some rules that support switch cannot be 
downloaded directly to acl. add a method to create and check acl rule.

Signed-off-by: Jiale Song <songx.jiale@intel.com>
---
 tests/TestSuite_dcf_lifecycle.py | 58 +++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/tests/TestSuite_dcf_lifecycle.py b/tests/TestSuite_dcf_lifecycle.py
index d47ef2b..ce51ea1 100755
--- a/tests/TestSuite_dcf_lifecycle.py
+++ b/tests/TestSuite_dcf_lifecycle.py
@@ -315,6 +315,7 @@ class TestDcfLifeCycle(TestCase):
             "-c {core_mask} "
             "-n {mem_channel} "
             "{allowlist} "
+            "--log-level=ice,7 "
             "--file-prefix={prefix} "
             "-- -i ").format(**{
                 'bin': ''.join(['./',self.vf_dcf_testpmd]),
@@ -374,6 +375,7 @@ class TestDcfLifeCycle(TestCase):
             "-c {core_mask} "
             "-n {mem_channel} "
             "{allowlist} "
+            "--log-level=ice,7 "
             "--file-prefix={prefix} "
             "-- -i ").format(**{
                 'bin': ''.join(['./',self.vf_testpmd2]),
@@ -1020,6 +1022,59 @@ class TestDcfLifeCycle(TestCase):
         self.preset_pmd_res()
         self.vf_create()
 
+    def create_acl_filter_rule(self, rules, session_name="", check_stats=True):
+        """
+        create acl filter rules
+        """
+        if session_name == "":
+            session_name = self.dut
+        p = re.compile(r"Flow rule #(\d+) created")
+        rule_list = []
+        switch_rule = "Succeeded to create (2) flow"
+        switch_id = ''
+        acl_rule = "Succeeded to create (4) flow"
+        if isinstance(rules, list):
+            for rule in rules:
+                if 'sctp' not in rule:
+                    # create switch rule
+                    switch_out = session_name.send_expect(rule, "testpmd> ")
+                    self.verify(switch_rule in switch_out, 'switch rule create failed')
+                    switch_id = p.findall(switch_out)[0]
+                # create acl rule
+                acl_out = session_name.send_expect(rule, "testpmd> ")
+                # destory switch rule
+                if switch_id != '':
+                    session_name.send_expect("flow destroy %s rule %s" % (0, switch_id), "testpmd> ")
+                if acl_rule in acl_out:
+                    m = p.search(acl_out)
+                    if m:
+                        rule_list.append(m.group(1))
+                    else:
+                        rule_list.append(False)
+        else:
+            if 'sctp' not in rules:
+                # create switch rule
+                switch_out = session_name.send_expect(rule, "testpmd> ")
+                self.verify(switch_rule in switch_out, 'switch rule create failed')
+                switch_id = p.findall(switch_out)[0]
+            # create acl rule
+            acl_out = session_name.send_expect(rules, "testpmd> ")
+            # destory switch rule
+            if switch_id != ''
+                session_name.send_expect("flow destroy %s rule %s" % (0, switch_id), "testpmd> ")
+            if acl_rule in acl_out:
+                m = p.search(acl_out)
+                if m:
+                    rule_list.append(m.group(1))
+                else:
+                    rule_list.append(False)
+
+        if check_stats:
+            self.verify(all(rule_list), "some rules not created successfully, result %s, rule %s" % (rule_list, rules))
+        else:
+            self.verify(not any(rule_list), "all rules should create failed, result %s" % rule_list)
+        return rule_list
+
     def destroy_resource(self):
         try:
             self.vf_destroy()
@@ -1232,7 +1287,8 @@ class TestDcfLifeCycle(TestCase):
     def pretest_handle_acl_filter(self):
         # Create an ACL rule, and send packet with dst mac of VF1, then it will dropped by VF1.
         rule = 'flow create 0 priority 0 ingress pattern eth / ipv4 / tcp src spec 8010 src mask 65520 / end actions drop / end'
-        self.d_con([rule, "testpmd> ", 15])
+        # acl rule
+        self.create_acl_filter_rule(rule, check_stats=True)
         self.check_rule_list()
         self.send_pkt_to_vf1_first(self.dmac)
         out = self.vf_pmd2_con(['stop', "testpmd> ", 15])
-- 
2.17.1


             reply	other threads:[~2021-10-19  8:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19  8:49 Jiale Song [this message]
2021-10-20  2:55 Jiale Song
2021-10-21  2:04 ` Huang, ZhiminX
2021-10-25  8:01 ` 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=1634633396-186116-1-git-send-email-songx.jiale@intel.com \
    --to=songx.jiale@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).