mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Bignum tests: add support for filtering
Sometimes we don't want all possible combinations of the input data and sometimes not all combinations make sense. We are adding a convenient way to decide on a case by case basis. Now child classes only need to implement the is_valid method and the invalid cases will be filtered out automatically. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
@ -172,6 +172,10 @@ class OperationCommon(test_data_generation.BaseTest):
|
|||||||
)
|
)
|
||||||
return super().description()
|
return super().description()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_valid(self) -> bool:
|
||||||
|
return True
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def result(self) -> List[str]:
|
def result(self) -> List[str]:
|
||||||
"""Get the result of the operation.
|
"""Get the result of the operation.
|
||||||
@ -204,13 +208,18 @@ class OperationCommon(test_data_generation.BaseTest):
|
|||||||
raise ValueError("Unknown input style!")
|
raise ValueError("Unknown input style!")
|
||||||
if cls.arity not in cls.arities:
|
if cls.arity not in cls.arities:
|
||||||
raise ValueError("Unsupported number of operands!")
|
raise ValueError("Unsupported number of operands!")
|
||||||
for a_value, b_value in cls.get_value_pairs():
|
|
||||||
if cls.input_style == "arch_split":
|
if cls.input_style == "arch_split":
|
||||||
for bil in cls.limb_sizes:
|
test_objects = (cls(a_value, b_value, bits_in_limb=bil)
|
||||||
yield cls(a_value, b_value,
|
for a_value, b_value in cls.get_value_pairs()
|
||||||
bits_in_limb=bil).create_test_case()
|
for bil in cls.limb_sizes)
|
||||||
else:
|
else:
|
||||||
yield cls(a_value, b_value).create_test_case()
|
test_objects = (cls(a_value, b_value) for
|
||||||
|
a_value, b_value in cls.get_value_pairs())
|
||||||
|
yield from (valid_test_object.create_test_case()
|
||||||
|
for valid_test_object in filter(
|
||||||
|
lambda test_object: test_object.is_valid,
|
||||||
|
test_objects
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
class ModOperationCommon(OperationCommon):
|
class ModOperationCommon(OperationCommon):
|
||||||
|
Reference in New Issue
Block a user