diff options
author | Pauli <paul.dale@oracle.com> | 2017-07-18 11:48:27 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2017-07-27 07:53:08 +1000 |
commit | ad887416f1e59c3294a7d8f83a0ca77120523b4a (patch) | |
tree | 99971c4acaaa7a43efa38a0d52e230c0e68a1c6c /test/siphash_internal_test.c | |
parent | d445302418b41b76c15e103954b1311d98077480 (diff) | |
download | openssl-ad887416f1e59c3294a7d8f83a0ca77120523b4a.tar.gz |
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/siphash_internal_test.c')
-rw-r--r-- | test/siphash_internal_test.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/test/siphash_internal_test.c b/test/siphash_internal_test.c index 0114af18d0..ca24339ee7 100644 --- a/test/siphash_internal_test.c +++ b/test/siphash_internal_test.c @@ -319,11 +319,13 @@ static int test_siphash_basic(void) && TEST_true(SipHash_Final(&siphash, output, 16)); } -int test_main(int argc, char **argv) +int setup_tests(void) { - int result = 0; - int iter_argv; - int benchmark = 0; + if (test_has_option("-h")) { + BIO_printf(bio_out, "-h\tThis help\n"); + BIO_printf(bio_out, "-b\tBenchmark in addition to the tests\n"); + return 1; + } b_stderr = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); b_stdout = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT); @@ -332,28 +334,15 @@ int test_main(int argc, char **argv) b_stdout = BIO_push(BIO_new(BIO_f_linebuffer()), b_stdout); #endif - for (iter_argv = 1; iter_argv < argc; iter_argv++) { - if (strcmp(argv[iter_argv], "-b") == 0) - benchmark = 1; - else if (strcmp(argv[iter_argv], "-h") == 0) - goto help; - } - ADD_TEST(test_siphash_basic); ADD_ALL_TESTS(test_siphash, OSSL_NELEM(tests)); - if (benchmark) + if (test_has_option("-b")) ADD_TEST(benchmark_siphash); + return 1; +} - result = run_tests(argv[0]); - goto out; - - help: - BIO_printf(b_stdout, "-h\tThis help\n"); - BIO_printf(b_stdout, "-b\tBenchmark in addition to the tests\n"); - - out: +void cleanup_tests(void) +{ BIO_free(b_stdout); BIO_free(b_stderr); - - return result; } |