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(lcore_filter_specifier=lcore_amount) 38 result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para) 39 self.verify( 40 f"hello from core {int(lcores[0])}" in result.stdout, 41 f"helloworld didn't start on lcore{lcores[0]}", 42 ) 43 44 def test_hello_world_all_cores(self) -> None: 45 """ 46 Steps: 47 Run the helloworld app on all usable logical cores. 48 Verify: 49 The app prints a message from all used cores: 50 "hello from core <core_id>" 51 """ 52 53 # get the maximum logical core number 54 eal_para = self.sut_node.create_eal_parameters( 55 lcore_filter_specifier=LogicalCoreList(self.sut_node.lcores) 56 ) 57 result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para, 50) 58 for lcore in self.sut_node.lcores: 59 self.verify( 60 f"hello from core {int(lcore)}" in result.stdout, 61 f"helloworld didn't start on lcore{lcore}", 62 ) 63