From: Luca Vizzarro <Luca.Vizzarro@arm.com>
To: dev@dpdk.org
Cc: Luca Vizzarro <luca.vizzarro@arm.com>,
Paul Szczepanek <paul.szczepanek@arm.com>,
Patrick Robb <probb@iol.unh.edu>
Subject: [PATCH v4 7/7] dts: improve configuration errors
Date: Mon, 3 Mar 2025 16:57:09 +0200 [thread overview]
Message-ID: <20250303145709.126126-8-Luca.Vizzarro@arm.com> (raw)
In-Reply-To: <20250303145709.126126-1-Luca.Vizzarro@arm.com>
From: Luca Vizzarro <luca.vizzarro@arm.com>
Improve the way that configuration errors are displayed to the user.
Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
dts/framework/config/__init__.py | 4 ++--
dts/framework/config/test_run.py | 2 +-
dts/framework/runner.py | 14 +++++++++++++-
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index 129e6f3222..1ec744d1d4 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -141,7 +141,7 @@ def _load_and_parse_model(file_path: Path, model_type: type[T], ctx: ValidationC
data = yaml.safe_load(f)
return TypeAdapter(model_type).validate_python(data, context=cast(dict[str, Any], ctx))
except ValidationError as e:
- msg = f"failed to load the configuration file {file_path}"
+ msg = f"Failed to load the configuration file {file_path}."
raise ConfigurationError(msg) from e
@@ -190,4 +190,4 @@ def load_config(ctx: ValidationContext) -> Configuration:
{"test_run": test_run, "nodes": nodes, "tests_config": dict(tests_config)}, context=ctx
)
except ValidationError as e:
- raise ConfigurationError("the configurations supplied are invalid") from e
+ raise ConfigurationError("The configurations supplied are invalid.") from e
diff --git a/dts/framework/config/test_run.py b/dts/framework/config/test_run.py
index 688688e88e..06fe28143c 100644
--- a/dts/framework/config/test_run.py
+++ b/dts/framework/config/test_run.py
@@ -445,7 +445,7 @@ def use_first_core(self) -> bool:
class DPDKConfiguration(DPDKRuntimeConfiguration):
"""The DPDK configuration needed to test."""
- #: The DPDKD build configuration used to test.
+ #: The DPDK build configuration used to test.
build: DPDKBuildConfiguration
diff --git a/dts/framework/runner.py b/dts/framework/runner.py
index f822e8a8fc..f20aa3576a 100644
--- a/dts/framework/runner.py
+++ b/dts/framework/runner.py
@@ -11,8 +11,10 @@
import os
import sys
+import textwrap
from framework.config.common import ValidationContext
+from framework.exception import ConfigurationError
from framework.test_run import TestRun
from framework.testbed_model.node import Node
@@ -37,7 +39,17 @@ class DTSRunner:
def __init__(self):
"""Initialize the instance with configuration, logger, result and string constants."""
- self._configuration = load_config(ValidationContext(settings=SETTINGS))
+ try:
+ self._configuration = load_config(ValidationContext(settings=SETTINGS))
+ except ConfigurationError as e:
+ if e.__cause__:
+ print(f"{e} Reason:", file=sys.stderr)
+ print(file=sys.stderr)
+ print(textwrap.indent(str(e.__cause__), prefix=" " * 2), file=sys.stderr)
+ else:
+ print(e, file=sys.stderr)
+ sys.exit(e.severity)
+
self._logger = get_dts_logger()
if not os.path.exists(SETTINGS.output_dir):
os.makedirs(SETTINGS.output_dir)
--
2.43.0
prev parent reply other threads:[~2025-03-03 14:58 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 16:13 [PATCH] dts: add per-test-suite configuration Luca Vizzarro
2024-09-27 17:45 ` Jeremy Spewock
2024-11-08 13:38 ` [PATCH v2 0/4] " Luca Vizzarro
2024-11-08 13:38 ` [PATCH v2 1/4] dts: add tests package to API docs Luca Vizzarro
2024-11-08 13:38 ` [PATCH v2 2/4] dts: fix smoke tests docstring Luca Vizzarro
2024-11-12 20:03 ` Dean Marx
2024-11-08 13:38 ` [PATCH v2 3/4] dts: add per-test-suite configuration Luca Vizzarro
2024-11-08 13:38 ` [PATCH v2 4/4] dts: update autodoc sorting order Luca Vizzarro
2024-11-08 13:45 ` [PATCH v3 0/4] dts: add per-test-suite configuration Luca Vizzarro
2024-11-08 13:45 ` [PATCH v3 1/4] dts: add tests package to API docs Luca Vizzarro
2024-11-12 19:55 ` Dean Marx
2024-11-08 13:45 ` [PATCH v3 2/4] dts: fix smoke tests docstring Luca Vizzarro
2024-11-08 13:45 ` [PATCH v3 3/4] dts: add per-test-suite configuration Luca Vizzarro
2024-11-13 21:44 ` Dean Marx
2024-11-14 12:39 ` Luca Vizzarro
2024-11-19 16:31 ` Dean Marx
2024-11-19 16:41 ` Luca Vizzarro
2024-11-08 13:45 ` [PATCH v3 4/4] dts: update autodoc sorting order Luca Vizzarro
2024-11-12 20:04 ` Dean Marx
2025-03-03 14:57 ` [PATCH v4 0/7] dts: add per-test-suite configuration Luca Vizzarro
2025-03-03 14:57 ` [PATCH v4 1/7] dts: add tests package to API docs Luca Vizzarro
2025-03-03 14:57 ` [PATCH v4 2/7] dts: amend test suites docstring Luca Vizzarro
2025-03-03 14:57 ` [PATCH v4 3/7] dts: fix smoke tests docstring Luca Vizzarro
2025-03-03 14:57 ` [PATCH v4 4/7] dts: update autodoc sorting order Luca Vizzarro
2025-03-03 14:57 ` [PATCH v4 5/7] dts: run only one test run per execution Luca Vizzarro
2025-03-03 14:57 ` [PATCH v4 6/7] dts: add per-test-suite configuration Luca Vizzarro
2025-03-03 14:57 ` Luca Vizzarro [this message]
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=20250303145709.126126-8-Luca.Vizzarro@arm.com \
--to=luca.vizzarro@arm.com \
--cc=dev@dpdk.org \
--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).