summaryrefslogtreecommitdiffstats
path: root/test/ecstresstest.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2017-07-18 11:48:27 +1000
committerPauli <paul.dale@oracle.com>2017-07-27 07:53:08 +1000
commitad887416f1e59c3294a7d8f83a0ca77120523b4a (patch)
tree99971c4acaaa7a43efa38a0d52e230c0e68a1c6c /test/ecstresstest.c
parentd445302418b41b76c15e103954b1311d98077480 (diff)
Update the test framework so that the need for test_main is removed. Everything
that needed test_main now works using the same infrastructure as tests that used register_tests. This meant: * renaming register_tests to setup_tests and giving it a success/failure return. * renaming the init_test function to setup_test_framework. * renaming the finish_test function to pulldown_test_framework. * adding a user provided global_init function that runs before the test frame work is initialised. It returns a failure indication that stops the stest. * adding helper functions that permit tests to access their command line args. * spliting the BIO initialisation and finalisation out from the test setup and teardown. * hiding some of the now test internal functions. * fix the comments in testutil.h Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3953)
Diffstat (limited to 'test/ecstresstest.c')
-rw-r--r--test/ecstresstest.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/test/ecstresstest.c b/test/ecstresstest.c
index 5ea8f8477e..1cdb12b228 100644
--- a/test/ecstresstest.c
+++ b/test/ecstresstest.c
@@ -123,39 +123,28 @@ static int atoi64(const char *in, int64_t *result)
* |num| times and prints the resulting X-coordinate. Otherwise runs the test
* the default number of times and compares against the expected result.
*/
-int test_main(int argc, char *argv[])
+int setup_tests(void)
{
- const char *argv0 = argv[0];
+ const char *p;
if (!atoi64(NUM_REPEATS, &num_repeats)) {
TEST_error("Cannot parse " NUM_REPEATS);
- return EXIT_FAILURE;
+ return 0;
}
/*
* TODO(openssl-team): code under test/ should be able to reuse the option
* parsing framework currently in apps/.
*/
- argc--;
- argv++;
- while (argc >= 1) {
- if (strcmp(*argv, "-num") == 0) {
- if (--argc < 1
- || !atoi64(*++argv, &num_repeats)
- || num_repeats < 0) {
- TEST_error("Bad -num argument\n");
- return EXIT_FAILURE;
- }
- print_mode = 1;
- } else {
- TEST_error("Unknown option %s\n", *argv);
- return EXIT_FAILURE;
- }
- argc--;
- argv++;
+ p = test_get_option_argument("-num");
+ if (p != NULL) {
+ if (!atoi64(p, &num_repeats)
+ || num_repeats < 0)
+ return 0;
+ print_mode = 1;
}
#ifndef OPENSSL_NO_EC
ADD_TEST(test_curve);
#endif
- return run_tests(argv0);
+ return 1;
}