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