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 28E95423FE; Tue, 17 Jan 2023 16:50:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20E5D42D71; Tue, 17 Jan 2023 16:49:24 +0100 (CET) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id 797C342D54 for ; Tue, 17 Jan 2023 16:49:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id D06B61D8128; Tue, 17 Jan 2023 16:49:20 +0100 (CET) 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 eJf0Us1tgsTS; Tue, 17 Jan 2023 16:49:19 +0100 (CET) Received: from entguard.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id 394AF1D811B; Tue, 17 Jan 2023 16:49:13 +0100 (CET) From: =?UTF-8?q?Juraj=20Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, ohilyard@iol.unh.edu, lijuan.tu@intel.com, bruce.richardson@intel.com Cc: dev@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [PATCH v3 08/10] dts: add hello world testsuite Date: Tue, 17 Jan 2023 15:49:04 +0000 Message-Id: <20230117154906.860916-9-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230117154906.860916-1-juraj.linkes@pantheon.tech> References: <20221114165438.1133783-1-juraj.linkes@pantheon.tech> <20230117154906.860916-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 The test suite implements test cases defined in the corresponding test plan. Signed-off-by: Juraj Linkeš --- dts/framework/remote_session/__init__.py | 2 +- dts/framework/remote_session/os_session.py | 16 ++++- .../remote_session/remote/__init__.py | 2 +- dts/framework/testbed_model/__init__.py | 1 + dts/framework/testbed_model/sut_node.py | 12 +++- dts/tests/TestSuite_hello_world.py | 59 +++++++++++++++++++ 6 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 dts/tests/TestSuite_hello_world.py diff --git a/dts/framework/remote_session/__init__.py b/dts/framework/remote_session/__init__.py index 747316c78a..ee221503df 100644 --- a/dts/framework/remote_session/__init__.py +++ b/dts/framework/remote_session/__init__.py @@ -17,7 +17,7 @@ from .linux_session import LinuxSession from .os_session import OSSession -from .remote import RemoteSession, SSHSession +from .remote import CommandResult, RemoteSession, SSHSession def create_session( diff --git a/dts/framework/remote_session/os_session.py b/dts/framework/remote_session/os_session.py index 966b7f76d5..a869c7acde 100644 --- a/dts/framework/remote_session/os_session.py +++ b/dts/framework/remote_session/os_session.py @@ -12,7 +12,7 @@ from framework.testbed_model import LogicalCore, MesonArgs from framework.utils import EnvVarsDict -from .remote import RemoteSession, create_remote_session +from .remote import CommandResult, RemoteSession, create_remote_session class OSSession(ABC): @@ -50,6 +50,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/remote_session/remote/__init__.py b/dts/framework/remote_session/remote/__init__.py index f3092f8bbe..8a1512210a 100644 --- a/dts/framework/remote_session/remote/__init__.py +++ b/dts/framework/remote_session/remote/__init__.py @@ -6,7 +6,7 @@ from framework.config import NodeConfiguration from framework.logger import DTSLOG -from .remote_session import RemoteSession +from .remote_session import CommandResult, RemoteSession from .ssh_session import SSHSession diff --git a/dts/framework/testbed_model/__init__.py b/dts/framework/testbed_model/__init__.py index 2be5169dc8..efb463f2e2 100644 --- a/dts/framework/testbed_model/__init__.py +++ b/dts/framework/testbed_model/__init__.py @@ -13,6 +13,7 @@ from .hw import ( LogicalCore, LogicalCoreAmount, + LogicalCoreAmountFilter, LogicalCoreList, LogicalCoreListFilter, VirtualDevice, diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index ea0b96d6bf..6a0472a733 100644 --- a/dts/framework/testbed_model/sut_node.py +++ b/dts/framework/testbed_model/sut_node.py @@ -8,7 +8,7 @@ from pathlib import PurePath from framework.config import BuildTargetConfiguration, NodeConfiguration -from framework.remote_session import OSSession +from framework.remote_session import CommandResult, OSSession from framework.settings import SETTINGS from framework.utils import EnvVarsDict, skip_setup @@ -249,3 +249,13 @@ def create_eal_parameters( vdevs=vdevs, other_eal_param=other_eal_param, ) + + def run_dpdk_app( + self, app_path: PurePath, eal_args: EalParameters, 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 + ) diff --git a/dts/tests/TestSuite_hello_world.py b/dts/tests/TestSuite_hello_world.py new file mode 100644 index 0000000000..5ade941d31 --- /dev/null +++ b/dts/tests/TestSuite_hello_world.py @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2014 Intel Corporation + +""" +DPDK Test suite. +Test HelloWorld example. +""" + +from framework.test_suite import TestSuite +from framework.testbed_model import ( + LogicalCoreAmount, + LogicalCoreAmountFilter, + LogicalCoreList, +) + + +class TestHelloWorld(TestSuite): + def set_up_suite(self) -> None: + """ + 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) -> None: + """ + Run hello world on single lcores + Only received hello message from core0 + """ + + # get the mask for the first core + lcore_amount = LogicalCoreAmount(1, 1, 1) + lcores = LogicalCoreAmountFilter(self.sut_node.lcores, lcore_amount).filter() + eal_para = self.sut_node.create_eal_parameters( + lcore_filter_specifier=lcore_amount + ) + result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para) + self.verify( + f"hello from core {int(lcores[0])}" in result.stdout, + f"EAL not started on lcore{lcores[0]}", + ) + + def test_hello_world_all_cores(self) -> None: + """ + 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( + lcore_filter_specifier=LogicalCoreList(self.sut_node.lcores) + ) + result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para, 50) + for lcore in self.sut_node.lcores: + self.verify( + f"hello from core {int(lcore)}" in result.stdout, + f"EAL not started on lcore{lcore}", + ) -- 2.30.2