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, func_test 12from framework.testbed_model.capability import TopologyType, requires 13from framework.testbed_model.cpu import ( 14 LogicalCoreCount, 15 LogicalCoreCountFilter, 16 LogicalCoreList, 17) 18 19 20@requires(topology_type=TopologyType.no_link) 21class TestHelloWorld(TestSuite): 22 """DPDK hello world app test suite.""" 23 24 def set_up_suite(self) -> None: 25 """Set up the test suite. 26 27 Setup: 28 Build the app we're about to test - helloworld. 29 """ 30 self.app_helloworld_path = self.sut_node.build_dpdk_app("helloworld") 31 32 @func_test 33 def hello_world_single_core(self) -> None: 34 """Single core test case. 35 36 Steps: 37 Run the helloworld app on the first usable logical core. 38 Verify: 39 The app prints a message from the used core: 40 "hello from core <core_id>" 41 """ 42 # get the first usable core 43 lcore_amount = LogicalCoreCount(1, 1, 1) 44 lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter() 45 eal_para = compute_eal_params(self.sut_node, lcore_filter_specifier=lcore_amount) 46 result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para) 47 self.verify( 48 f"hello from core {int(lcores[0])}" in result.stdout, 49 f"helloworld didn't start on lcore{lcores[0]}", 50 ) 51 52 @func_test 53 def hello_world_all_cores(self) -> None: 54 """All cores test case. 55 56 Steps: 57 Run the helloworld app on all usable logical cores. 58 Verify: 59 The app prints a message from all used cores: 60 "hello from core <core_id>" 61 """ 62 # get the maximum logical core number 63 eal_para = compute_eal_params( 64 self.sut_node, lcore_filter_specifier=LogicalCoreList(self.sut_node.lcores) 65 ) 66 result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para, 50) 67 for lcore in self.sut_node.lcores: 68 self.verify( 69 f"hello from core {int(lcore)}" in result.stdout, 70 f"helloworld didn't start on lcore{lcore}", 71 ) 72