xref: /dpdk/dts/tests/TestSuite_hello_world.py (revision 7917b0d38e92e8b9ec5a870415b791420e10f11a)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2010-2014 Intel Corporation
3
4"""The DPDK hello world app test suite.
5
6Run the helloworld example app and verify it prints a message for each used core.
7No other EAL parameters apart from cores are used.
8"""
9
10from framework.remote_session.dpdk_shell import compute_eal_params
11from framework.test_suite import TestSuite
12from framework.testbed_model.cpu import (
13    LogicalCoreCount,
14    LogicalCoreCountFilter,
15    LogicalCoreList,
16)
17
18
19class TestHelloWorld(TestSuite):
20    """DPDK hello world app test suite."""
21
22    def set_up_suite(self) -> None:
23        """Set up the test suite.
24
25        Setup:
26            Build the app we're about to test - helloworld.
27        """
28        self.app_helloworld_path = self.sut_node.build_dpdk_app("helloworld")
29
30    def test_hello_world_single_core(self) -> None:
31        """Single core test case.
32
33        Steps:
34            Run the helloworld app on the first usable logical core.
35        Verify:
36            The app prints a message from the used core:
37            "hello from core <core_id>"
38        """
39        # get the first usable core
40        lcore_amount = LogicalCoreCount(1, 1, 1)
41        lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter()
42        eal_para = compute_eal_params(self.sut_node, lcore_filter_specifier=lcore_amount)
43        result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para)
44        self.verify(
45            f"hello from core {int(lcores[0])}" in result.stdout,
46            f"helloworld didn't start on lcore{lcores[0]}",
47        )
48
49    def test_hello_world_all_cores(self) -> None:
50        """All cores test case.
51
52        Steps:
53            Run the helloworld app on all usable logical cores.
54        Verify:
55            The app prints a message from all used cores:
56            "hello from core <core_id>"
57        """
58        # get the maximum logical core number
59        eal_para = compute_eal_params(
60            self.sut_node, lcore_filter_specifier=LogicalCoreList(self.sut_node.lcores)
61        )
62        result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para, 50)
63        for lcore in self.sut_node.lcores:
64            self.verify(
65                f"hello from core {int(lcore)}" in result.stdout,
66                f"helloworld didn't start on lcore{lcore}",
67            )
68