From: Nicholas Pratte <npratte@iol.unh.edu>
To: Luca Vizzarro <luca.vizzarro@arm.com>
Cc: dev@dpdk.org, Patrick Robb <probb@iol.unh.edu>,
Paul Szczepanek <paul.szczepanek@arm.com>
Subject: Re: [RFC PATCH 5/7] dts: add runtime status
Date: Wed, 12 Feb 2025 13:50:23 -0500 [thread overview]
Message-ID: <CAKXZ7eg5XgMDS4n+CmNNEcBUS7=eKTMovRE_eymggzq0xR=23w@mail.gmail.com> (raw)
In-Reply-To: <20250203151613.2436570-6-luca.vizzarro@arm.com>
Reviewed-by: Nicholas Pratte <npratte@iol.unh.edu>
On Mon, Feb 3, 2025 at 10:17 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote:
>
> Add a new module which defines the global runtime status of DTS and the
> distinct execution stages and steps.
>
> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
> ---
> doc/api/dts/framework.status.rst | 8 ++++
> doc/api/dts/index.rst | 1 +
> dts/framework/logger.py | 36 ++++--------------
> dts/framework/status.py | 64 ++++++++++++++++++++++++++++++++
> 4 files changed, 81 insertions(+), 28 deletions(-)
> create mode 100644 doc/api/dts/framework.status.rst
> create mode 100644 dts/framework/status.py
>
> diff --git a/doc/api/dts/framework.status.rst b/doc/api/dts/framework.status.rst
> new file mode 100644
> index 0000000000..07277b5301
> --- /dev/null
> +++ b/doc/api/dts/framework.status.rst
> @@ -0,0 +1,8 @@
> +.. SPDX-License-Identifier: BSD-3-Clause
> +
> +status - DTS status definitions
> +===========================================================
> +
> +.. automodule:: framework.status
> + :members:
> + :show-inheritance:
> diff --git a/doc/api/dts/index.rst b/doc/api/dts/index.rst
> index 534512dc17..cde603576c 100644
> --- a/doc/api/dts/index.rst
> +++ b/doc/api/dts/index.rst
> @@ -29,6 +29,7 @@ Modules
> framework.test_suite
> framework.test_result
> framework.settings
> + framework.status
> framework.logger
> framework.parser
> framework.utils
> diff --git a/dts/framework/logger.py b/dts/framework/logger.py
> index d2b8e37da4..7b1c8e6637 100644
> --- a/dts/framework/logger.py
> +++ b/dts/framework/logger.py
> @@ -13,37 +13,17 @@
> """
>
> import logging
> -from enum import auto
> from logging import FileHandler, StreamHandler
> from pathlib import Path
> from typing import ClassVar
>
> -from .utils import StrEnum
> +from framework.status import PRE_RUN, State
>
> date_fmt = "%Y/%m/%d %H:%M:%S"
> stream_fmt = "%(asctime)s - %(stage)s - %(name)s - %(levelname)s - %(message)s"
> dts_root_logger_name = "dts"
>
>
> -class DtsStage(StrEnum):
> - """The DTS execution stage."""
> -
> - #:
> - pre_run = auto()
> - #:
> - test_run_setup = auto()
> - #:
> - test_suite_setup = auto()
> - #:
> - test_suite = auto()
> - #:
> - test_suite_teardown = auto()
> - #:
> - test_run_teardown = auto()
> - #:
> - post_run = auto()
> -
> -
> class DTSLogger(logging.Logger):
> """The DTS logger class.
>
> @@ -55,7 +35,7 @@ class DTSLogger(logging.Logger):
> a new stage switch occurs. This is useful mainly for logging per test suite.
> """
>
> - _stage: ClassVar[DtsStage] = DtsStage.pre_run
> + _stage: ClassVar[State] = PRE_RUN
> _extra_file_handlers: list[FileHandler] = []
>
> def __init__(self, *args, **kwargs):
> @@ -75,7 +55,7 @@ def makeRecord(self, *args, **kwargs) -> logging.LogRecord:
> record: The generated record with the stage information.
> """
> record = super().makeRecord(*args, **kwargs)
> - record.stage = DTSLogger._stage
> + record.stage = str(DTSLogger._stage)
> return record
>
> def add_dts_root_logger_handlers(self, verbose: bool, output_dir: str) -> None:
> @@ -110,7 +90,7 @@ def add_dts_root_logger_handlers(self, verbose: bool, output_dir: str) -> None:
>
> self._add_file_handlers(Path(output_dir, self.name))
>
> - def set_stage(self, stage: DtsStage, log_file_path: Path | None = None) -> None:
> + def set_stage(self, state: State, log_file_path: Path | None = None) -> None:
> """Set the DTS execution stage and optionally log to files.
>
> Set the DTS execution stage of the DTSLog class and optionally add
> @@ -120,15 +100,15 @@ def set_stage(self, stage: DtsStage, log_file_path: Path | None = None) -> None:
> the other one is a machine-readable log file with extra debug information.
>
> Args:
> - stage: The DTS stage to set.
> + state: The DTS execution state to set.
> log_file_path: An optional path of the log file to use. This should be a full path
> (either relative or absolute) without suffix (which will be appended).
> """
> self._remove_extra_file_handlers()
>
> - if DTSLogger._stage != stage:
> - self.info(f"Moving from stage '{DTSLogger._stage}' to stage '{stage}'.")
> - DTSLogger._stage = stage
> + if DTSLogger._stage != state:
> + self.info(f"Moving from stage '{DTSLogger._stage}' " f"to stage '{state}'.")
> + DTSLogger._stage = state
>
> if log_file_path:
> self._extra_file_handlers.extend(self._add_file_handlers(log_file_path))
> diff --git a/dts/framework/status.py b/dts/framework/status.py
> new file mode 100644
> index 0000000000..4a59aa50e6
> --- /dev/null
> +++ b/dts/framework/status.py
> @@ -0,0 +1,64 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2025 Arm Limited
> +
> +"""Running status of DTS.
> +
> +This module contains the definitions that represent the different states of execution within DTS.
> +"""
> +
> +from enum import auto
> +from typing import NamedTuple
> +
> +from .utils import StrEnum
> +
> +
> +class Stage(StrEnum):
> + """Execution stage."""
> +
> + #:
> + PRE_RUN = auto()
> + #:
> + TEST_RUN = auto()
> + #:
> + TEST_SUITE = auto()
> + #:
> + TEST_CASE = auto()
> + #:
> + POST_RUN = auto()
> +
> +
> +class InternalState(StrEnum):
> + """Internal state of the current execution stage."""
> +
> + #:
> + BEGIN = auto()
> + #:
> + SETUP = auto()
> + #:
> + RUN = auto()
> + #:
> + TEARDOWN = auto()
> + #:
> + END = auto()
> +
> +
> +class State(NamedTuple):
> + """Representation of the DTS execution state."""
> +
> + #:
> + stage: Stage
> + #:
> + state: InternalState
> +
> + def __str__(self) -> str:
> + """A formatted name."""
> + name = self.stage.value.lower()
> + if self.state is not InternalState.RUN:
> + return f"{name}_{self.state.value.lower()}"
> + return name
> +
> +
> +#: A ready-made pre-run DTS state.
> +PRE_RUN = State(Stage.PRE_RUN, InternalState.RUN)
> +#: A ready-made post-run DTS state.
> +POST_RUN = State(Stage.POST_RUN, InternalState.RUN)
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-02-12 18:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 15:16 [RFC PATCH 0/7] dts: revamp framework Luca Vizzarro
2025-02-03 15:16 ` [RFC PATCH 1/7] dts: add port topology configuration Luca Vizzarro
2025-02-07 18:25 ` Nicholas Pratte
2025-02-12 16:47 ` Luca Vizzarro
2025-02-11 18:00 ` Dean Marx
2025-02-12 16:47 ` Luca Vizzarro
2025-02-03 15:16 ` [RFC PATCH 2/7] dts: isolate test specification to config Luca Vizzarro
2025-02-10 19:09 ` Nicholas Pratte
2025-02-11 18:11 ` Dean Marx
2025-02-03 15:16 ` [RFC PATCH 3/7] dts: revamp Topology model Luca Vizzarro
2025-02-10 19:42 ` Nicholas Pratte
2025-02-11 18:18 ` Dean Marx
2025-02-03 15:16 ` [RFC PATCH 4/7] dts: improve Port model Luca Vizzarro
2025-02-11 18:56 ` Dean Marx
2025-02-03 15:16 ` [RFC PATCH 5/7] dts: add runtime status Luca Vizzarro
2025-02-11 19:45 ` Dean Marx
2025-02-12 18:50 ` Nicholas Pratte [this message]
2025-02-03 15:16 ` [RFC PATCH 6/7] dts: add global runtime context Luca Vizzarro
2025-02-11 20:26 ` Dean Marx
2025-02-03 15:16 ` [RFC PATCH 7/7] dts: revamp runtime internals Luca Vizzarro
2025-02-11 20:50 ` Dean Marx
2025-02-04 21:08 ` [RFC PATCH 0/7] dts: revamp framework Dean Marx
2025-02-12 16:52 ` Luca Vizzarro
2025-02-12 16:45 ` [PATCH v2 " Luca Vizzarro
2025-02-12 16:45 ` [PATCH v2 1/7] dts: add port topology configuration Luca Vizzarro
2025-02-12 16:45 ` [PATCH v2 2/7] dts: isolate test specification to config Luca Vizzarro
2025-02-12 16:45 ` [PATCH v2 3/7] dts: revamp Topology model Luca Vizzarro
2025-02-12 16:45 ` [PATCH v2 4/7] dts: improve Port model Luca Vizzarro
2025-02-12 16:45 ` [PATCH v2 5/7] dts: add global runtime context Luca Vizzarro
2025-02-12 19:45 ` Nicholas Pratte
2025-02-12 16:45 ` [PATCH v2 6/7] dts: revamp runtime internals Luca Vizzarro
2025-02-12 16:46 ` [PATCH v2 7/7] dts: remove node distinction Luca Vizzarro
2025-02-12 16:47 ` [PATCH v2 0/7] dts: revamp framework Luca Vizzarro
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='CAKXZ7eg5XgMDS4n+CmNNEcBUS7=eKTMovRE_eymggzq0xR=23w@mail.gmail.com' \
--to=npratte@iol.unh.edu \
--cc=dev@dpdk.org \
--cc=luca.vizzarro@arm.com \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
/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).