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