188489c05SJeremy Spewock# SPDX-License-Identifier: BSD-3-Clause 288489c05SJeremy Spewock# Copyright(c) 2023 University of New Hampshire 388489c05SJeremy Spewock 46ef07151SJuraj Linkeš"""Smoke test suite. 56ef07151SJuraj Linkeš 66ef07151SJuraj LinkešSmoke tests are a class of tests which are used for validating a minimal set of important features. 76ef07151SJuraj LinkešThese are the most important features without which (or when they're faulty) the software wouldn't 86ef07151SJuraj Linkešwork properly. Thus, if any failure occurs while testing these features, 96ef07151SJuraj Linkešthere isn't that much of a reason to continue testing, as the software is fundamentally broken. 106ef07151SJuraj Linkeš 116ef07151SJuraj LinkešThese tests don't have to include only DPDK tests, as the reason for failures could be 126ef07151SJuraj Linkešin the infrastructure (a faulty link between NICs or a misconfiguration). 136ef07151SJuraj Linkeš""" 146ef07151SJuraj Linkeš 1588489c05SJeremy Spewockimport re 1688489c05SJeremy Spewock 1788489c05SJeremy Spewockfrom framework.config import PortConfig 182b2f5a8aSLuca Vizzarrofrom framework.remote_session.testpmd_shell import TestPmdShell 1988489c05SJeremy Spewockfrom framework.settings import SETTINGS 20b6eb5004SJuraj Linkešfrom framework.test_suite import TestSuite, func_test 21039256daSJuraj Linkešfrom framework.testbed_model.capability import TopologyType, requires 2288489c05SJeremy Spewockfrom framework.utils import REGEX_FOR_PCI_ADDRESS 2388489c05SJeremy Spewock 2488489c05SJeremy Spewock 25039256daSJuraj Linkeš@requires(topology_type=TopologyType.no_link) 265d094f9fSJuraj Linkešclass TestSmokeTests(TestSuite): 276ef07151SJuraj Linkeš """DPDK and infrastructure smoke test suite. 286ef07151SJuraj Linkeš 296ef07151SJuraj Linkeš The test cases validate the most basic DPDK functionality needed for all other test suites. 306ef07151SJuraj Linkeš The infrastructure also needs to be tested, as that is also used by all other test suites. 316ef07151SJuraj Linkeš 326ef07151SJuraj Linkeš Attributes: 336ef07151SJuraj Linkeš is_blocking: This test suite will block the execution of all other test suites 3411b2279aSTomáš Ďurovec in the test run after it. 356ef07151SJuraj Linkeš nics_in_node: The NICs present on the SUT node. 366ef07151SJuraj Linkeš """ 376ef07151SJuraj Linkeš 3888489c05SJeremy Spewock is_blocking = True 3988489c05SJeremy Spewock # dicts in this list are expected to have two keys: 4088489c05SJeremy Spewock # "pci_address" and "current_driver" 4188489c05SJeremy Spewock nics_in_node: list[PortConfig] = [] 4288489c05SJeremy Spewock 4388489c05SJeremy Spewock def set_up_suite(self) -> None: 446ef07151SJuraj Linkeš """Set up the test suite. 456ef07151SJuraj Linkeš 4688489c05SJeremy Spewock Setup: 476ef07151SJuraj Linkeš Set the build directory path and a list of NICs in the SUT node. 4888489c05SJeremy Spewock """ 4988489c05SJeremy Spewock self.dpdk_build_dir_path = self.sut_node.remote_dpdk_build_dir 5088489c05SJeremy Spewock self.nics_in_node = self.sut_node.config.ports 5188489c05SJeremy Spewock 52b6eb5004SJuraj Linkeš @func_test 5388489c05SJeremy Spewock def test_unit_tests(self) -> None: 546ef07151SJuraj Linkeš """DPDK meson ``fast-tests`` unit tests. 556ef07151SJuraj Linkeš 566ef07151SJuraj Linkeš Test that all unit test from the ``fast-tests`` suite pass. 576ef07151SJuraj Linkeš The suite is a subset with only the most basic tests. 586ef07151SJuraj Linkeš 5988489c05SJeremy Spewock Test: 606ef07151SJuraj Linkeš Run the ``fast-tests`` unit test suite through meson. 6188489c05SJeremy Spewock """ 6288489c05SJeremy Spewock self.sut_node.main_session.send_command( 6388489c05SJeremy Spewock f"meson test -C {self.dpdk_build_dir_path} --suite fast-tests -t 60", 6488489c05SJeremy Spewock 480, 6588489c05SJeremy Spewock verify=True, 6688489c05SJeremy Spewock privileged=True, 6788489c05SJeremy Spewock ) 6888489c05SJeremy Spewock 69b6eb5004SJuraj Linkeš @func_test 7088489c05SJeremy Spewock def test_driver_tests(self) -> None: 716ef07151SJuraj Linkeš """DPDK meson ``driver-tests`` unit tests. 726ef07151SJuraj Linkeš 736ef07151SJuraj Linkeš Test that all unit test from the ``driver-tests`` suite pass. 746ef07151SJuraj Linkeš The suite is a subset with driver tests. This suite may be run with virtual devices 756ef07151SJuraj Linkeš configured in the test run configuration. 766ef07151SJuraj Linkeš 7788489c05SJeremy Spewock Test: 786ef07151SJuraj Linkeš Run the ``driver-tests`` unit test suite through meson. 7988489c05SJeremy Spewock """ 8088489c05SJeremy Spewock vdev_args = "" 8188489c05SJeremy Spewock for dev in self.sut_node.virtual_devices: 8288489c05SJeremy Spewock vdev_args += f"--vdev {dev} " 8388489c05SJeremy Spewock vdev_args = vdev_args[:-1] 84517b4b26SJuraj Linkeš driver_tests_command = f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests" 8588489c05SJeremy Spewock if vdev_args: 8688489c05SJeremy Spewock self._logger.info( 87517b4b26SJuraj Linkeš f"Running driver tests with the following virtual devices: {vdev_args}" 8888489c05SJeremy Spewock ) 8988489c05SJeremy Spewock driver_tests_command += f' --test-args "{vdev_args}"' 9088489c05SJeremy Spewock 9188489c05SJeremy Spewock self.sut_node.main_session.send_command( 9288489c05SJeremy Spewock driver_tests_command, 9388489c05SJeremy Spewock 300, 9488489c05SJeremy Spewock verify=True, 9588489c05SJeremy Spewock privileged=True, 9688489c05SJeremy Spewock ) 9788489c05SJeremy Spewock 98b6eb5004SJuraj Linkeš @func_test 9988489c05SJeremy Spewock def test_devices_listed_in_testpmd(self) -> None: 1006ef07151SJuraj Linkeš """Testpmd device discovery. 1016ef07151SJuraj Linkeš 1026ef07151SJuraj Linkeš Test that the devices configured in the test run configuration are found in testpmd. 1036ef07151SJuraj Linkeš 10488489c05SJeremy Spewock Test: 1056ef07151SJuraj Linkeš List all devices found in testpmd and verify the configured devices are among them. 10688489c05SJeremy Spewock """ 1072b648cd4SJeremy Spewock with TestPmdShell(self.sut_node) as testpmd: 1082b648cd4SJeremy Spewock dev_list = [str(x) for x in testpmd.get_devices()] 10988489c05SJeremy Spewock for nic in self.nics_in_node: 11088489c05SJeremy Spewock self.verify( 11188489c05SJeremy Spewock nic.pci in dev_list, 11288489c05SJeremy Spewock f"Device {nic.pci} was not listed in testpmd's available devices, " 11388489c05SJeremy Spewock "please check your configuration", 11488489c05SJeremy Spewock ) 11588489c05SJeremy Spewock 116b6eb5004SJuraj Linkeš @func_test 11788489c05SJeremy Spewock def test_device_bound_to_driver(self) -> None: 1186ef07151SJuraj Linkeš """Device driver in OS. 1196ef07151SJuraj Linkeš 1206ef07151SJuraj Linkeš Test that the devices configured in the test run configuration are bound to 1216ef07151SJuraj Linkeš the proper driver. 1226ef07151SJuraj Linkeš 12388489c05SJeremy Spewock Test: 1246ef07151SJuraj Linkeš List all devices with the ``dpdk-devbind.py`` script and verify that 1256ef07151SJuraj Linkeš the configured devices are bound to the proper driver. 12688489c05SJeremy Spewock """ 12768010b2aSJeremy Spewock path_to_devbind = self.sut_node.path_to_devbind_script 12888489c05SJeremy Spewock 12988489c05SJeremy Spewock all_nics_in_dpdk_devbind = self.sut_node.main_session.send_command( 130*b935bdc3SLuca Vizzarro f"{path_to_devbind} --status | awk '/{REGEX_FOR_PCI_ADDRESS}/'", 13188489c05SJeremy Spewock SETTINGS.timeout, 13288489c05SJeremy Spewock ).stdout 13388489c05SJeremy Spewock 13488489c05SJeremy Spewock for nic in self.nics_in_node: 13588489c05SJeremy Spewock # This regular expression finds the line in the above string that starts 13688489c05SJeremy Spewock # with the address for the nic we are on in the loop and then captures the 13788489c05SJeremy Spewock # name of the driver in a group 13888489c05SJeremy Spewock devbind_info_for_nic = re.search( 139409359adSJuraj Linkeš f"{nic.pci}[^\\n]*drv=([\\d\\w-]*) [^\\n]*", 14088489c05SJeremy Spewock all_nics_in_dpdk_devbind, 14188489c05SJeremy Spewock ) 14288489c05SJeremy Spewock self.verify( 14388489c05SJeremy Spewock devbind_info_for_nic is not None, 14488489c05SJeremy Spewock f"Failed to find configured device ({nic.pci}) using dpdk-devbind.py", 14588489c05SJeremy Spewock ) 14688489c05SJeremy Spewock # We know this isn't None, but mypy doesn't 14788489c05SJeremy Spewock assert devbind_info_for_nic is not None 14888489c05SJeremy Spewock self.verify( 14968010b2aSJeremy Spewock devbind_info_for_nic.group(1) == nic.os_driver_for_dpdk, 15088489c05SJeremy Spewock f"Driver for device {nic.pci} does not match driver listed in " 15188489c05SJeremy Spewock f"configuration (bound to {devbind_info_for_nic.group(1)})", 15288489c05SJeremy Spewock ) 153