Bignum tests: complete support for unary operators

There are no intended changes to generated tests. (The ordering of tests
in the mod_raw module has changed.)

Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
Janos Follath 2022-11-19 14:55:43 +00:00
parent 435b305a49
commit 284672ccfb
2 changed files with 81 additions and 87 deletions

View file

@ -193,6 +193,9 @@ class OperationCommon(test_data_generation.BaseTest):
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.
""" """
if cls.arity == 1:
yield from ((a, "0") for a in cls.input_values)
elif cls.arity == 2:
if cls.unique_combinations_only: if cls.unique_combinations_only:
yield from combination_pairs(cls.input_values) yield from combination_pairs(cls.input_values)
else: else:
@ -201,6 +204,8 @@ class OperationCommon(test_data_generation.BaseTest):
for a in cls.input_values for a in cls.input_values
for b in cls.input_values for b in cls.input_values
) )
else:
raise ValueError("Unsupported number of operands!")
@classmethod @classmethod
def generate_function_tests(cls) -> Iterator[test_case.TestCase]: def generate_function_tests(cls) -> Iterator[test_case.TestCase]:

View file

@ -14,9 +14,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from typing import Dict, Iterator, List from typing import Dict, List
from . import test_case
from . import test_data_generation from . import test_data_generation
from . import bignum_common from . import bignum_common
@ -59,7 +58,7 @@ class BignumModRawConvertToMont(bignum_common.ModOperationCommon,
input_style = "arch_split" input_style = "arch_split"
arity = 1 arity = 1
test_data_moduli = ["b", moduli = ["b",
"fd", "fd",
"eeff99aa37", "eeff99aa37",
"eeff99aa11", "eeff99aa11",
@ -84,7 +83,7 @@ class BignumModRawConvertToMont(bignum_common.ModOperationCommon,
"b8896f33bb12e6ef73f12ec5c5ea7a8a337" "b8896f33bb12e6ef73f12ec5c5ea7a8a337"
] ]
test_input_numbers = ["0", input_values = ["0",
"1", "1",
"97", "97",
"f5", "f5",
@ -121,16 +120,6 @@ class BignumModRawConvertToMont(bignum_common.ModOperationCommon,
self.int_n, self.int_n,
self.int_a) self.int_a)
@classmethod
def generate_function_tests(cls) -> Iterator[test_case.TestCase]:
for bil in [32, 64]:
for n in cls.test_data_moduli:
for i in cls.test_input_numbers:
# Skip invalid combinations where A.limbs > N.limbs
if bignum_common.hex_to_int(i) > bignum_common.hex_to_int(n):
continue
yield cls(n, i, bits_in_limb=bil).create_test_case()
class BignumModRawConvertFromMont(BignumModRawConvertToMont): class BignumModRawConvertFromMont(BignumModRawConvertToMont):
""" Test cases for mpi_mod_raw_from_mont_rep(). """ """ Test cases for mpi_mod_raw_from_mont_rep(). """
@ -138,7 +127,7 @@ class BignumModRawConvertFromMont(BignumModRawConvertToMont):
test_function = "mpi_mod_raw_from_mont_rep" test_function = "mpi_mod_raw_from_mont_rep"
test_name = "Convert from Mont: " test_name = "Convert from Mont: "
test_input_numbers = ["0", input_values = ["0",
"1", "1",
"3ca", "3ca",
"539ed428", "539ed428",