mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-01 09:41:40 +03:00
Terminology: use "dependencies" for a list of settings
"Super settings" were effectively the dependencies of a setting, so align on that terminology. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -44,12 +44,12 @@ PSA_WANT_KEY_TYPE_KEY_PAIR_RE = \
|
|||||||
re.compile(r'(?P<prefix>PSA_WANT_KEY_TYPE_(?P<type>\w+)_KEY_PAIR_)(?P<operation>\w+)\Z')
|
re.compile(r'(?P<prefix>PSA_WANT_KEY_TYPE_(?P<type>\w+)_KEY_PAIR_)(?P<operation>\w+)\Z')
|
||||||
|
|
||||||
# If foo is a setting that is only meaningful when bar is enabled, set
|
# If foo is a setting that is only meaningful when bar is enabled, set
|
||||||
# SUPER_SETTINGS[foo]=bar. More generally, bar can be a colon-separated
|
# SIMPLE_DEPENDENCIES[foo]=bar. More generally, bar can be a colon-separated
|
||||||
# list of settings, meaning that all the settings must be enabled. Each setting
|
# list of settings, meaning that all the settings must be enabled. Each setting
|
||||||
# can be prefixed with '!' to negate it. This is the same syntax as a
|
# in bar can be prefixed with '!' to negate it. This is the same syntax as a
|
||||||
# depends_on directive in test data.
|
# depends_on directive in test data.
|
||||||
# See also `find_super_setting`.
|
# See also `dependencies_of_settting`.
|
||||||
SUPER_SETTINGS = {
|
SIMPLE_DEPENDENCIES = {
|
||||||
'MBEDTLS_AESCE_C': 'MBEDTLS_AES_C',
|
'MBEDTLS_AESCE_C': 'MBEDTLS_AES_C',
|
||||||
'MBEDTLS_AESNI_C': 'MBEDTLS_AES_C',
|
'MBEDTLS_AESNI_C': 'MBEDTLS_AES_C',
|
||||||
'MBEDTLS_ERROR_STRERROR_DUMMY': '!MBEDTLS_ERROR_C',
|
'MBEDTLS_ERROR_STRERROR_DUMMY': '!MBEDTLS_ERROR_C',
|
||||||
@ -63,19 +63,25 @@ SUPER_SETTINGS = {
|
|||||||
'MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS': 'MBEDTLS_PSA_CRYPTO_C',
|
'MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS': 'MBEDTLS_PSA_CRYPTO_C',
|
||||||
}
|
}
|
||||||
|
|
||||||
def find_super_setting(cfg: config.Config,
|
def dependencies_of_setting(cfg: config.Config,
|
||||||
setting: config.Setting) -> Optional[str]:
|
setting: config.Setting) -> Optional[str]:
|
||||||
"""If setting is only meaningful when some setting is enabled, return that setting.
|
"""Return dependencies without which a setting is not meaningful.
|
||||||
|
|
||||||
|
The dependencies of a setting express when a setting can be enabled and
|
||||||
|
is relevant. For example, if ``check_config.h`` errors out when
|
||||||
|
``defined(FOO) && !defined(BAR)``, then ``BAR`` is a dependency of ``FOO``.
|
||||||
|
If ``FOO`` has no effect when ``CORGE`` is disabled, then ``CORGE``
|
||||||
|
is a dependency of ``FOO``.
|
||||||
|
|
||||||
The return value can be a colon-separated list of settings, if the setting
|
The return value can be a colon-separated list of settings, if the setting
|
||||||
is only meaningful when all of these settings are enabled. Settings can be
|
is only meaningful when all of these settings are enabled. Each setting can
|
||||||
negated by prefixing them with '!'. This is the same syntax as a
|
be negated by prefixing them with '!'. This is the same syntax as a
|
||||||
depends_on directive in test data.
|
depends_on directive in test data.
|
||||||
"""
|
"""
|
||||||
#pylint: disable=too-many-return-statements
|
#pylint: disable=too-many-return-statements
|
||||||
name = setting.name
|
name = setting.name
|
||||||
if name in SUPER_SETTINGS:
|
if name in SIMPLE_DEPENDENCIES:
|
||||||
return SUPER_SETTINGS[name]
|
return SIMPLE_DEPENDENCIES[name]
|
||||||
if name.startswith('MBEDTLS_') and not name.endswith('_C'):
|
if name.startswith('MBEDTLS_') and not name.endswith('_C'):
|
||||||
if name.startswith('MBEDTLS_CIPHER_PADDING_'):
|
if name.startswith('MBEDTLS_CIPHER_PADDING_'):
|
||||||
return 'MBEDTLS_CIPHER_C:MBEDTLS_CIPHER_MODE_CBC'
|
return 'MBEDTLS_CIPHER_C:MBEDTLS_CIPHER_MODE_CBC'
|
||||||
@ -128,9 +134,9 @@ def conditions_for_setting(cfg: config.Config,
|
|||||||
if name.endswith('_ALT') and not config.is_seamless_alt(name):
|
if name.endswith('_ALT') and not config.is_seamless_alt(name):
|
||||||
# We don't test alt implementations, except (most) platform alts
|
# We don't test alt implementations, except (most) platform alts
|
||||||
return
|
return
|
||||||
super_setting = find_super_setting(cfg, setting)
|
dependencies = dependencies_of_setting(cfg, setting)
|
||||||
if super_setting:
|
if dependencies:
|
||||||
yield [super_setting], ''
|
yield [dependencies], ''
|
||||||
return
|
return
|
||||||
yield [], ''
|
yield [], ''
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user