1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-06-25 12:41:56 +03:00
Commit Graph

39 Commits

Author SHA1 Message Date
83763ab6b1 Pacify pylint
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
92c5d31b44 Add negative zero as an input to automatically generated tests
Although negative zero is officially unsupported, we've had bugs related to
it in the past. So do test functions with a negative zero input.

There will likely be cases where we don't want to accept negative zero as if
it was valid, because it's too hard to handle. We'll add exceptions on a
case by case basis.

For the functions that are currently tested by the generated tests, the new
test cases pass.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
ee78b6e642 For binary operations, test both x op y and y op x
This exposes a bug in mbedtls_mpi_add_mpi() and mbedtls_mpi_sub_mpi() which
will be fixed in a subsequent commit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
5b68608b40 Rename test_suite_bignum for consistency with bignum.{h,c}
Align the name of the bignum test suite with the source module (which was
renamed from mpi.c to bignum.c in the PolarSSL 1.x days). This also brings
it into line with the test suites for the low-level bignum interfaces.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-09 21:00:28 +01:00
ca980c037f Move implementation detail from docstring to comment
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-14 15:34:06 +02:00
69feebd178 More precise name for test data generation
We have Python code both for test code generation
(tests/scripts/generate_test_code.py) and now for test data generation.
Avoid the ambiguous expression "test generation".

This commit renames the Python module and adjusts all references to it. A
subsequent commit will adjust the documentation.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-14 15:24:30 +02:00
4ed94a4f7e Use a script specific description in CLI help
Previous changes used the docstring of the test_generation module,
which does not inform a user about the script.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:09:23 +01:00
64334d96d0 Update references to file targets in docstrings
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:08:53 +01:00
38c2491ef4 Add combination_pairs helper function
Wrapper function for itertools.combinations_with_replacement, with
explicit cast due to imprecise typing with older versions of mypy.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:08:53 +01:00
1965d48cad Use typing.cast instead of unqualified cast
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:08:53 +01:00
8b2d14bbd7 Replace L/R inputs with A/B
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:07:42 +01:00
46c09a66de Move symbol definition out of __init__
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:07:42 +01:00
3edcee72c4 Use simpler int to hex string conversion
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:07:42 +01:00
e53be35c09 Remove unused imports
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:07:42 +01:00
0d07e86a44 Rework TestGenerator to add file targets
BaseTarget-derived targets are now added to TestGenerator.targets in
initialization. This reduces repeated code in generate_xxx_tests.py
scripts which use this framework.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 17:07:37 +01:00
18f94d8175 Use combinations_with_replacement for inputs
When generating combinations of values, `itertools.combinations` will
not allow inputs to be repeated. This is replaced so that cases where
input values match are generated, i.e. ("0", "0").

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:49:13 +01:00
2b0f7d8d56 Modify wording in docstrings
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:49:13 +01:00
b03420fb3b Clarify documentation
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:47:33 +01:00
b29f59f5ff Disable abstract check in pylint
Version of pylint used in CI does not recognize abstract subclasses of
BaseTarget, so disable warning in these abstract classes.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
412c497cbe Fix TARGET types and code style
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
d77d33defb Raise NotImplementedError in abstract methods
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
478a4ce1fe Use typing casts for fixed-width tuples
Enforces fixed-width tuple types where mypy does not recognize.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
9509f44d79 Add missing typing
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
cace1aa02e Use __new__() for case counting
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
c34d037fa0 Split generate_tests to reduce code complexity
Previous implementation mixed the test case generation and the
recursive generation calls together. A separate method is added to
generate test cases for the current class' test function. This reduces
the need to override generate_tests().

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
47e37b3b75 Use ABCMeta for abstract classes
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
008d90d424 Add details to docstrings
Clarification is added to docstrings, mostly in abstract classes.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
1c2a732203 Convert bools to int before arithmetic
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
02998c470a Remove unneeded list concatenation
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
70d3f3dcdc Remove abbreviations and clarify attributes
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
dcad1e93fe Separate common test generation classes/functions
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:46:39 +01:00
92bb1cd8cb Fix incorrect indentation
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00
f0910ae380 Remove is None from if statement
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00
d76c5edc8e Fix type issues
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00
1bdee226e3 Remove set() to preserve test case order
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00
1c413bda51 Sort tests when generating cases
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00
5c1173bc1b Add test case generation for bignum add
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00
423f99bcef Add test generation for bignum cmp variant
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00
545911f751 Add bignum test generation framework
Adds python script for generation of bignum test cases, with initial
classes for mpi_cmp_mpi test cases. Build scripts are updated to
generate test data.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-21 16:29:49 +01:00