Skip to content

Commit 49595c7

Browse files
PerMackartben
authored andcommitted
twister: Adjust status for quarantined instances
Skipped status fits quarantined items better than filtered. Filtered tests are by default removed from reports, which shouldn't be the case for quarantined tests. Adjust tests unit and blackbox tests accordingly. Signed-off-by: Maciej Perkowski <maciej.perkowski@nordicsemi.no>
1 parent 50f36f0 commit 49595c7

File tree

7 files changed

+53
-24
lines changed

7 files changed

+53
-24
lines changed

scripts/pylib/twister/twisterlib/reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def summary(self, results, duration):
734734
f'.'
735735
)
736736

737-
built_only = results.total - run - results.filtered_configs
737+
built_only = results.total - run - results.filtered_configs - results.skipped
738738
logger.info(
739739
f"{Fore.GREEN}{run}{Fore.RESET} test configurations executed on platforms,"
740740
f" {TwisterStatus.get_color(TwisterStatus.NOTRUN)}{built_only}{Fore.RESET}"

scripts/pylib/twister/twisterlib/runner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ def run(self):
18851885
self.results.done -= self.results.error
18861886
self.results.error = 0
18871887
else:
1888-
self.results.done = self.results.filtered_static
1888+
self.results.done = self.results.filtered_static + self.results.skipped
18891889

18901890
self.execute(pipeline, done_queue)
18911891

@@ -1923,6 +1923,10 @@ def update_counting_before_pipeline(self):
19231923
self.results.filtered_configs_increment()
19241924
self.results.filtered_cases_increment(len(instance.testsuite.testcases))
19251925
self.results.cases_increment(len(instance.testsuite.testcases))
1926+
elif instance.status == TwisterStatus.SKIP and "overflow" not in instance.reason:
1927+
self.results.skipped_increment()
1928+
self.results.skipped_cases_increment(len(instance.testsuite.testcases))
1929+
self.results.cases_increment(len(instance.testsuite.testcases))
19261930
elif instance.status == TwisterStatus.ERROR:
19271931
self.results.error_increment()
19281932

scripts/pylib/twister/twisterlib/testplan.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,12 @@ def handle_quarantined_tests(self, instance: TestInstance, plat: Platform):
605605
sim_name
606606
)
607607
if matched_quarantine and not self.options.quarantine_verify:
608-
instance.add_filter("Quarantine: " + matched_quarantine, Filters.QUARANTINE)
608+
instance.status = TwisterStatus.SKIP
609+
instance.reason = "Quarantine: " + matched_quarantine
609610
return
610611
if not matched_quarantine and self.options.quarantine_verify:
611-
instance.add_filter("Not under quarantine", Filters.QUARANTINE)
612+
instance.status = TwisterStatus.SKIP
613+
instance.reason = "Not under quarantine"
612614

613615
def load_from_file(self, file, filter_platform=None):
614616
if filter_platform is None:

scripts/pylib/twister/twisterlib/twister_main.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,26 @@ def twister(options: argparse.Namespace, default_options: argparse.Namespace):
104104
logger.error(f"{e}")
105105
return 1
106106

107-
if options.verbose > 1:
108-
# if we are using command line platform filter, no need to list every
109-
# other platform as excluded, we know that already.
110-
# Show only the discards that apply to the selected platforms on the
111-
# command line
107+
# if we are using command line platform filter, no need to list every
108+
# other platform as excluded, we know that already.
109+
# Show only the discards that apply to the selected platforms on the
110+
# command line
112111

112+
if options.verbose > 0:
113113
for i in tplan.instances.values():
114-
if i.status == TwisterStatus.FILTER:
114+
if i.status in [TwisterStatus.SKIP,TwisterStatus.FILTER]:
115115
if options.platform and not tplan.check_platform(i.platform, options.platform):
116116
continue
117+
# Filtered tests should be visable only when verbosity > 1
118+
if options.verbose < 2 and i.status == TwisterStatus.FILTER:
119+
continue
120+
res = i.reason
121+
if "Quarantine" in i.reason:
122+
res = "Quarantined"
117123
logger.info(
118124
f"{i.platform.name:<25} {i.testsuite.name:<50}"
119-
f" {Fore.YELLOW}FILTERED{Fore.RESET}: {i.reason}"
120-
)
125+
f" {Fore.YELLOW}{i.status.upper()}{Fore.RESET}: {res}"
126+
)
121127

122128
report = Reporting(tplan, env)
123129
plan_file = os.path.join(options.outdir, "testplan.json")

scripts/tests/twister/test_runner.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,8 @@ def mock_client_from_environ(jobs):
25452545
results_mock().iteration = 0
25462546
results_mock().failed = 2
25472547
results_mock().total = 9
2548+
results_mock().filtered_static = 0
2549+
results_mock().skipped = 0
25482550

