From ae9f14b159fa8c109829c1f1731a29beba1e28ab Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 12 Apr 2021 14:43:05 +0200 Subject: [PATCH] Speed up the generation of storage format test cases First build a list of all keys, then construct all the corresponding test cases. This allows all required information to be obtained in one go, which is a significant performance gain as the information includes numerical values obtained by compiling a C program. Signed-off-by: Gilles Peskine --- tests/scripts/generate_psa_tests.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index aaaa5c33b..e7655f7b5 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -371,11 +371,15 @@ class StorageFormat: def all_test_cases(self) -> Iterator[test_case.TestCase]: """Generate all storage format test cases.""" - for key in self.all_keys_for_usage_flags(): - yield self.make_test_case(key) - for key in self.all_keys_for_types(): - yield self.make_test_case(key) - for key in self.all_keys_for_algorithms(): + # First build a list of all keys, then construct all the corresponding + # test cases. This allows all required information to be obtained in + # one go, which is a significant performance gain as the information + # includes numerical values obtained by compiling a C program. + keys = [] #type: List[StorageKey] + keys += self.all_keys_for_usage_flags() + keys += self.all_keys_for_types() + keys += self.all_keys_for_algorithms() + for key in keys: yield self.make_test_case(key) # To do: vary id, lifetime