xref: /dpdk/dts/tests/TestSuite_hello_world.py (revision 039256daa8bfa9d258b57b5fd56c12df9891721f)
1444833c0SJuraj Linkeš# SPDX-License-Identifier: BSD-3-Clause
2444833c0SJuraj Linkeš# Copyright(c) 2010-2014 Intel Corporation
3444833c0SJuraj Linkeš
46ef07151SJuraj Linkeš"""The DPDK hello world app test suite.
56ef07151SJuraj Linkeš
6444833c0SJuraj LinkešRun the helloworld example app and verify it prints a message for each used core.
7444833c0SJuraj LinkešNo other EAL parameters apart from cores are used.
8444833c0SJuraj Linkeš"""
9444833c0SJuraj Linkeš
10bfad0948SLuca Vizzarrofrom framework.remote_session.dpdk_shell import compute_eal_params
11b6eb5004SJuraj Linkešfrom framework.test_suite import TestSuite, func_test
12*039256daSJuraj Linkešfrom framework.testbed_model.capability import TopologyType, requires
132b2f5a8aSLuca Vizzarrofrom framework.testbed_model.cpu import (
14444833c0SJuraj Linkeš    LogicalCoreCount,
15444833c0SJuraj Linkeš    LogicalCoreCountFilter,
16444833c0SJuraj Linkeš    LogicalCoreList,
17444833c0SJuraj Linkeš)
18444833c0SJuraj Linkeš
19444833c0SJuraj Linkeš
20*039256daSJuraj Linkeš@requires(topology_type=TopologyType.no_link)
21444833c0SJuraj Linkešclass TestHelloWorld(TestSuite):
226ef07151SJuraj Linkeš    """DPDK hello world app test suite."""
236ef07151SJuraj Linkeš
24444833c0SJuraj Linkeš    def set_up_suite(self) -> None:
256ef07151SJuraj Linkeš        """Set up the test suite.
266ef07151SJuraj Linkeš
27444833c0SJuraj Linkeš        Setup:
28444833c0SJuraj Linkeš            Build the app we're about to test - helloworld.
29444833c0SJuraj Linkeš        """
30444833c0SJuraj Linkeš        self.app_helloworld_path = self.sut_node.build_dpdk_app("helloworld")
31444833c0SJuraj Linkeš
32b6eb5004SJuraj Linkeš    @func_test
33b6eb5004SJuraj Linkeš    def hello_world_single_core(self) -> None:
346ef07151SJuraj Linkeš        """Single core test case.
356ef07151SJuraj Linkeš
36444833c0SJuraj Linkeš        Steps:
37444833c0SJuraj Linkeš            Run the helloworld app on the first usable logical core.
38444833c0SJuraj Linkeš        Verify:
39444833c0SJuraj Linkeš            The app prints a message from the used core:
40444833c0SJuraj Linkeš            "hello from core <core_id>"
41444833c0SJuraj Linkeš        """
42444833c0SJuraj Linkeš        # get the first usable core
43444833c0SJuraj Linkeš        lcore_amount = LogicalCoreCount(1, 1, 1)
44444833c0SJuraj Linkeš        lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter()
45bfad0948SLuca Vizzarro        eal_para = compute_eal_params(self.sut_node, lcore_filter_specifier=lcore_amount)
46444833c0SJuraj Linkeš        result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para)
47444833c0SJuraj Linkeš        self.verify(
48444833c0SJuraj Linkeš            f"hello from core {int(lcores[0])}" in result.stdout,
49444833c0SJuraj Linkeš            f"helloworld didn't start on lcore{lcores[0]}",
50444833c0SJuraj Linkeš        )
51444833c0SJuraj Linkeš
52b6eb5004SJuraj Linkeš    @func_test
53b6eb5004SJuraj Linkeš    def hello_world_all_cores(self) -> None:
546ef07151SJuraj Linkeš        """All cores test case.
556ef07151SJuraj Linkeš
56444833c0SJuraj Linkeš        Steps:
57444833c0SJuraj Linkeš            Run the helloworld app on all usable logical cores.
58444833c0SJuraj Linkeš        Verify:
59444833c0SJuraj Linkeš            The app prints a message from all used cores:
60444833c0SJuraj Linkeš            "hello from core <core_id>"
61444833c0SJuraj Linkeš        """
62444833c0SJuraj Linkeš        # get the maximum logical core number
63bfad0948SLuca Vizzarro        eal_para = compute_eal_params(
64bfad0948SLuca Vizzarro            self.sut_node, lcore_filter_specifier=LogicalCoreList(self.sut_node.lcores)
65444833c0SJuraj Linkeš        )
66444833c0SJuraj Linkeš        result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para, 50)
67444833c0SJuraj Linkeš        for lcore in self.sut_node.lcores:
68444833c0SJuraj Linkeš            self.verify(
69444833c0SJuraj Linkeš                f"hello from core {int(lcore)}" in result.stdout,
70444833c0SJuraj Linkeš                f"helloworld didn't start on lcore{lcore}",
71444833c0SJuraj Linkeš            )
72