mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
generate_*_tests.py: simplify test_suite_directory handling
test_suite_directory can be changed by a command line option in the development branch but not in 2.28. Align the simplified version here with a change in the development version ("generate_*_tests.py --directory: fix handling of relative path"). Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -139,9 +139,8 @@ class BaseTarget(metaclass=ABCMeta):
|
|||||||
|
|
||||||
class TestGenerator:
|
class TestGenerator:
|
||||||
"""Generate test cases and write to data files."""
|
"""Generate test cases and write to data files."""
|
||||||
def __init__(self, options) -> None:
|
def __init__(self, _options) -> None:
|
||||||
self.test_suite_directory = self.get_option(options, 'directory',
|
self.test_suite_directory = 'tests/suites'
|
||||||
'tests/suites')
|
|
||||||
# Update `targets` with an entry for each child class of BaseTarget.
|
# Update `targets` with an entry for each child class of BaseTarget.
|
||||||
# Each entry represents a file generated by the BaseTarget framework,
|
# Each entry represents a file generated by the BaseTarget framework,
|
||||||
# and enables generating the .data files using the CLI.
|
# and enables generating the .data files using the CLI.
|
||||||
@ -150,11 +149,6 @@ class TestGenerator:
|
|||||||
for subclass in BaseTarget.__subclasses__()
|
for subclass in BaseTarget.__subclasses__()
|
||||||
})
|
})
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_option(options, name: str, default: T) -> T:
|
|
||||||
value = getattr(options, name, None)
|
|
||||||
return default if value is None else value
|
|
||||||
|
|
||||||
def filename_for(self, basename: str) -> str:
|
def filename_for(self, basename: str) -> str:
|
||||||
"""The location of the data file with the specified base name."""
|
"""The location of the data file with the specified base name."""
|
||||||
return posixpath.join(self.test_suite_directory, basename + '.data')
|
return posixpath.join(self.test_suite_directory, basename + '.data')
|
||||||
|
Reference in New Issue
Block a user