mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 03:35:35 +00:00
analyze_outcomes.py: remove components and ignore parameters
Use a dictionary to specify optional parameters for each task. If the task is not specified then all tasks are executed. Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
ab0451bc2c
commit
4d13c833da
@ -122,14 +122,18 @@ by a semicolon.
|
|||||||
outcomes[key].failures.append(setup)
|
outcomes[key].failures.append(setup)
|
||||||
return outcomes
|
return outcomes
|
||||||
|
|
||||||
def do_analyze_coverage(outcome_file):
|
def do_analyze_coverage(outcome_file, args):
|
||||||
"""Perform coverage analyze."""
|
"""Perform coverage analyze."""
|
||||||
|
del args # unused
|
||||||
outcomes = read_outcome_file(outcome_file)
|
outcomes = read_outcome_file(outcome_file)
|
||||||
results = analyze_outcomes(outcomes)
|
results = analyze_outcomes(outcomes)
|
||||||
return results.error_count == 0
|
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."""
|
"""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)
|
# 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]):
|
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). ')
|
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)
|
outcomes = read_outcome_file(outcome_file)
|
||||||
return analyze_driver_vs_reference(outcomes, components, ignored_tests)
|
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():
|
def main():
|
||||||
try:
|
try:
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
parser.add_argument('outcomes', metavar='OUTCOMES.CSV',
|
parser.add_argument('outcomes', metavar='OUTCOMES.CSV',
|
||||||
help='Outcome file to analyze')
|
help='Outcome file to analyze')
|
||||||
parser.add_argument('--task', default='analyze_coverage',
|
parser.add_argument('--task', default='all',
|
||||||
help='Analyze to be done: analyze_coverage or '
|
help='Analyze to be done: all or analyze_coverage or '
|
||||||
'analyze_driver_vs_reference')
|
'analyze_driver_vs_reference_hash')
|
||||||
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.')
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
result = False
|
result = True
|
||||||
|
|
||||||
if options.task == 'analyze_coverage':
|
if options.task == 'all':
|
||||||
result = do_analyze_coverage(options.outcomes)
|
for task in TASKS:
|
||||||
elif options.task == 'analyze_driver_vs_reference':
|
if not TASKS[task]['test_function'](options.outcomes, TASKS[task]['args']):
|
||||||
components_list = options.components.split(',')
|
result = False
|
||||||
ignored_tests_list = options.ignore.split(',')
|
elif options.task in TASKS:
|
||||||
ignored_tests_list = ['test_suite_' + x for x in ignored_tests_list]
|
if not TASKS[options.task]['test_function'](options.outcomes,
|
||||||
result = do_analyze_driver_vs_reference(options.outcomes,
|
TASKS[options.task]['args']):
|
||||||
components_list, ignored_tests_list)
|
result = False
|
||||||
else:
|
else:
|
||||||
print('Error: Unknown task: {}'.format(options.task))
|
print('Error: Unknown task: {}'.format(options.task))
|
||||||
|
result = False
|
||||||
|
|
||||||
if result is False:
|
if result is False:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user