blob: 73434d970df3ba1bad0e291a1de393bbee919fe6 [file] [log] [blame]
Gabor Mezei308132f2023-01-16 16:53:29 +01001#!/usr/bin/env python3
2"""Generate test data for ecp functions.
3
4With no arguments, generate all test data. With non-option arguments,
5generate only the specified files.
6
7Class structure:
8
9Child classes of test_data_generation.BaseTarget (file targets) represent an output
10file. These indicate where test cases will be written to, for all subclasses of
11this target. Multiple file targets should not reuse a `target_basename`.
12
13Each subclass derived from a file target can either be:
14 - A concrete class, representing a test function, which generates test cases.
15 - An abstract class containing shared methods and attributes, not associated
16 with a test function.
17
18Both concrete and abstract subclasses can be derived from, to implement
19additional test cases (see BignumCmp and BignumCmpAbs for examples of deriving
20from abstract and concrete classes).
21
22
23Adding test case generation for a function:
24
25A subclass representing the test function should be added, deriving from a
26file target such as BignumTarget. This test class must set/implement the
27following:
28 - test_function: the function name from the associated .function file.
29 - test_name: a descriptive name or brief summary to refer to the test
30 function.
31 - arguments(): a method to generate the list of arguments required for the
32 test_function.
33 - generate_function_tests(): a method to generate TestCases for the function.
34 This should create instances of the class with required input data, and
35 call `.create_test_case()` to yield the TestCase.
36
37Additional details and other attributes/methods are given in the documentation
38of BaseTarget in test_data_generation.py.
39"""
40
41# Copyright The Mbed TLS Contributors
42# SPDX-License-Identifier: Apache-2.0
43#
44# Licensed under the Apache License, Version 2.0 (the "License"); you may
45# not use this file except in compliance with the License.
46# You may obtain a copy of the License at
47#
48# http://www.apache.org/licenses/LICENSE-2.0
49#
50# Unless required by applicable law or agreed to in writing, software
51# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
52# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53# See the License for the specific language governing permissions and
54# limitations under the License.
55
56import sys
57
58import scripts_path # pylint: disable=unused-import
59from mbedtls_dev import test_data_generation
Gabor Mezei7e14c662023-01-18 10:56:13 +010060
Gabor Mezei308132f2023-01-16 16:53:29 +010061# Import modules containing additional test classes
62# Test function classes in these modules will be registered by
63# the framework
64from mbedtls_dev import ecp # pylint: disable=unused-import
65
66if __name__ == '__main__':
67 # Use the section of the docstring relevant to the CLI as description
68 test_data_generation.main(sys.argv[1:], "\n".join(__doc__.splitlines()[:4]))