test suite reviews and discussions
 help / color / mirror / Atom feed
From: Jun Dong <junx.dong@intel.com>
To: dts@dpdk.org
Cc: lijuan.tu@intel.com, qingx.sun@intel.com, junx.dong@intel.com
Subject: [dts] [V1] framework/*: Fixed some issues of new create eal parameter API
Date: Tue, 15 Mar 2022 12:16:13 +0800	[thread overview]
Message-ID: <20220315041613.1552-1-junx.dong@intel.com> (raw)

- Remove blank from cores list
- Change validate rule of port to compatible with FreeBSD
- Modify file prefix generate rule to compatible with FreeBSD
- Restore ParameterInvalidException's define since some API have used it

Signed-off-by: Jun Dong <junx.dong@intel.com>
---
 framework/dut.py       | 22 ++++++++++++++++------
 framework/exception.py |  7 +------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/framework/dut.py b/framework/dut.py
index 7b3535c7..dfd85c81 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -1364,6 +1364,10 @@ class _EalParameter(object):
         self.vdevs = vdevs
         self.other_eal_param = other_eal_param
 
+    _param_validate_exception_info_template = (
+        'Invalid parameter of %s about value of %s, Please reference API doc.'
+    )
+
     @staticmethod
     def _validate_cores(cores: Union[str, List[int], List[str]]):
         core_string_match = r"default|all|\d+S/\d+C/\d+T|$"
@@ -1386,18 +1390,22 @@ class _EalParameter(object):
                 or all(map(lambda _port: type(_port) == str, ports))
                 and all(
             map(
-                lambda _port: re.match(r"^([\d\w]+:){2}[\d\w]+\.[\d\w]+$", _port),
+                lambda _port: re.match(r"^([\d\w]+:){1,2}[\d\w]+\.[\d\w]+$", _port),
                 ports,
             )
         )
         ):
-            raise ParameterInvalidException("ports", ports)
+            raise ParameterInvalidException(
+                _EalParameter._param_validate_exception_info_template % ('ports', ports)
+            )
         return ports
 
     @staticmethod
     def _validate_port_options(port_options: Dict[Union[str, int], str]):
         if not isinstance(port_options, Dict):
-            raise ParameterInvalidException("port_options", port_options)
+            raise ParameterInvalidException(
+                _EalParameter._param_validate_exception_info_template % ('port_options', port_options)
+            )
         port_list = port_options.keys()
         _EalParameter._validate_ports(list(port_list))
         return port_options
@@ -1405,7 +1413,9 @@ class _EalParameter(object):
     @staticmethod
     def _validate_vdev(vdev: List[str]):
         if not isinstance(vdev, list):
-            raise ParameterInvalidException("vdev", vdev)
+            raise ParameterInvalidException(
+                _EalParameter._param_validate_exception_info_template % ('vdev', vdev)
+            )
 
     def _make_cores_param(self) -> str:
         is_use_default_cores = (
@@ -1446,7 +1456,7 @@ class _EalParameter(object):
                 )
             return _formated_core_list
 
-        return f'-l {", ".join(_get_consecutive_cores_range(core_list))}'
+        return f'-l {",".join(_get_consecutive_cores_range(core_list))}'
 
     def _make_memory_channels(self) -> str:
         param_template = "-n {}"
@@ -1499,7 +1509,6 @@ class _EalParameter(object):
             if not self.fixed_prefix:
                 fixed_file_prefix = fixed_file_prefix + "_" + self.dut.prefix_subfix
         fixed_file_prefix = self._do_os_handle_with_prefix_param(fixed_file_prefix)
-        fixed_file_prefix = "--file-prefix=" + fixed_file_prefix
         return fixed_file_prefix
 
     def _make_vdevs_param(self) -> str:
@@ -1570,6 +1579,7 @@ class _EalParameter(object):
             file_prefix = ""
         else:
             self.dut.prefix_list.append(file_prefix)
+            file_prefix = "--file-prefix=" + file_prefix
         return file_prefix
 
     def make_eal_param(self) -> str:
diff --git a/framework/exception.py b/framework/exception.py
index 2554c1d8..c3900cb6 100644
--- a/framework/exception.py
+++ b/framework/exception.py
@@ -77,12 +77,7 @@ class SSHSessionDeadException(Exception):
 
 
 class ParameterInvalidException(Exception):
-    def __init__(self, param_name: str, param_value: Any):
-        self.param_name = param_name
-        self.param_value = param_value
-
-    def __str__(self) -> str:
-        return f'Invalid parameter of {self.param_name} about value of {self.param_value}, Please reference API doc.'
+    pass
 
 
 class StartVMFailedException(Exception):
-- 
2.33.1.windows.1


             reply	other threads:[~2022-03-15  4:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15  4:16 Jun Dong [this message]
2022-03-15 11:37 ` 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=20220315041613.1552-1-junx.dong@intel.com \
    --to=junx.dong@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    --cc=qingx.sun@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).