From 6ee7253df22ed9e04f90163374f4cf778ef8e8c0 Mon Sep 17 00:00:00 2001 From: gabor-mezei-arm Date: Thu, 24 Jun 2021 09:42:02 +0200 Subject: [PATCH] Extend description generation Add an extra optional parameter to generate a more detailed description for test cases. Signed-off-by: gabor-mezei-arm --- tests/scripts/generate_psa_tests.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 793bc34dc..39438d105 100644 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -340,13 +340,15 @@ class StorageFormat: def key_for_usage_flags( self, usage_flags: List[str], - short: Optional[str] = None + short: Optional[str] = None, + extra_desc: Optional[str] = None ) -> StorageKey: """Construct a test key for the given key usage.""" usage = ' | '.join(usage_flags) if usage_flags else '0' if short is None: short = re.sub(r'\bPSA_KEY_USAGE_', r'', usage) - description = 'usage: ' + short + extra_desc = ' ' + extra_desc if extra_desc is not None and len(extra_desc) > 0 else '' + description = 'usage' + extra_desc + ': ' + short return self.key_builder.build(version=self.version, id=1, lifetime=0x00000001, type='PSA_KEY_TYPE_RAW_DATA', bits=8, @@ -354,14 +356,17 @@ class StorageFormat: material=b'K', description=description) - def all_keys_for_usage_flags(self) -> List[StorageKey]: + def all_keys_for_usage_flags( + self, + extra_desc: Optional[str] = None + ) -> List[StorageKey]: """Generate test keys covering usage flags.""" known_flags = sorted(self.constructors.key_usage_flags) keys = [] #type List[StorageKey] - keys.append(self.key_for_usage_flags(['0'])) - keys += [self.key_for_usage_flags([usage_flag]) + keys.append(self.key_for_usage_flags(['0'], extra_desc=extra_desc)) + keys += [self.key_for_usage_flags([usage_flag], extra_desc=extra_desc) for usage_flag in known_flags] - keys += [self.key_for_usage_flags([flag1, flag2]) + keys += [self.key_for_usage_flags([flag1, flag2], extra_desc=extra_desc) for flag1, flag2 in zip(known_flags, known_flags[1:] + [known_flags[0]])] keys.append(self.key_for_usage_flags(known_flags, short='all known'))