25492551
def iteration_increment(value=1, decrement=False):
25502552
results_mock().iteration += value * (-1 if decrement else 1)
@@ -2608,7 +2610,7 @@ def test_twisterrunner_update_counting_before_pipeline():
26082610
),
26092611
'dummy5': mock.Mock(
26102612
status=TwisterStatus.SKIP,
2611-
reason=None,
2613+
reason="Quarantine",
26122614
testsuite=mock.Mock(
26132615
testcases=[mock.Mock()]
26142616
)
@@ -2629,6 +2631,7 @@ def test_twisterrunner_update_counting_before_pipeline():
26292631
error = 0,
26302632
cases = 0,
26312633
filtered_cases = 0,
2634+
skipped = 0,
26322635
skipped_cases = 0,
26332636
failed_cases = 0,
26342637
error_cases = 0,
@@ -2652,14 +2655,22 @@ def cases_increment(value=1, decrement=False):
26522655
def filtered_cases_increment(value=1, decrement=False):
26532656
tr.results.filtered_cases += value * (-1 if decrement else 1)
26542657
tr.results.filtered_cases_increment = filtered_cases_increment
2658+
def skipped_increment(value=1, decrement=False):
2659+
tr.results.skipped += value * (-1 if decrement else 1)
2660+
tr.results.skipped_increment = skipped_increment
2661+
def skipped_cases_increment(value=1, decrement=False):
2662+
tr.results.skipped_cases += value * (-1 if decrement else 1)
2663+
tr.results.skipped_cases_increment = skipped_cases_increment
26552664

26562665
tr.update_counting_before_pipeline()
26572666

26582667
assert tr.results.filtered_static == 1
26592668
assert tr.results.filtered_configs == 1
26602669
assert tr.results.filtered_cases == 4
2661-
assert tr.results.cases == 4
2670+
assert tr.results.cases == 5
26622671
assert tr.results.error == 1
2672+
assert tr.results.skipped == 1
2673+
assert tr.results.skipped_cases == 1
26632674

26642675

26652676
def test_twisterrunner_show_brief(caplog):

scripts/tests/twister/test_testplan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ def test_quarantine_short(class_testplan, platforms_list, test_data,
342342
if testname in expected_val:
343343
assert instance.status == TwisterStatus.NONE
344344
else:
345-
assert instance.status == TwisterStatus.FILTER
345+
assert instance.status == TwisterStatus.SKIP
346346
assert instance.reason == "Not under quarantine"
347347
else:
348348
if testname in expected_val:
349-
assert instance.status == TwisterStatus.FILTER
349+
assert instance.status == TwisterStatus.SKIP
350350
assert instance.reason == "Quarantine: " + expected_val[testname]
351351
else:
352352
assert instance.status == TwisterStatus.NONE

scripts/tests/twister_blackbox/test_quarantine.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import json
1616

1717
# pylint: disable=duplicate-code
18+
# pylint: disable=no-name-in-module
1819
from conftest import ZEPHYR_BASE, TEST_DATA, testsuite_filename_mock
1920
from twisterlib.testplan import TestPlan
2021

@@ -49,10 +50,15 @@ def test_quarantine_verify(self, out_path):
4950

5051
with open(os.path.join(out_path, 'testplan.json')) as f:
5152
j = json.load(f)
53+
54+
# Quarantine-verify "swaps" statuses. The ones that are in quarantine list
55+
# should no longer be quarantined, and the ones that are not in the list
56+
# should be quarantined. Remove "quarantined" tests from "verify" testplan
57+
# to count what should be verified.
5258
filtered_j = [
53-
(ts['platform'], ts['name'], tc['identifier']) \
59+
(ts['platform'], ts['name']) \
5460
for ts in j['testsuites'] \
55-
for tc in ts['testcases'] if 'reason' not in tc
61+
if ts['status'] != "skipped"
5662
]
5763

5864
assert str(sys_exit.value) == '0'
@@ -89,26 +95,26 @@ def test_quarantine_list(self, capfd, out_path, test_path, test_platforms, quara
8995
sys.stdout.write(out)
9096
sys.stderr.write(err)
9197

92-
board1_match1 = re.search('agnostic/group2/dummy.agnostic.group2 FILTERED: Quarantine: test '
98+
board1_match1 = re.search('agnostic/group2/dummy.agnostic.group2 SKIPPED: Quarantine: test '
9399
'intel_adl_crb', err)
94100
board1_match2 = re.search(
95-
'agnostic/group1/subgroup2/dummy.agnostic.group1.subgroup2 FILTERED: Quarantine: test '
101+
'agnostic/group1/subgroup2/dummy.agnostic.group1.subgroup2 SKIPPED: Quarantine: test '
96102
'intel_adl_crb',
97103
err)
98104
qemu_64_match = re.search(
99-
'agnostic/group1/subgroup2/dummy.agnostic.group1.subgroup2 FILTERED: Quarantine: test '
105+
'agnostic/group1/subgroup2/dummy.agnostic.group1.subgroup2 SKIPPED: Quarantine: test '
100106
'qemu_x86_64',
101107
err)
102108
all_platforms_match = re.search(
103-
'agnostic/group1/subgroup1/dummy.agnostic.group1.subgroup1 FILTERED: Quarantine: test '
109+
'agnostic/group1/subgroup1/dummy.agnostic.group1.subgroup1 SKIPPED: Quarantine: test '
104110
'all platforms',
105111
err)
106112
all_platforms_match2 = re.search(
107-
'agnostic/group1/subgroup1/dummy.agnostic.group1.subgroup1 FILTERED: Quarantine: test '
113+
'agnostic/group1/subgroup1/dummy.agnostic.group1.subgroup1 SKIPPED: Quarantine: test '
108114
'all platforms',
109115
err)
110116
all_platforms_match3 = re.search(
111-
'agnostic/group1/subgroup1/dummy.agnostic.group1.subgroup1 FILTERED: Quarantine: test '
117+
'agnostic/group1/subgroup1/dummy.agnostic.group1.subgroup1 SKIPPED: Quarantine: test '
112118
'all platforms',
113119
err)
114120

0 commit comments

Comments
 (0)