@@ -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(
@@ -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:
"""
@@ -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
@@ -12,6 +12,7 @@
from .hw import (
LogicalCore,
LogicalCoreCount,
+ LogicalCoreCountFilter,
LogicalCoreList,
LogicalCoreListFilter,
VirtualDevice,
@@ -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__(
new file mode 100644
@@ -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 <core_id>"
+ """
+
+ # 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 <core_id>"
+ """
+
+ # 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}",
+ )