зеркало из https://github.com/microsoft/lisa.git
check platforms to prevent mismached feature types.
This commit is contained in:
Родитель
a767a8f82b
Коммит
125817aff0
|
@ -655,7 +655,9 @@ class LisaRunner(BaseRunner):
|
||||||
tested_environment = environment.get_guest_environment()
|
tested_environment = environment.get_guest_environment()
|
||||||
try:
|
try:
|
||||||
if result.check_environment(
|
if result.check_environment(
|
||||||
environment=tested_environment, save_reason=True
|
environment=tested_environment,
|
||||||
|
environment_platform_type=self.platform.type_name(),
|
||||||
|
save_reason=True,
|
||||||
) and (
|
) and (
|
||||||
not result.runtime_data.use_new_environment
|
not result.runtime_data.use_new_environment
|
||||||
or environment.is_new
|
or environment.is_new
|
||||||
|
@ -784,9 +786,6 @@ class LisaRunner(BaseRunner):
|
||||||
platform_type: str,
|
platform_type: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
assert platform_type
|
assert platform_type
|
||||||
platform_type_set = search_space.SetSpace[str](
|
|
||||||
is_allow_set=True, items=[platform_type]
|
|
||||||
)
|
|
||||||
|
|
||||||
cases_ignored_features: Dict[str, Set[str]] = {}
|
cases_ignored_features: Dict[str, Set[str]] = {}
|
||||||
# if platform defined requirement, replace the requirement from
|
# if platform defined requirement, replace the requirement from
|
||||||
|
@ -797,12 +796,10 @@ class LisaRunner(BaseRunner):
|
||||||
platform_requirement = self._create_platform_requirement()
|
platform_requirement = self._create_platform_requirement()
|
||||||
test_req: TestCaseRequirement = test_result.runtime_data.requirement
|
test_req: TestCaseRequirement = test_result.runtime_data.requirement
|
||||||
|
|
||||||
# check if there is platform requirement on test case
|
check_result = test_result.check_platform(platform_type)
|
||||||
if test_req.platform_type and len(test_req.platform_type) > 0:
|
if not check_result.result:
|
||||||
check_result = platform_type_set.check(test_req.platform_type)
|
test_result.set_status(TestStatus.SKIPPED, check_result.reasons)
|
||||||
if not check_result.result:
|
continue
|
||||||
test_result.set_status(TestStatus.SKIPPED, check_result.reasons)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if test_result.can_run:
|
if test_result.can_run:
|
||||||
assert test_req.environment
|
assert test_req.environment
|
||||||
|
|
|
@ -187,11 +187,23 @@ class TestResult:
|
||||||
self._send_result_message(self.stacktrace)
|
self._send_result_message(self.stacktrace)
|
||||||
|
|
||||||
def check_environment(
|
def check_environment(
|
||||||
self, environment: Environment, save_reason: bool = False
|
self,
|
||||||
|
environment: Environment,
|
||||||
|
# The environment platform may not be associated to the environment at
|
||||||
|
# early stage, so pass it in to validate.
|
||||||
|
environment_platform_type: str = "",
|
||||||
|
save_reason: bool = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
requirement = self.runtime_data.metadata.requirement
|
requirement = self.runtime_data.metadata.requirement
|
||||||
assert requirement.environment
|
assert requirement.environment
|
||||||
check_result = requirement.environment.check(environment.capability)
|
|
||||||
|
check_result = search_space.ResultReason()
|
||||||
|
if environment_platform_type:
|
||||||
|
check_result = self.check_platform(environment_platform_type)
|
||||||
|
|
||||||
|
if check_result.result:
|
||||||
|
check_result = requirement.environment.check(environment.capability)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
check_result.result
|
check_result.result
|
||||||
and requirement.os_type
|
and requirement.os_type
|
||||||
|
@ -230,6 +242,29 @@ class TestResult:
|
||||||
|
|
||||||
return self._timer.elapsed(False)
|
return self._timer.elapsed(False)
|
||||||
|
|
||||||
|
def check_platform(
|
||||||
|
self, environment_platform_type: str
|
||||||
|
) -> search_space.ResultReason:
|
||||||
|
result = search_space.ResultReason()
|
||||||
|
|
||||||
|
assert environment_platform_type, "platform type is not defined"
|
||||||
|
environment_platform_type_set = search_space.SetSpace[str](
|
||||||
|
is_allow_set=True, items=[environment_platform_type]
|
||||||
|
)
|
||||||
|
# only check platform, when it's defined.
|
||||||
|
if (
|
||||||
|
not self.runtime_data.requirement
|
||||||
|
or not self.runtime_data.requirement.platform_type
|
||||||
|
or len(self.runtime_data.requirement.platform_type.items) == 0
|
||||||
|
):
|
||||||
|
return result
|
||||||
|
|
||||||
|
test_supported_platforms = self.runtime_data.requirement.platform_type
|
||||||
|
|
||||||
|
result = environment_platform_type_set.check(test_supported_platforms)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def _send_result_message(self, stacktrace: Optional[str] = None) -> None:
|
def _send_result_message(self, stacktrace: Optional[str] = None) -> None:
|
||||||
self.elapsed = self.get_elapsed()
|
self.elapsed = self.get_elapsed()
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче