mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-10-07 09:17:23 +00:00
Prepare psa_test_cases to mix manual and automatic dependencies
No change to the generated files. Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -12,6 +12,7 @@ from typing import Callable, Dict, Iterator, List, Optional #pylint: disable=unu
|
|||||||
|
|
||||||
from . import crypto_knowledge
|
from . import crypto_knowledge
|
||||||
from . import psa_information
|
from . import psa_information
|
||||||
|
from . import psa_test_case
|
||||||
from . import test_case
|
from . import test_case
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ class HashPSALowLevel:
|
|||||||
function: str, note: str,
|
function: str, note: str,
|
||||||
arguments: List[str]) -> test_case.TestCase:
|
arguments: List[str]) -> test_case.TestCase:
|
||||||
"""Construct one test case involving a hash."""
|
"""Construct one test case involving a hash."""
|
||||||
tc = test_case.TestCase()
|
tc = psa_test_case.TestCase()
|
||||||
tc.set_description('{}{} {}'
|
tc.set_description('{}{} {}'
|
||||||
.format(function,
|
.format(function,
|
||||||
' ' + note if note else '',
|
' ' + note if note else '',
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from typing import List, Set
|
||||||
|
|
||||||
from . import test_case
|
from . import test_case
|
||||||
|
|
||||||
|
|
||||||
@@ -18,3 +20,28 @@ class TestCase(test_case.TestCase):
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
del self.dependencies
|
||||||
|
self.manual_dependencies = [] #type: List[str]
|
||||||
|
self.automatic_dependencies = set() #type: Set[str]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def infer_dependencies(_arguments: List[str]) -> List[str]:
|
||||||
|
"""Infer dependencies based on the test case arguments."""
|
||||||
|
return [] # not implemented yet
|
||||||
|
|
||||||
|
def set_arguments(self, arguments: List[str]) -> None:
|
||||||
|
"""Set test case arguments and automatically infer dependencies."""
|
||||||
|
super().set_arguments(arguments)
|
||||||
|
self.automatic_dependencies.update(self.infer_dependencies(arguments))
|
||||||
|
|
||||||
|
def set_dependencies(self, dependencies: List[str]) -> None:
|
||||||
|
"""Override any previously added automatic or manual dependencies."""
|
||||||
|
self.manual_dependencies = dependencies
|
||||||
|
self.automatic_dependencies.clear()
|
||||||
|
|
||||||
|
def add_dependencies(self, dependencies: List[str]) -> None:
|
||||||
|
"""Add manual dependencies."""
|
||||||
|
self.manual_dependencies += dependencies
|
||||||
|
|
||||||
|
def get_dependencies(self) -> List[str]:
|
||||||
|
return sorted(self.automatic_dependencies) + self.manual_dependencies
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ class TestCase:
|
|||||||
def set_description(self, description: str) -> None:
|
def set_description(self, description: str) -> None:
|
||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
|
def get_dependencies(self) -> List[str]:
|
||||||
|
return self.dependencies
|
||||||
|
|
||||||
def set_dependencies(self, dependencies: List[str]) -> None:
|
def set_dependencies(self, dependencies: List[str]) -> None:
|
||||||
self.dependencies = dependencies
|
self.dependencies = dependencies
|
||||||
|
|
||||||
@@ -117,9 +120,10 @@ class TestCase:
|
|||||||
for reason in self.skip_reasons:
|
for reason in self.skip_reasons:
|
||||||
out.write('## # skipped because: ' + reason + '\n')
|
out.write('## # skipped because: ' + reason + '\n')
|
||||||
out.write(prefix + self.description + '\n')
|
out.write(prefix + self.description + '\n')
|
||||||
if self.dependencies:
|
dependencies = self.get_dependencies()
|
||||||
|
if dependencies:
|
||||||
out.write(prefix + 'depends_on:' +
|
out.write(prefix + 'depends_on:' +
|
||||||
':'.join(self.dependencies) + '\n')
|
':'.join(dependencies) + '\n')
|
||||||
out.write(prefix + self.function + ':' +
|
out.write(prefix + self.function + ':' +
|
||||||
':'.join(self.arguments) + '\n')
|
':'.join(self.arguments) + '\n')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user