diff --git a/tests/scripts/analyze_outcomes.py b/tests/scripts/analyze_outcomes.py index 3e95997305..de52d776b4 100755 --- a/tests/scripts/analyze_outcomes.py +++ b/tests/scripts/analyze_outcomes.py @@ -122,14 +122,18 @@ by a semicolon. outcomes[key].failures.append(setup) return outcomes -def do_analyze_coverage(outcome_file): +def do_analyze_coverage(outcome_file, args): """Perform coverage analyze.""" + del args # unused outcomes = read_outcome_file(outcome_file) results = analyze_outcomes(outcomes) return results.error_count == 0 -def do_analyze_driver_vs_reference(outcome_file, components, ignored_tests): +def do_analyze_driver_vs_reference(outcome_file, args): """Perform driver vs reference analyze.""" + components = args['components'].split(',') + ignored_tests = args['ignored'].split(',') + ignored_tests = ['test_suite_' + x for x in ignored_tests] # We need exactly 2 components to analyze (first driver and second reference) if(len(components) != 2 or "accel" not in components[0] or "reference" not in components[1]): print('Error: Wrong component list. Exactly 2 components are required (driver,reference). ') @@ -137,35 +141,43 @@ def do_analyze_driver_vs_reference(outcome_file, components, ignored_tests): outcomes = read_outcome_file(outcome_file) return analyze_driver_vs_reference(outcomes, components, ignored_tests) +# List of tasks with function that can handle this task and additional arguments if required +# pylint: disable=line-too-long +TASKS = { + 'analyze_coverage': { + 'test_function': do_analyze_coverage, + 'args': {}}, + 'analyze_driver_vs_reference_hash': { + 'test_function': do_analyze_driver_vs_reference, + 'args': { + 'components': 'test_psa_crypto_config_accel_hash_use_psa,test_psa_crypto_config_reference_hash_use_psa', + 'ignored': 'md,mdx,shax,entropy,hmac_drbg,random,psa_crypto_init,hkdf'}} +} +# pylint: enable=line-too-long + def main(): try: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('outcomes', metavar='OUTCOMES.CSV', help='Outcome file to analyze') - parser.add_argument('--task', default='analyze_coverage', - help='Analyze to be done: analyze_coverage or ' - 'analyze_driver_vs_reference') - parser.add_argument('--components', - help='List of test components to compare. ' - 'Must be exactly 2 in valid order: driver,reference. ' - 'Apply only for analyze_driver_vs_reference task.') - parser.add_argument('--ignore', - help='List of test suits to ignore. ' - 'Apply only for analyze_driver_vs_reference task.') + parser.add_argument('--task', default='all', + help='Analyze to be done: all or analyze_coverage or ' + 'analyze_driver_vs_reference_hash') options = parser.parse_args() - result = False + result = True - if options.task == 'analyze_coverage': - result = do_analyze_coverage(options.outcomes) - elif options.task == 'analyze_driver_vs_reference': - components_list = options.components.split(',') - ignored_tests_list = options.ignore.split(',') - ignored_tests_list = ['test_suite_' + x for x in ignored_tests_list] - result = do_analyze_driver_vs_reference(options.outcomes, - components_list, ignored_tests_list) + if options.task == 'all': + for task in TASKS: + if not TASKS[task]['test_function'](options.outcomes, TASKS[task]['args']): + result = False + elif options.task in TASKS: + if not TASKS[options.task]['test_function'](options.outcomes, + TASKS[options.task]['args']): + result = False else: print('Error: Unknown task: {}'.format(options.task)) + result = False if result is False: sys.exit(1)