[PATCH 3/6] dts: add current test suite and cases to context
Luca Vizzarro
luca.vizzarro at arm.com
Fri Jul 25 17:11:38 CEST 2025
Add the current test suite and case to the context, so that they can be
accessed by helper functions, etc.
Signed-off-by: Luca Vizzarro <luca.vizzarro at arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek at arm.com>
---
dts/framework/context.py | 7 ++++++-
dts/framework/test_run.py | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dts/framework/context.py b/dts/framework/context.py
index 4360bc8699..b99a5a4a69 100644
--- a/dts/framework/context.py
+++ b/dts/framework/context.py
@@ -5,7 +5,7 @@
import functools
from dataclasses import MISSING, dataclass, field, fields
-from typing import TYPE_CHECKING, ParamSpec
+from typing import TYPE_CHECKING, ParamSpec, Union
from framework.exception import InternalError
from framework.remote_session.shell_pool import ShellPool
@@ -16,6 +16,7 @@
if TYPE_CHECKING:
from framework.remote_session.dpdk import DPDKBuildEnvironment, DPDKRuntimeEnvironment
+ from framework.test_suite import TestCase, TestSuite
from framework.testbed_model.traffic_generator.traffic_generator import TrafficGenerator
P = ParamSpec("P")
@@ -26,6 +27,8 @@ class LocalContext:
"""Updatable context local to test suites and cases.
Attributes:
+ current_test_suite: The currently running test suite, if any.
+ current_test_case: The currently running test case, if any.
lcore_filter_specifier: A number of lcores/cores/sockets to use or a list of lcore ids to
use. The default will select one lcore for each of two cores on one socket, in ascending
order of core ids.
@@ -37,6 +40,8 @@ class LocalContext:
and no output is gathered within the timeout, an exception is thrown.
"""
+ current_test_suite: Union["TestSuite", None] = None
+ current_test_case: Union[type["TestCase"], None] = None
lcore_filter_specifier: LogicalCoreCount | LogicalCoreList = field(
default_factory=LogicalCoreCount
)
diff --git a/dts/framework/test_run.py b/dts/framework/test_run.py
index 4355aeeb4b..614022e2b6 100644
--- a/dts/framework/test_run.py
+++ b/dts/framework/test_run.py
@@ -406,6 +406,7 @@ def next(self) -> State | None:
return self
test_run.ctx.local.reset()
+ test_run.ctx.local.current_test_suite = test_suite
return TestSuiteSetup(test_run, test_suite, test_suite_result)
except IndexError:
# No more test suites. We are done here.
@@ -529,6 +530,7 @@ def next(self) -> State | None:
test_case_result.mark_result_as(Result.SKIP, e)
return self
+ self.test_run.ctx.local.current_test_case = test_case
return TestCaseSetup(
self.test_run,
self.test_suite,
--
2.43.0
More information about the dev
mailing list