From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0FC5CA00BE; Tue, 15 Mar 2022 05:16:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D074E40395; Tue, 15 Mar 2022 05:16:23 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id B896A4014F for ; Tue, 15 Mar 2022 05:16:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647317781; x=1678853781; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Ck2+iO71heY8uwgQjHWLQBkSAwiRvfED2tRTH5kKB8s=; b=Jc9OOxWN+0wTaGlAm4VJPT4kpIlxJS7j4dLIeQbqYMLV/9SFvk6pKaLl PR4WYsbRssypxCuc51wqEwp3hPnGOobMaypzIa+K6iTOC/KVX1+fD0D5Z VQXO63qOiby5Tgss0lpcxo9PDN8gCed/nZlqHoXSammlHNYya9E290Tzj Q28tCV9WtA9nKAChBo0PzLt6xlycz7KL/HmHyNCUQQsqcnoQRzCKgl5D+ EnA6bbWoPrcXrilOksAzQ2PlyTCpVSigRenlp4vZrwqI/e0dB2tTjLhpv KCwqdO3fF8no+7m2DmeP4X5lo08us/M1mXUEvtZrfirVI+ca7kd65Gghg g==; X-IronPort-AV: E=McAfee;i="6200,9189,10286"; a="342634705" X-IronPort-AV: E=Sophos;i="5.90,182,1643702400"; d="scan'208";a="342634705" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2022 21:16:20 -0700 X-IronPort-AV: E=Sophos;i="5.90,182,1643702400"; d="scan'208";a="782929000" Received: from shwdenpg197.ccr.corp.intel.com ([10.253.109.70]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2022 21:16:19 -0700 From: Jun Dong 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 Message-Id: <20220315041613.1552-1-junx.dong@intel.com> X-Mailer: git-send-email 2.33.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org - 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 --- 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