Add flag for unique combinations in operations

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
This commit is contained in:
Werner Lewis 2022-10-04 10:07:13 +01:00
parent 6351c7f5f3
commit bbf0a32d67
2 changed files with 13 additions and 1 deletions

View file

@ -77,10 +77,14 @@ class OperationCommon:
combined to produce pairs of values. combined to produce pairs of values.
input_cases: List of tuples containing pairs of test case inputs. This input_cases: List of tuples containing pairs of test case inputs. This
can be used to implement specific pairs of inputs. can be used to implement specific pairs of inputs.
unique_combinations_only: Boolean to select if test case combinations
must be unique. If True, only A,B or B,A would be included as a test
case. If False, both A,B and B,A would be included.
""" """
symbol = "" symbol = ""
input_values = [] # type: List[str] input_values = [] # type: List[str]
input_cases = [] # type: List[Tuple[str, str]] input_cases = [] # type: List[Tuple[str, str]]
unique_combinations_only = True
def __init__(self, val_a: str, val_b: str) -> None: def __init__(self, val_a: str, val_b: str) -> None:
self.arg_a = val_a self.arg_a = val_a
@ -107,5 +111,12 @@ class OperationCommon:
Combinations are first generated from all input values, and then Combinations are first generated from all input values, and then
specific cases provided. specific cases provided.
""" """
yield from combination_pairs(cls.input_values) if cls.unique_combinations_only:
yield from combination_pairs(cls.input_values)
else:
yield from (
(a, b)
for a in cls.input_values
for b in cls.input_values
)
yield from cls.input_cases yield from cls.input_cases

View file

@ -97,6 +97,7 @@ class BignumCoreSub(BignumCoreOperation):
symbol = "-" symbol = "-"
test_function = "mpi_core_sub" test_function = "mpi_core_sub"
test_name = "mbedtls_mpi_core_sub" test_name = "mbedtls_mpi_core_sub"
unique_combinations_only = False
def result(self) -> str: def result(self) -> str:
if self.int_a >= self.int_b: if self.int_a >= self.int_b: