Skip to content

Commit 8c488b1

Browse files
Merge pull request #41 from gabor-mezei-arm/9325_move_config.py_to_framework
Move `config.py` functionalities to the framework
2 parents 8ae1250 + 86ae2a7 commit 8c488b1

File tree

2 files changed

+442
-14
lines changed

2 files changed

+442
-14
lines changed

scripts/generate_config_tests.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
# Copyright The Mbed TLS Contributors
66
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
77

8-
import abc
98
import re
109
import sys
1110
from typing import Iterable, Iterator, List, Optional, Tuple
1211

1312
import project_scripts # pylint: disable=unused-import
1413
import config
14+
from mbedtls_framework import config_common
1515
from mbedtls_framework import test_case
1616
from mbedtls_framework import test_data_generation
1717

1818

19-
def single_setting_case(setting: config.Setting, when_on: bool,
19+
def single_setting_case(setting: config_common.Setting, when_on: bool,
2020
dependencies: List[str],
2121
note: Optional[str]) -> test_case.TestCase:
2222
"""Construct a test case for a boolean setting.
@@ -64,8 +64,8 @@ def single_setting_case(setting: config.Setting, when_on: bool,
6464
'MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS': 'MBEDTLS_PSA_CRYPTO_C',
6565
}
6666

67-
def dependencies_of_setting(cfg: config.Config,
68-
setting: config.Setting) -> Optional[str]:
67+
def dependencies_of_setting(cfg: config_common.Config,
68+
setting: config_common.Setting) -> Optional[str]:
6969
"""Return dependencies without which a setting is not meaningful.
7070
7171
The dependencies of a setting express when a setting can be enabled and
@@ -112,8 +112,8 @@ def dependencies_of_setting(cfg: config.Config,
112112
return m.group('prefix') + 'BASIC'
113113
return None
114114

115-
def conditions_for_setting(cfg: config.Config,
116-
setting: config.Setting
115+
def conditions_for_setting(cfg: config_common.Config,
116+
setting: config_common.Setting
117117
) -> Iterator[Tuple[List[str], str]]:
118118
"""Enumerate the conditions under which to test the given setting.
119119
@@ -142,7 +142,7 @@ def conditions_for_setting(cfg: config.Config,
142142
yield [], ''
143143

144144

145-
def enumerate_boolean_setting_cases(cfg: config.Config
145+
def enumerate_boolean_setting_cases(cfg: config_common.Config
146146
) -> Iterable[test_case.TestCase]:
147147
"""Emit test cases for all boolean settings."""
148148
for name in sorted(cfg.settings.keys()):
@@ -159,15 +159,10 @@ class ConfigTestGenerator(test_data_generation.TestGenerator):
159159
"""Generate test cases for configuration reporting."""
160160

161161
def __init__(self, settings):
162-
# Temporarily use different config classes for 3.6. With the config.py moving to
163-
# the framework it will be unified.
164-
is_3_6 = not isinstance(config.ConfigFile, abc.ABCMeta)
165-
# pylint: disable=no-value-for-parameter, no-member
166-
self.mbedtls_config = config.ConfigFile() if is_3_6 else config.MbedTLSConfig()
162+
self.mbedtls_config = config.MbedTLSConfig()
167163
self.targets['test_suite_config.mbedtls_boolean'] = \
168164
lambda: enumerate_boolean_setting_cases(self.mbedtls_config)
169-
self.psa_config = config.ConfigFile('include/psa/crypto_config.h') if is_3_6 else \
170-
config.CryptoConfig()
165+
self.psa_config = config.CryptoConfig()
171166
self.targets['test_suite_config.psa_boolean'] = \
172167
lambda: enumerate_boolean_setting_cases(self.psa_config)
173168
super().__init__(settings)

0 commit comments

Comments
 (0)