Best Python code snippet using lisa_python
dpdktestpmd.py
Source:dpdktestpmd.py  
...784            fail("Could not locate testpmd binary after installation!")785        elif not path_check:786            self._testpmd_install_path = ""787        return path_check788    def _split_testpmd_output(self) -> None:789        search_str = "Port 0: device removal event"790        device_removal_index = self._last_run_output.find(search_str)791        assert_that(device_removal_index).described_as(792            "Could not locate SRIOV rescind event in testpmd output"793        ).is_not_equal_to(-1)794        self._testpmd_output_before_rescind = self._last_run_output[795            :device_removal_index796        ]797        after_rescind = self._last_run_output[device_removal_index:]798        # Identify the device add event799        hotplug_match = self._search_hotplug_regex.finditer(after_rescind)800        matches_list = list(hotplug_match)801        if not list(matches_list):802            hotplug_alt_match = self._search_hotplug_regex_alt.finditer(after_rescind)803            if hotplug_alt_match:804                matches_list = list(hotplug_alt_match)805            else:806                command_dumped = "timeout: the monitored command dumped core"807                if command_dumped in self._last_run_output:808                    raise LisaException("Testpmd crashed after device removal.")809        # pick the last match810        if len(matches_list) > 0:811            last_match = matches_list[-1]812        else:813            raise LisaException(814                "Found no vf hotplug events in testpmd output. "815                "Check output to verify if PPS drop occurred and port removal "816                "event message matches the expected forms."817            )818        self.node.log.info(f"Identified hotplug event: {last_match.group(0)}")819        before_reenable = after_rescind[: last_match.start()]820        after_reenable = after_rescind[last_match.end() :]821        self._testpmd_output_during_rescind = before_reenable822        self._testpmd_output_after_reenable = after_reenable823    def _get_pps_sriov_rescind(824        self,825        key_constant: str,826    ) -> Tuple[int, int, int]:827        if not all(828            [829                self._testpmd_output_during_rescind,830                self._testpmd_output_after_reenable,831                self._testpmd_output_before_rescind,832            ]833        ):834            self._split_testpmd_output()835        before_rescind = self.get_data_from_testpmd_output(836            key_constant,837            self._testpmd_output_before_rescind,838        )839        during_rescind = self.get_data_from_testpmd_output(840            key_constant,841            self._testpmd_output_during_rescind,842        )843        after_reenable = self.get_data_from_testpmd_output(844            key_constant,845            self._testpmd_output_after_reenable,846        )847        before, during, after = map(848            _mean, [before_rescind, during_rescind, after_reenable]...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
