From c231711dbc8ed339d37698afe66fce46931cdc18 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 21 Nov 2019 17:17:39 +0100 Subject: [PATCH] Move value collection into its own function No behavior change. --- tests/scripts/test_psa_constant_names.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/scripts/test_psa_constant_names.py b/tests/scripts/test_psa_constant_names.py index a43a3e888..53af0a524 100755 --- a/tests/scripts/test_psa_constant_names.py +++ b/tests/scripts/test_psa_constant_names.py @@ -324,6 +324,17 @@ def normalize(expr): """ return re.sub(NORMALIZE_STRIP_RE, '', expr) +def collect_values(options, inputs, type_word): + """Generate expressions using known macro names and calculate their values. + + Return a list of pairs of (expr, value) where expr is an expression and + value is a string representation of its integer value. + """ + names = inputs.get_names(type_word) + expressions = sorted(inputs.generate_expressions(names)) + values = run_c(options, type_word, expressions) + return expressions, values + def do_test(options, inputs, type_word): """Test psa_constant_names for the specified type. @@ -335,9 +346,7 @@ def do_test(options, inputs, type_word): that have been tested and ``errors`` is the list of errors that were encountered. """ - names = inputs.get_names(type_word) - expressions = sorted(inputs.generate_expressions(names)) - values = run_c(options, type_word, expressions) + expressions, values = collect_values(options, inputs, type_word) output = subprocess.check_output([options.program, type_word] + values) outputs = output.decode('ascii').strip().split('\n') errors = [(type_word, expr, value, output)