|
29 | 29 | from twisterlib.platform import Platform
|
30 | 30 | from twisterlib.config_parser import TwisterConfigParser
|
31 | 31 | from twisterlib.testinstance import TestInstance
|
| 32 | +from twisterlib.quarantine import Quarantine |
32 | 33 |
|
33 | 34 |
|
34 | 35 | from zephyr_module import parse_modules
|
@@ -79,7 +80,7 @@ def __init__(self, env=None):
|
79 | 80 |
|
80 | 81 | # Keep track of which test cases we've filtered out and why
|
81 | 82 | self.testsuites = {}
|
82 |
| - self.quarantine = {} |
| 83 | + self.quarantine = None |
83 | 84 | self.platforms = []
|
84 | 85 | self.platform_names = []
|
85 | 86 | self.selected_platforms = []
|
@@ -128,15 +129,12 @@ def discover(self):
|
128 | 129 |
|
129 | 130 | # handle quarantine
|
130 | 131 | ql = self.options.quarantine_list
|
131 |
| - if ql: |
132 |
| - self.load_quarantine(ql) |
133 |
| - |
134 | 132 | qv = self.options.quarantine_verify
|
135 |
| - if qv: |
136 |
| - if not ql: |
137 |
| - logger.error("No quarantine list given to be verified") |
138 |
| - raise TwisterRuntimeError("No quarantine list given to be verified") |
139 |
| - |
| 133 | + if qv and not ql: |
| 134 | + logger.error("No quarantine list given to be verified") |
| 135 | + raise TwisterRuntimeError("No quarantine list given to be verified") |
| 136 | + if ql: |
| 137 | + self.quarantine = Quarantine(ql) |
140 | 138 |
|
141 | 139 | def load(self):
|
142 | 140 |
|
@@ -463,35 +461,6 @@ def get_platform(self, name):
|
463 | 461 | break
|
464 | 462 | return selected_platform
|
465 | 463 |
|
466 |
| - def load_quarantine(self, file): |
467 |
| - """ |
468 |
| - Loads quarantine list from the given yaml file. Creates a dictionary |
469 |
| - of all tests configurations (platform + scenario: comment) that shall be |
470 |
| - skipped due to quarantine |
471 |
| - """ |
472 |
| - |
473 |
| - # Load yaml into quarantine_yaml |
474 |
| - quarantine_yaml = scl.yaml_load_verify(file, self.quarantine_schema) |
475 |
| - |
476 |
| - # Create quarantine_list with a product of the listed |
477 |
| - # platforms and scenarios for each entry in quarantine yaml |
478 |
| - quarantine_list = [] |
479 |
| - for quar_dict in quarantine_yaml: |
480 |
| - if quar_dict['platforms'][0] == "all": |
481 |
| - plat = self.platform_names |
482 |
| - else: |
483 |
| - plat = quar_dict['platforms'] |
484 |
| - self.verify_platforms_existence(plat, "quarantine-list") |
485 |
| - comment = quar_dict.get('comment', "NA") |
486 |
| - quarantine_list.append([{".".join([p, s]): comment} |
487 |
| - for p in plat for s in quar_dict['scenarios']]) |
488 |
| - |
489 |
| - # Flatten the quarantine_list |
490 |
| - quarantine_list = [it for sublist in quarantine_list for it in sublist] |
491 |
| - # Change quarantine_list into a dictionary |
492 |
| - for d in quarantine_list: |
493 |
| - self.quarantine.update(d) |
494 |
| - |
495 | 464 | def load_from_file(self, file, filter_platform=[]):
|
496 | 465 | with open(file, "r") as json_test_plan:
|
497 | 466 | jtp = json.load(json_test_plan)
|
@@ -775,14 +744,15 @@ def apply_filters(self, **kwargs):
|
775 | 744 | else:
|
776 | 745 | instance.add_filter(f"Excluded platform missing key fields demanded by test {key_fields}", Filters.PLATFORM)
|
777 | 746 |
|
778 |
| - test_configuration = ".".join([instance.platform.name, |
779 |
| - instance.testsuite.id]) |
780 |
| - # skip quarantined tests |
781 |
| - if test_configuration in self.quarantine and not self.options.quarantine_verify: |
782 |
| - instance.add_filter(f"Quarantine: {self.quarantine[test_configuration]}", Filters.QUARENTINE) |
783 |
| - # run only quarantined test to verify their statuses (skip everything else) |
784 |
| - if self.options.quarantine_verify and test_configuration not in self.quarantine: |
785 |
| - instance.add_filter("Not under quarantine", Filters.QUARENTINE) |
| 747 | + # handle quarantined tests |
| 748 | + if self.quarantine: |
| 749 | + matched_quarantine = self.quarantine.get_matched_quarantine( |
| 750 | + instance.testsuite.id, plat.name, plat.arch |
| 751 | + ) |
| 752 | + if matched_quarantine and not self.options.quarantine_verify: |
| 753 | + instance.add_filter(matched_quarantine, Filters.QUARENTINE) |
| 754 | + if not matched_quarantine and self.options.quarantine_verify: |
| 755 | + instance.add_filter("Not under quarantine", Filters.QUARENTINE) |
786 | 756 |
|
787 | 757 | # if nothing stopped us until now, it means this configuration
|
788 | 758 | # needs to be added.
|
|
0 commit comments