test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org, lijuan.tu@intel.com
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 2/2] tests/l3fwd: support set test ports in cfg file
Date: Fri, 17 Jan 2020 10:29:54 +0800	[thread overview]
Message-ID: <20200117022954.21597-3-yufengx.mo@intel.com> (raw)
In-Reply-To: <20200117022954.21597-1-yufengx.mo@intel.com>


add a key to select custom dut ports to run testing. If not set this key in cfg file,
use default dut port list of dts framework.

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 tests/l3fwd_base.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tests/l3fwd_base.py b/tests/l3fwd_base.py
index 3fbf71f..0e51418 100644
--- a/tests/l3fwd_base.py
+++ b/tests/l3fwd_base.py
@@ -63,6 +63,7 @@ class L3fwdBase(object):
 
     def l3fwd_init(self, valports, socket):
         self.__valports = valports
+        self.__white_list = None
         self.__socket = socket
         self.__nic_name = self.nic
         self.__pkt_typ = 'udp'
@@ -384,6 +385,7 @@ class L3fwdBase(object):
             "{bin} "
             "-c {cores} "
             "-n {channel} "
+            "{whitelist}"
             "-- "
             "-p {port_mask} "
             "--config '{config}'"
@@ -391,6 +393,7 @@ class L3fwdBase(object):
                 'bin': bin,
                 'cores': core_mask,
                 'channel': self.dut.get_memory_channels(),
+                'whitelist': self.__white_list if self.__white_list else '',
                 'port_mask': utils.create_mask(self.__valports),
                 'config': config, })
         if self.nic == "niantic":
@@ -701,7 +704,30 @@ class L3fwdBase(object):
 
         return test_content
 
+    def __get_whitelist(self, port_list):
+        white_list = ''
+        for port_index in port_list:
+            pci = self.dut.ports_info[port_index].get('pci')
+            if not pci:
+                continue
+            white_list += '-w {} '.format(pci)
+        return white_list
+    
+    def __preset_port_list(self, test_content):
+        port_list = test_content.get('port_list')
+        if port_list:
+            if not set(port_list).issubset(set(self.__valports)):
+                msg = 'total ports are {}, select ports are wrong'.format(pformat(self.__valports))
+                raise VerifyFailure(msg)
+            else:
+                msg = 'current using {} for testing'.format(pformat(port_list))
+                self.logger.warning(msg)
+            self.__valports = port_list
+            self.__white_list = self.__get_whitelist(port_list)
+
     def l3fwd_preset_test_environment(self, test_content):
+        # if user set port list in cfg file, use
+        self.__preset_port_list(test_content)
         # get test content
         self.__test_content = self.__get_test_content_from_cfg(test_content)
         # binary process flag
-- 
2.21.0


  parent reply	other threads:[~2020-01-17  2:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-17  2:29 [dts] [PATCH V1 0/2] l3fwd: " yufengmx
2020-01-17  2:29 ` [dts] [PATCH V1 1/2] conf/l3fwd: " yufengmx
2020-01-17  2:29 ` yufengmx [this message]
2020-01-17  3:12 ` [dts] [PATCH V1 0/2] l3fwd: " Mo, YufengX

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=20200117022954.21597-3-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@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).