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 A6C08A0543; Wed, 24 Aug 2022 18:25:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0ED84280C; Wed, 24 Aug 2022 18:25:03 +0200 (CEST) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id 4695E41144 for ; Wed, 24 Aug 2022 18:25:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id 1DFCDCD26A; Wed, 24 Aug 2022 18:24:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at siecit.sk Received: from lb.pantheon.sk ([127.0.0.1]) by localhost (lb.pantheon.sk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2qi_Xs7zdonV; Wed, 24 Aug 2022 18:24:58 +0200 (CEST) Received: from entguard.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id AD333CD26D; Wed, 24 Aug 2022 18:24:55 +0200 (CEST) From: =?UTF-8?q?Juraj=20Linke=C5=A1?= To: thomas@monjalon.net, david.marchand@redhat.com, ronan.randles@intel.com, Honnappa.Nagarahalli@arm.com, ohilyard@iol.unh.edu, lijuan.tu@intel.com Cc: dev@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [RFC PATCH v1 02/10] dts: hello world cli parameters and env vars Date: Wed, 24 Aug 2022 16:24:46 +0000 Message-Id: <20220824162454.394285-3-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824162454.394285-1-juraj.linkes@pantheon.tech> References: <20220824162454.394285-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add command line arguments (and the corresponding env variables) that specify DPDK build and test execution workflow. Also split the configuration into two parts, one that can be changed during runtime and one that can't. We will need to change the git refspec to a DPDK tarball path when support is added for building DPDK from the repo. Signed-off-by: Juraj Linkeš --- dts/framework/logger.py | 9 ++-- dts/framework/settings.py | 96 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 96 insertions(+), 9 deletions(-) diff --git a/dts/framework/logger.py b/dts/framework/logger.py index 920ce0fb15..15cae3e4f9 100644 --- a/dts/framework/logger.py +++ b/dts/framework/logger.py @@ -8,6 +8,8 @@ import os.path from typing import TypedDict +from .settings import SETTINGS + """ DTS logger module with several log level. DTS framework and TestSuite log will saved into different log files. @@ -66,10 +68,9 @@ def __init__(self, logger: logging.Logger, node: str = "suite"): self.logger.addHandler(sh) self.sh = sh - if not os.path.exists("output"): - os.mkdir("output") + logging_file_prefix = os.path.join(SETTINGS.output_dir, node) - fh = logging.FileHandler(f"output/{node}.log") + fh = logging.FileHandler(f"{logging_file_prefix}.log") fh.setFormatter( logging.Formatter( fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s", @@ -83,7 +84,7 @@ def __init__(self, logger: logging.Logger, node: str = "suite"): # This outputs EVERYTHING, intended for post-mortem debugging # Also optimized for processing via AWK (awk -F '|' ...) - verbose_handler = logging.FileHandler(f"output/{node}.verbose.log") + verbose_handler = logging.FileHandler(f"{logging_file_prefix}.verbose.log") verbose_handler.setFormatter( logging.Formatter( fmt="%(asctime)s|%(name)s|%(levelname)s|%(pathname)s|%(lineno)d|%(funcName)s|" diff --git a/dts/framework/settings.py b/dts/framework/settings.py index c9621d4e3d..1ff3af4438 100644 --- a/dts/framework/settings.py +++ b/dts/framework/settings.py @@ -7,6 +7,7 @@ import argparse import os from dataclasses import dataclass +from enum import Enum, unique from typing import Any @@ -38,10 +39,40 @@ def wrapper(**kwargs) -> _EnvironmentArgument: @dataclass(slots=True, frozen=True) -class _Settings: +class _EnvSettings: config_file_path: str + compile_timeout: int timeout: float verbose: bool + output_dir: str + skip_setup: bool + test_cases: list + re_run: int + remote_dpdk_dir: str + + +@dataclass(slots=True) +class _RuntimeSettings: + dpdk_ref: str + + +class _Settings(_EnvSettings, _RuntimeSettings): + pass + + +@unique +class DTSRuntimeErrors(Enum): + NO_ERR = 0 + GENERIC_ERR = 1 + DPDK_BUILD_ERR = (2,) + SUT_SETUP_ERR = (3,) + TG_SETUP_ERR = (4,) + SUITE_SETUP_ERR = (5,) + SUITE_EXECUTE_ERR = 6 + + +# TODO singleton +DTSRuntimeError: DTSRuntimeErrors = DTSRuntimeErrors.NO_ERR def _get_parser() -> argparse.ArgumentParser: @@ -63,6 +94,14 @@ def _get_parser() -> argparse.ArgumentParser: help="[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.", ) + parser.add_argument( + "--compile-timeout", + action=_env_arg("DTS_COMPILE_TIMEOUT"), + default=1200, + required=False, + help="[DTS_COMPILE_TIMEOUT] The timeout for compiling DPDK.", + ) + parser.add_argument( "-v", "--verbose", @@ -72,15 +111,62 @@ def _get_parser() -> argparse.ArgumentParser: help="[DTS_VERBOSE] Set to 'Y' to enable verbose output, logging all messages to the console.", ) + parser.add_argument( + "--dpdk-ref", + "--git", + "--snapshot", + action=_env_arg("DTS_DPDK_REF"), + default="dep/dpdk.tar.gz", + help="[DTS_DPDK_REF] Reference to DPDK source code, " + "can be either a path to a tarball or a git refspec. " + "In case of a tarball, it will be extracted in the same directory.", + ) + + parser.add_argument( + "--output-dir", + "--output", + action=_env_arg("DTS_OUTPUT_DIR"), + default="output", + help="[DTS_OUTPUT_DIR] Output directory where dts logs and results are saved.", + ) + + parser.add_argument( + "-s", + "--skip-setup", + action=_env_arg("DTS_SKIP_SETUP"), + help="[DTS_SKIP_SETUP] Set to 'Y' to skip all setup steps on SUT and TG nodes.", + ) + + parser.add_argument( + "--test-cases", + action=_env_arg("DTS_TESTCASES"), + help="[DTS_TESTCASES] Comma-separated list of testcases to execute", + ) + + parser.add_argument( + "--re-run", + "--re_run", + action=_env_arg("DTS_RERUN"), + default=0, + help="[DTS_RERUN] Re-run tests the specified amount of times if a test failure occurs", + ) + return parser def _get_settings() -> _Settings: - args = _get_parser().parse_args() + parsed_args = _get_parser().parse_args() return _Settings( - config_file_path=args.config_file, - timeout=float(args.timeout), - verbose=(args.verbose == "Y"), + config_file_path=parsed_args.config_file, + compile_timeout=parsed_args.compile_timeout, + timeout=parsed_args.timeout, + verbose=(parsed_args.verbose == "Y"), + output_dir=parsed_args.output_dir, + skip_setup=(parsed_args.skip_setup == "Y"), + test_cases=parsed_args.test_cases.split(","), + re_run=int(parsed_args.re_run), + remote_dpdk_dir="/tmp/", + dpdk_ref=parsed_args.dpdk_ref, ) -- 2.30.2