The testsuite implements the testcases defined in the corresponding test plan.
Signed-off-by: Juraj Linkeš <juraj.lin...@pantheon.tech> --- dts/framework/remote_session/os/os_session.py | 16 +++++- dts/framework/testbed_model/__init__.py | 1 + dts/framework/testbed_model/node/sut_node.py | 11 ++++ dts/tests/TestSuite_hello_world.py | 53 +++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_hello_world.py diff --git a/dts/framework/remote_session/os/os_session.py b/dts/framework/remote_session/os/os_session.py index f84f3ce63c..1548e3c6c8 100644 --- a/dts/framework/remote_session/os/os_session.py +++ b/dts/framework/remote_session/os/os_session.py @@ -9,7 +9,7 @@ from framework.config import CPU, Architecture, NodeConfiguration from framework.logger import DTSLOG from framework.remote_session.factory import create_remote_session -from framework.remote_session.remote_session import RemoteSession +from framework.remote_session.remote_session import CommandResult, RemoteSession from framework.settings import SETTINGS from framework.utils import EnvVarsDict @@ -49,6 +49,20 @@ def is_alive(self) -> bool: """ return self.remote_session.is_alive() + def send_command( + self, + command: str, + timeout: float, + verify: bool = False, + env: EnvVarsDict | None = None, + ) -> CommandResult: + """ + An all-purpose API in case the command to be executed is already + OS-agnostic, such as when the path to the executed command has been + constructed beforehand. + """ + return self.remote_session.send_command(command, timeout, verify, env) + @abstractmethod def guess_dpdk_remote_dir(self, remote_dir) -> PurePath: """ diff --git a/dts/framework/testbed_model/__init__.py b/dts/framework/testbed_model/__init__.py index 13c29c59c8..0a4862d7d6 100644 --- a/dts/framework/testbed_model/__init__.py +++ b/dts/framework/testbed_model/__init__.py @@ -8,4 +8,5 @@ # pylama:ignore=W0611 +from .hw import CPUAmount, CPUAmountFilter, CPUListFilter, CPUList from .node import Node, SutNode diff --git a/dts/framework/testbed_model/node/sut_node.py b/dts/framework/testbed_model/node/sut_node.py index ff3be845b4..d56f7467ba 100644 --- a/dts/framework/testbed_model/node/sut_node.py +++ b/dts/framework/testbed_model/node/sut_node.py @@ -9,6 +9,7 @@ from framework.config import CPU, BuildTargetConfiguration, CPUList, NodeConfiguration from framework.remote_session import OSSession +from framework.remote_session.remote_session import CommandResult from framework.settings import SETTINGS from framework.testbed_model.hw import CPUAmount, CPUListFilter from framework.utils import EnvVarsDict, skip_setup @@ -224,6 +225,16 @@ def create_eal_parameters( return eal_str + def run_dpdk_app( + self, app_path: PurePath, eal_args: str, timeout: float = 30 + ) -> CommandResult: + """ + Run DPDK application on the remote node. + """ + return self.main_session.send_command( + f"{app_path} {eal_args}", timeout, verify=True + ) + class _EalParameter(object): def __init__( diff --git a/dts/tests/TestSuite_hello_world.py b/dts/tests/TestSuite_hello_world.py new file mode 100644 index 0000000000..d3661bb243 --- /dev/null +++ b/dts/tests/TestSuite_hello_world.py @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2014 Intel Corporation + +""" +DPDK Test suite. +Test HelloWorld example. +""" + +from framework.test_case import TestCase +from framework.testbed_model import CPUAmount, CPUAmountFilter, CPUList + + +class TestHelloWorld(TestCase): + def set_up_all(self): + """ + Run at the start of each test suite. + hello_world Prerequisites: + helloworld build pass + """ + self.app_helloworld_path = self.sut_node.build_dpdk_app("helloworld") + + def test_hello_world_single_core(self): + """ + Run hello world on single lcores + Only received hello message from core0 + """ + + # get the mask for the first core + cpu_amount = CPUAmount(1, 1, 1) + cores = CPUAmountFilter(self.sut_node.cpus, cpu_amount).filter() + eal_para = self.sut_node.create_eal_parameters(core_filter_specifier=cpu_amount) + result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para) + self.verify( + f"hello from core {str(cores[0]) in result.stdout}", + f"EAL not started on core{cores[0]}", + ) + + def test_hello_world_all_cores(self): + """ + Run hello world on all lcores + Received hello message from all lcores + """ + + # get the maximum logical core number + eal_para = self.sut_node.create_eal_parameters( + core_filter_specifier=CPUList(self.sut_node.cpus) + ) + result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para, 50) + for core in self.sut_node.cpus: + self.verify( + f"hello from core {str(core) in result.stdout}", + f"EAL not started on core{core}", + ) -- 2.30.2