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š 10*bfad0948SLuca Vizzarrofrom framework.remote_session.dpdk_shell import compute_eal_params 11444833c0SJuraj Linkešfrom framework.test_suite import TestSuite 122b2f5a8aSLuca Vizzarrofrom framework.testbed_model.cpu import ( 13444833c0SJuraj Linkeš LogicalCoreCount, 14444833c0SJuraj Linkeš LogicalCoreCountFilter, 15444833c0SJuraj Linkeš LogicalCoreList, 16444833c0SJuraj Linkeš) 17444833c0SJuraj Linkeš 18444833c0SJuraj Linkeš 19444833c0SJuraj Linkešclass TestHelloWorld(TestSuite): 206ef07151SJuraj Linkeš """DPDK hello world app test suite.""" 216ef07151SJuraj Linkeš 22444833c0SJuraj Linkeš def set_up_suite(self) -> None: 236ef07151SJuraj Linkeš """Set up the test suite. 246ef07151SJuraj Linkeš 25444833c0SJuraj Linkeš Setup: 26444833c0SJuraj Linkeš Build the app we're about to test - helloworld. 27444833c0SJuraj Linkeš """ 28444833c0SJuraj Linkeš self.app_helloworld_path = self.sut_node.build_dpdk_app("helloworld") 29444833c0SJuraj Linkeš 30444833c0SJuraj Linkeš def test_hello_world_single_core(self) -> None: 316ef07151SJuraj Linkeš """Single core test case. 326ef07151SJuraj Linkeš 33444833c0SJuraj Linkeš Steps: 34444833c0SJuraj Linkeš Run the helloworld app on the first usable logical core. 35444833c0SJuraj Linkeš Verify: 36444833c0SJuraj Linkeš The app prints a message from the used core: 37444833c0SJuraj Linkeš "hello from core <core_id>" 38444833c0SJuraj Linkeš """ 39444833c0SJuraj Linkeš # get the first usable core 40444833c0SJuraj Linkeš lcore_amount = LogicalCoreCount(1, 1, 1) 41444833c0SJuraj Linkeš lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter() 42*bfad0948SLuca Vizzarro eal_para = compute_eal_params(self.sut_node, lcore_filter_specifier=lcore_amount) 43444833c0SJuraj Linkeš result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para) 44444833c0SJuraj Linkeš self.verify( 45444833c0SJuraj Linkeš f"hello from core {int(lcores[0])}" in result.stdout, 46444833c0SJuraj Linkeš f"helloworld didn't start on lcore{lcores[0]}", 47444833c0SJuraj Linkeš ) 48444833c0SJuraj Linkeš 49444833c0SJuraj Linkeš def test_hello_world_all_cores(self) -> None: 506ef07151SJuraj Linkeš """All cores test case. 516ef07151SJuraj Linkeš 52444833c0SJuraj Linkeš Steps: 53444833c0SJuraj Linkeš Run the helloworld app on all usable logical cores. 54444833c0SJuraj Linkeš Verify: 55444833c0SJuraj Linkeš The app prints a message from all used cores: 56444833c0SJuraj Linkeš "hello from core <core_id>" 57444833c0SJuraj Linkeš """ 58444833c0SJuraj Linkeš # get the maximum logical core number 59*bfad0948SLuca Vizzarro eal_para = compute_eal_params( 60*bfad0948SLuca Vizzarro self.sut_node, lcore_filter_specifier=LogicalCoreList(self.sut_node.lcores) 61444833c0SJuraj Linkeš ) 62444833c0SJuraj Linkeš result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para, 50) 63444833c0SJuraj Linkeš for lcore in self.sut_node.lcores: 64444833c0SJuraj Linkeš self.verify( 65444833c0SJuraj Linkeš f"hello from core {int(lcore)}" in result.stdout, 66444833c0SJuraj Linkeš f"helloworld didn't start on lcore{lcore}", 67444833c0SJuraj Linkeš ) 68