Skip to content

Commit 4acc332

Browse files
Detect repeated configuration names
Detect repeated configuration names. To keep this simple and fast, assume that we are doing a single make invocation for each separate build of the library, and report if there is more than one for a given value of "${MBEDTLS_TEST_PLATFORM};${MBEDTLS_TEST_CONFIGURATION}". Signed-off-by: Gilles Peskine <[email protected]>
1 parent 1a82925 commit 4acc332

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

tests/scripts/analyze_outcomes.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,18 @@ def analyze_outcomes(results: Results, outcomes: Outcomes, args) -> None:
175175
analyze_coverage(results, outcomes, args['allow_list'],
176176
args['full_coverage'])
177177

178-
def read_outcome_file(outcome_file: str) -> Outcomes:
178+
179+
180+
MAKE_LIB_TARGET = re.compile(r'all\Z|lib\Z|library/')
181+
182+
def read_outcome_file(results: Results, outcome_file: str) -> Outcomes:
179183
"""Parse an outcome file and return an outcome collection.
180184
"""
181185
outcomes = {}
186+
seen = {} #type: typing.Dict[str, int]
182187
with open(outcome_file, 'r', encoding='utf-8') as input_file:
183188
for line in input_file:
184-
(_platform, component, suite, case, result, _cause) = line.split(';')
189+
(platform, component, suite, case, result, _cause) = line.split(';')
185190
# Note that `component` is not unique. If a test case passes on Linux
186191
# and fails on FreeBSD, it'll end up in both the successes set and
187192
# the failures set.
@@ -192,6 +197,20 @@ def read_outcome_file(outcome_file: str) -> Outcomes:
192197
outcomes[component].successes.add(suite_case)
193198
elif result == 'FAIL':
194199
outcomes[component].failures.add(suite_case)
200+
build_name = ';'.join([platform, component])
201+
# Detect repeated make invocations to build all or part of the
202+
# library in the same configuration on the same platform.
203+
# This generally indicates that MBEDTLS_TEST_CONFIGURATION was
204+
# not set to a unique value.
205+
if suite == 'make' and MAKE_LIB_TARGET.match(case):
206+
seen.setdefault(build_name, 0)
207+
seen[build_name] += 1
208+
209+
# Complain about repeated configurations
210+
for build_name in sorted(seen.keys()):
211+
if seen[build_name] > 1:
212+
results.error('Repeated platform;configuration for library build: {}',
213+
build_name, seen[build_name])
195214

196215
return outcomes
197216

@@ -688,6 +707,8 @@ def main():
688707

689708
if options.specified_tasks == 'all':
690709
tasks_list = KNOWN_TASKS.keys()
710+
elif options.specified_tasks == 'parse_only':
711+
tasks_list = []
691712
else:
692713
tasks_list = re.split(r'[, ]+', options.specified_tasks)
693714
for task in tasks_list:
@@ -716,7 +737,7 @@ def main():
716737
task['args']['component_driver'],
717738
options.outcomes)
718739

719-
outcomes = read_outcome_file(options.outcomes)
740+
outcomes = read_outcome_file(main_results, options.outcomes)
720741

721742
for task in tasks_list:
722743
test_function = KNOWN_TASKS[task]['test_function']

0 commit comments

Comments
 (0)