diff options
Diffstat (limited to 'test')
92 files changed, 604 insertions, 532 deletions
diff --git a/test/README b/test/README index bc96ff2aea..d8526806a8 100644 --- a/test/README +++ b/test/README @@ -123,9 +123,10 @@ Generic form of C test executables return testresult; } - void register_tests(void) + int setup_tests(void) { ADD_TEST(my_test); /* Add each test separately */ + return 1; /* Indicate success */ } You should use the TEST_xxx macros provided by testutil.h to test all failure diff --git a/test/afalgtest.c b/test/afalgtest.c index 40ea025405..62dcdb2277 100644 --- a/test/afalgtest.c +++ b/test/afalgtest.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -85,21 +85,20 @@ static int test_afalg_aes_128_cbc(void) } #endif -int main(int argc, char **argv) +#ifndef OPENSSL_NO_ENGINE +int global_init(void) { - int ret = 0; - -#ifdef OPENSSL_NO_ENGINE - setup_test(); - ret = run_tests(argv[0]); -#else ENGINE_load_builtin_engines(); # ifndef OPENSSL_NO_STATIC_ENGINE OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL); # endif + return 1; +} +#endif - setup_test(); - +int setup_tests(void) +{ +#ifndef OPENSSL_NO_ENGINE if ((e = ENGINE_by_id("afalg")) == NULL) { /* Probably a platform env issue, not a test failure. */ TEST_info("Can't load AFALG engine"); @@ -108,9 +107,14 @@ int main(int argc, char **argv) ADD_TEST(test_afalg_aes_128_cbc); # endif } - ret = run_tests(argv[0]); - ENGINE_free(e); #endif - return finish_test(ret); + return 1; } + +#ifndef OPENSSL_NO_ENGINE +void cleanup_tests(void) +{ + ENGINE_free(e); +} +#endif diff --git a/test/asn1_encode_test.c b/test/asn1_encode_test.c index 9b8cdcaf3a..b8ec168943 100644 --- a/test/asn1_encode_test.c +++ b/test/asn1_encode_test.c @@ -853,7 +853,7 @@ static int test_uint64(void) return test_intern(&uint64_test_package); } -void register_tests(void) +int setup_tests(void) { #if OPENSSL_API_COMPAT < 0x10200000L ADD_TEST(test_long_32bit); @@ -863,4 +863,5 @@ void register_tests(void) ADD_TEST(test_uint32); ADD_TEST(test_int64); ADD_TEST(test_uint64); + return 1; } diff --git a/test/asn1_internal_test.c b/test/asn1_internal_test.c index 38ef6100c1..194a073788 100644 --- a/test/asn1_internal_test.c +++ b/test/asn1_internal_test.c @@ -91,8 +91,9 @@ static int test_standard_methods() return 0; } -void register_tests(void) +int setup_tests(void) { ADD_TEST(test_tbl_standard); ADD_TEST(test_standard_methods); + return 1; } diff --git a/test/asynciotest.c b/test/asynciotest.c index ee450dafd3..aa6076ba01 100644 --- a/test/asynciotest.c +++ b/test/asynciotest.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL licenses, (the "License"); * you may not use this file except in compliance with the License. @@ -362,22 +362,17 @@ static int test_asyncio(int test) return testresult; } -int test_main(int argc, char *argv[]) +int setup_tests(void) { - int testresult = 0; - - if (!TEST_int_eq(argc, 3)) - goto end; - - cert = argv[1]; - privkey = argv[2]; + if (!TEST_ptr(cert = test_get_argument(0)) + || !TEST_ptr(privkey = test_get_argument(1))) + return 0; ADD_ALL_TESTS(test_asyncio, 2); + return 1; +} - testresult = run_tests(argv[0]); - - end: +void cleanup_tests(void) +{ BIO_meth_free(methods_async); - - return testresult; } diff --git a/test/bad_dtls_test.c b/test/bad_dtls_test.c index 9745ff8720..2c10a1cc5b 100644 --- a/test/bad_dtls_test.c +++ b/test/bad_dtls_test.c @@ -581,7 +581,8 @@ static int test_bad_dtls(void) return testresult; } -void register_tests(void) +int setup_tests(void) { ADD_TEST(test_bad_dtls); + return 1; } diff --git a/test/bftest.c b/test/bftest.c index df2c9a7af5..cc509f2dfc 100644 --- a/test/bftest.c +++ b/test/bftest.c @@ -435,7 +435,7 @@ static int test_bf_ofb64(void) } #endif -int test_main(int argc, char *argv[]) +int setup_tests(void) { #ifndef OPENSSL_NO_BF # ifdef CHARSET_EBCDIC @@ -447,15 +447,16 @@ int test_main(int argc, char *argv[]) } # endif - ADD_ALL_TESTS(test_bf_ecb_raw, 2); - ADD_ALL_TESTS(test_bf_ecb, NUM_TESTS); - ADD_ALL_TESTS(test_bf_set_key, KEY_TEST_NUM-1); - ADD_TEST(test_bf_cbc); - ADD_TEST(test_bf_cfb64); - ADD_TEST(test_bf_ofb64); - - if (argc > 1) - return print_test_data(); + if (test_get_argument(0) != NULL) { + print_test_data(); + } else { + ADD_ALL_TESTS(test_bf_ecb_raw, 2); + ADD_ALL_TESTS(test_bf_ecb, NUM_TESTS); + ADD_ALL_TESTS(test_bf_set_key, KEY_TEST_NUM-1); + ADD_TEST(test_bf_cbc); + ADD_TEST(test_bf_cfb64); + ADD_TEST(test_bf_ofb64); + } #endif - return run_tests(argv[0]); + return 1; } diff --git a/test/bio_enc_test.c b/test/bio_enc_test.c index bc49a7992a..8474dc516e 100644 --- a/test/bio_enc_test.c +++ b/test/bio_enc_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -212,7 +212,7 @@ static int test_bio_enc_chacha20_poly1305(int idx) return do_test_bio_cipher(EVP_chacha20_poly1305(), idx); } -void register_tests(void) +int setup_tests(void) { ADD_ALL_TESTS(test_bio_enc_aes_128_cbc, 2); ADD_ALL_TESTS(test_bio_enc_aes_128_ctr, 2); @@ -224,4 +224,5 @@ void register_tests(void) ADD_ALL_TESTS(test_bio_enc_chacha20_poly1305, 2); # endif # endif + return 1; } diff --git a/test/bioprinttest.c b/test/bioprinttest.c index 2c51b7a8b5..d35bffa840 100644 --- a/test/bioprinttest.c +++ b/test/bioprinttest.c @@ -253,17 +253,15 @@ static int test_big(void) } -int test_main(int argc, char **argv) +int setup_tests(void) { - if (argc == 2 && strcmp(argv[1], "-expected") == 0) - justprint = 1; + justprint = test_has_option("-expected"); ADD_TEST(test_big); ADD_ALL_TESTS(test_fp, nelem(pw_params)); ADD_ALL_TESTS(test_zu, nelem(zu_data)); ADD_ALL_TESTS(test_j, nelem(jf_data)); - - return run_tests(argv[0]); + return 1; } /* diff --git a/test/bntest.c b/test/bntest.c index 59148b0366..a570d0099b 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -2003,16 +2003,15 @@ static int file_test_run(STANZA *s) return 0; } -static char * const *testfiles; - static int run_file_tests(int i) { STANZA *s = NULL; + char *testfile = test_get_argument(i); int c; if (!TEST_ptr(s = OPENSSL_zalloc(sizeof(*s)))) return 0; - if (!test_start_file(s, testfiles[i])) { + if (!test_start_file(s, testfile)) { OPENSSL_free(s); return 0; } @@ -2034,18 +2033,17 @@ static int run_file_tests(int i) } -int test_main(int argc, char *argv[]) +int setup_tests(void) |