From 20987b9a469284db74277bb8adaea7311edf1bd6 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 12 Jan 2021 01:11:32 +0100 Subject: [PATCH] Detect test cases that require something not to be supported PSA_xxx_CATEGORY_yyy is used in metadata tests where it doesn't involve any particular support, and elsewhere it's used as a value that is definitely not supported but is in a plausible range. Such symbols do not require any dependency. If a test case is expects PSA_ERROR_NOT_SUPPORTED, its dependencies (often including one negative dependency) cannot be determined automatically, so leave that test case alone. Signed-off-by: Gilles Peskine --- tests/scripts/set_psa_test_dependencies.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/scripts/set_psa_test_dependencies.py b/tests/scripts/set_psa_test_dependencies.py index 7f913cdd1..3882a9b0d 100755 --- a/tests/scripts/set_psa_test_dependencies.py +++ b/tests/scripts/set_psa_test_dependencies.py @@ -149,6 +149,11 @@ def dependencies_of_symbol(symbol): return frozenset() if symbol in SPECIAL_SYSTEMATIC_DEPENDENCIES: return SPECIAL_SYSTEMATIC_DEPENDENCIES[symbol] + if symbol.startswith('PSA_ALG_CATEGORY_') or \ + symbol.startswith('PSA_KEY_TYPE_CATEGORY_'): + # Categories are used in test data when an unsupported but plausible + # mechanism number needed. They have no associated dependency. + return frozenset() return {symbol.replace('_', '_WANT_', 1)} def systematic_dependencies(file_name, function_name, arguments): @@ -178,6 +183,12 @@ def updated_dependencies(file_name, function_name, arguments, dependencies): def keep_manual_dependencies(file_name, function_name, arguments): #pylint: disable=unused-argument """Declare test functions with unusual dependencies here.""" + # When PSA_ERROR_NOT_SUPPORTED is expected, usually, at least one of the + # constants mentioned in the test should not be supported. It isn't + # possible to determine which one in a systematic way. So let the programmer + # decide. + if arguments[-1] == 'PSA_ERROR_NOT_SUPPORTED': + return True return False def process_data_stanza(stanza, file_name, test_case_number):