From 60063336977a591958d3f5414d89c492ba76220a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 19 Jun 2024 20:17:09 +0200 Subject: [PATCH 1/2] 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 --- scripts/mbedtls_framework/outcome_analysis.py | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/mbedtls_framework/outcome_analysis.py b/scripts/mbedtls_framework/outcome_analysis.py index 2a79fd57d..e911bc00b 100644 --- a/scripts/mbedtls_framework/outcome_analysis.py +++ b/scripts/mbedtls_framework/outcome_analysis.py @@ -122,13 +122,16 @@ def open_outcome_file(outcome_file: str) -> typing.TextIO: else: return open(outcome_file, 'rt', encoding='utf-8') -def read_outcome_file(outcome_file: str) -> Outcomes: +MAKE_LIB_TARGET = re.compile(r'all\Z|lib\Z|library/') + +def read_outcome_file(results: Results, outcome_file: str) -> Outcomes: """Parse an outcome file and return an outcome collection. """ outcomes = {} + seen = {} #type: typing.Dict[str, int] with open_outcome_file(outcome_file) as input_file: for line in input_file: - (_platform, component, suite, case, result, _cause) = line.split(';') + (platform, component, suite, case, result, _cause) = line.split(';') # Note that `component` is not unique. If a test case passes on Linux # and fails on FreeBSD, it'll end up in both the successes set and # the failures set. @@ -139,6 +142,20 @@ def read_outcome_file(outcome_file: str) -> Outcomes: outcomes[component].successes.add(suite_case) elif result == 'FAIL': outcomes[component].failures.add(suite_case) + build_name = ';'.join([platform, component]) + # Detect repeated make invocations to build all or part of the + # library in the same configuration on the same platform. + # This generally indicates that MBEDTLS_TEST_CONFIGURATION was + # not set to a unique value. + if suite == 'make' and MAKE_LIB_TARGET.match(case): + seen.setdefault(build_name, 0) + seen[build_name] += 1 + + # Complain about repeated configurations + for build_name in sorted(seen.keys()): + if seen[build_name] > 1: + results.error('Repeated platform;configuration for library build: {}', + build_name, seen[build_name]) return outcomes @@ -380,7 +397,7 @@ def main(known_tasks: typing.Dict[str, typing.Type[Task]]) -> None: getattr(task_class, 'DRIVER'), options.outcomes) - outcomes = read_outcome_file(options.outcomes) + outcomes = read_outcome_file(main_results, options.outcomes) for task_name in tasks_list: task_constructor = known_tasks[task_name] From 6af71b8633849cc58470aa5997bed7c0462b14f9 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 31 Oct 2024 20:07:48 +0100 Subject: [PATCH 2/2] Improve reporting of repeated configurations Signed-off-by: Gilles Peskine --- scripts/mbedtls_framework/outcome_analysis.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mbedtls_framework/outcome_analysis.py b/scripts/mbedtls_framework/outcome_analysis.py index e911bc00b..cc6d90d19 100644 --- a/scripts/mbedtls_framework/outcome_analysis.py +++ b/scripts/mbedtls_framework/outcome_analysis.py @@ -152,10 +152,10 @@ def read_outcome_file(results: Results, outcome_file: str) -> Outcomes: seen[build_name] += 1 # Complain about repeated configurations - for build_name in sorted(seen.keys()): - if seen[build_name] > 1: - results.error('Repeated platform;configuration for library build: {}', - build_name, seen[build_name]) + for build_name in sorted(build_name for build_name in seen.keys() + if seen[build_name] > 1): + results.error('Repeated *{} platform;configuration for library build: {}', + seen[build_name], build_name) return outcomes