Enumerate metadata test functions explicitly

When gathering test cases from test_suite_psa_crypto_metadata, look up
the test function explicitly. This way test_psa_constant_names will
error out if we add a new test function that needs coverage here.

This change highlights an omission in the previous version:
asymmetric_signature_wildcard was silently ignored as a source of
algorithm expressions to test. Fix that.
This commit is contained in:
Gilles Peskine 2019-11-25 17:10:12 +01:00
parent d2cea9f57c
commit 8fa1348276

View file

@ -97,15 +97,22 @@ class Inputs:
} }
# Test functions # Test functions
self.table_by_test_function = { self.table_by_test_function = {
'key_type': self.key_types, # Any function ending in _algorithm also gets added to
'ecc_key_types': self.ecc_curves, # self.algorithms.
'dh_key_types': self.dh_groups, 'key_type': [self.key_types],
'hash_algorithm': self.hash_algorithms, 'ecc_key_types': [self.ecc_curves],
'mac_algorithm': self.mac_algorithms, 'dh_key_types': [self.dh_groups],
'hmac_algorithm': self.mac_algorithms, 'hash_algorithm': [self.hash_algorithms],
'aead_algorithm': self.aead_algorithms, 'mac_algorithm': [self.mac_algorithms],
'key_derivation_algorithm': self.kdf_algorithms, 'cipher_algorithm': [],
'key_agreement_algorithm': self.ka_algorithms, 'hmac_algorithm': [self.mac_algorithms],
'aead_algorithm': [self.aead_algorithms],
'key_derivation_algorithm': [self.kdf_algorithms],
'key_agreement_algorithm': [self.ka_algorithms],
'asymmetric_signature_algorithm': [],
'asymmetric_signature_wildcard': [self.algorithms],
'asymmetric_encryption_algorithm': [],
'other_algorithm': [],
} }
# macro name -> list of argument names # macro name -> list of argument names
self.argspecs = {} self.argspecs = {}
@ -253,8 +260,7 @@ class Inputs:
# exclude ones that are already chained with a KDF. # exclude ones that are already chained with a KDF.
# Keep the expression as one to test as an algorithm. # Keep the expression as one to test as an algorithm.
function = 'other_algorithm' function = 'other_algorithm'
if function in self.table_by_test_function: sets += self.table_by_test_function[function]
sets.append(self.table_by_test_function[function])
if self.accept_test_case_line(function, argument): if self.accept_test_case_line(function, argument):
for s in sets: for s in sets:
s.add(argument) s.add(argument)