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 035EA41DC6; Fri, 3 Mar 2023 11:26:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD8F642D3E; Fri, 3 Mar 2023 11:25:22 +0100 (CET) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mails.dpdk.org (Postfix) with ESMTP id 53965427EE for ; Fri, 3 Mar 2023 11:25:18 +0100 (CET) Received: by mail-ed1-f47.google.com with SMTP id f13so8304087edz.6 for ; Fri, 03 Mar 2023 02:25:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon-tech.20210112.gappssmtp.com; s=20210112; t=1677839118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8sUh98ZWp0MwGaBe4pHvAZTJTMPDTyuFgLID5PGH4Yw=; b=L1r5/d4fHxXIb4C6s8uqiSyYj3R1NOpB/9T3WseHrfAUhM7g2V1Qw5WRf9j7rndzs8 boNDeeVk3k7WGBMcfdvSJMA5jGNYTTwklmcZfHy9PfW6Qm4gWFGigLfCkF4ih5GC1OLO 3KuNx2so4QWD8GtOa7JxQzODu5pxmzjTHLbCr0ASC+GGqygLZBTeeT6BNg5Ca2uTEogI 8DfRsItmjmTo+npwpW2tqc2maXxLEkqIb/EpINuXEHzxpRVusQVIudHhTc6w/OoyZeLd FvJ7ZteVDvs66lEwa+GdyIMXy2tp2DZ2fjFcVsZ7hAMWgkxUoi6/FfpFBfBRJ6BJjau6 KL6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677839118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8sUh98ZWp0MwGaBe4pHvAZTJTMPDTyuFgLID5PGH4Yw=; b=5u+sQpDFUUwtniZGbty7bp8kCaaE6Y9U/RxUPIwPLGZbd65FkK4iZxJEqDDu81agE4 TyNRU9l0PJ5dNigKCIrZy6I0uHBEmVlhl33VWqH2K+3bmOQYyiQGxfk2T8I6KxX6tPNJ ks6YOdBwJm0n2eRxEd75/j1QlbtJF2QKbDzl2qQ0Xl63THKlEjKiUv/V8619mMMGnW57 GqoRqMVQxG0kbHCPiw/idCGRJUMMSHGjtuImy3uFZR6KqD0kCa56k9fAM4wHoxrcWFCA y+Ldxms3bnd+QHIlR3Fs50jQjthneYuUT1OTsPRQpTT8tfaTVHFcglQV4+93cwaqVpQ4 j2KQ== X-Gm-Message-State: AO0yUKWgcS7Nj6EQpW9SZnGnQuU3M8BGpvcp2zRy3rwAsDXE6jNry65T w6tUqUgwg66AQ4EIJ0avZ7vQq27axPY+dPKe X-Google-Smtp-Source: AK7set+AnhLEV4sM9xrjd5s0ecN3LSxALuWNBe7O90izyja7mCUUwPBTWO/3LcJnF4ZTnZDS0ZcwJQ== X-Received: by 2002:aa7:c391:0:b0:4ac:c3ea:47e0 with SMTP id k17-20020aa7c391000000b004acc3ea47e0mr1441701edq.14.1677839118077; Fri, 03 Mar 2023 02:25:18 -0800 (PST) Received: from localhost.localdomain (ip-46.34.234.35.o2inet.sk. [46.34.234.35]) by smtp.gmail.com with ESMTPSA id j19-20020a508a93000000b004c3e3a6136dsm984028edj.21.2023.03.03.02.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 02:25:17 -0800 (PST) From: =?UTF-8?q?Juraj=20Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, lijuan.tu@intel.com, bruce.richardson@intel.com, probb@iol.unh.edu Cc: dev@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [PATCH v6 07/10] dts: add hello world testsuite Date: Fri, 3 Mar 2023 11:25:04 +0100 Message-Id: <20230303102507.527790-8-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230303102507.527790-1-juraj.linkes@pantheon.tech> References: <20230223152840.634183-1-juraj.linkes@pantheon.tech> <20230303102507.527790-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 | 64 +++++++++++++++++++ 6 files changed, 93 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 048bf7178e..4c48ae2567 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 from framework.utils import EnvVarsDict, MesonArgs -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 5be3e4c48d..f54a947051 100644 --- a/dts/framework/testbed_model/__init__.py +++ b/dts/framework/testbed_model/__init__.py @@ -12,6 +12,7 @@ from .hw import ( LogicalCore, LogicalCoreCount, + LogicalCoreCountFilter, LogicalCoreList, LogicalCoreListFilter, VirtualDevice, diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py index 3672f5f6e5..2b2b50d982 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, MesonArgs @@ -252,6 +252,16 @@ def create_eal_parameters( 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 + ) + class EalParameters(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..7e3d95c0cf --- /dev/null +++ b/dts/tests/TestSuite_hello_world.py @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2014 Intel Corporation + +""" +Run the helloworld example app and verify it prints a message for each used core. +No other EAL parameters apart from cores are used. +""" + +from framework.test_suite import TestSuite +from framework.testbed_model import ( + LogicalCoreCount, + LogicalCoreCountFilter, + LogicalCoreList, +) + + +class TestHelloWorld(TestSuite): + def set_up_suite(self) -> None: + """ + Setup: + Build the app we're about to test - helloworld. + """ + self.app_helloworld_path = self.sut_node.build_dpdk_app("helloworld") + + def test_hello_world_single_core(self) -> None: + """ + Steps: + Run the helloworld app on the first usable logical core. + Verify: + The app prints a message from the used core: + "hello from core " + """ + + # get the first usable core + lcore_amount = LogicalCoreCount(1, 1, 1) + lcores = LogicalCoreCountFilter(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"helloworld didn't start on lcore{lcores[0]}", + ) + + def test_hello_world_all_cores(self) -> None: + """ + Steps: + Run the helloworld app on all usable logical cores. + Verify: + The app prints a message from all used cores: + "hello from core " + """ + + # 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"helloworld didn't start on lcore{lcore}", + ) -- 2.30.2