def discover_running_cases()

in lisa/runners/legacy_runner.py [0:0]


    def discover_running_cases(self) -> List[Dict[str, str]]:
        cases: List[Dict[str, str]] = []
        for line in self._line_iter():
            case_match = self.CASE_RUNNING.match(line)
            if case_match:
                name = case_match["name"]
                current_case: Dict[str, str] = {
                    key: value for key, value in case_match.groupdict().items() if value
                }
            image_match = self.CASE_IMAGE_LOCATION.match(line)
            location = ""
            if image_match:
                location = image_match["location"]
                current_case.update(
                    {
                        key: value
                        for key, value in image_match.groupdict().items()
                        if value
                    }
                )
                # marketplace_image for ARMImage, vhd_image for OsVHD in legacy run
                if "marketplace_image" in current_case.keys():
                    current_case["image"] = current_case.pop("marketplace_image")
                elif "vhd_image" in current_case.keys():
                    current_case["image"] = current_case.pop("vhd_image")
                else:
                    raise LisaException(
                        "Can't get ARMImage or OsVHD from legacy run "
                        "when parsing running cases"
                    )
                # In sequence run, there is no vm size log line.
                # So, when image and location is found, the case can be added.
                cases.append(current_case)
            vmsize_match = self.CASE_VMSIZE.match(line)
            if vmsize_match:
                temp_name = vmsize_match["name"]
                temp_location = vmsize_match["location"]
                assert name == temp_name, (
                    f"cannot match location between logs. "
                    f"current case is: '{name}', "
                    f"name in vmsize is: '{temp_name}'. {line}"
                )
                if location:
                    assert location == temp_location, (
                        f"cannot match location between logs. "
                        f"setup config is: '{location}', "
                        f"location in vmsize is: '{temp_location}'. {line}"
                    )
                current_case.update(
                    {
                        key: value
                        for key, value in vmsize_match.groupdict().items()
                        if value
                    }
                )
        return cases