From: Matt Caswell Date: Mon, 8 Feb 2016 16:45:35 +0000 (+0000) Subject: Clean up the tests for auto-init/de-init X-Git-Tag: OpenSSL_1_1_0-pre3~174 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8793f012f11416abd300aa524057c863e8c16dd5;p=oweals%2Fopenssl.git Clean up the tests for auto-init/de-init Remove the need to explicitly initialise/deinitialise for the tests Reviewed-by: Richard Levitte --- diff --git a/test/bntest.c b/test/bntest.c index d315ad8432..082cf4cba0 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -345,7 +345,7 @@ int main(int argc, char *argv[]) * notices the failure, see test_bn in * test/Makefile.ssl */ (void)BIO_flush(out); - ERR_load_crypto_strings(); + ERR_print_errors_fp(stderr); EXIT(1); } diff --git a/test/clienthellotest.c b/test/clienthellotest.c index d9ae758987..877566131a 100644 --- a/test/clienthellotest.c +++ b/test/clienthellotest.c @@ -103,9 +103,6 @@ int main(int argc, char *argv[]) int testresult = 0; int currtest = 0; - SSL_library_init(); - SSL_load_error_strings(); - err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); CRYPTO_set_mem_debug(1); @@ -212,10 +209,6 @@ int main(int argc, char *argv[]) } } - ERR_free_strings(); - ERR_remove_thread_state(NULL); - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(err) <= 0) testresult = 0; diff --git a/test/danetest.c b/test/danetest.c index b9ccd404d3..01f77313ea 100644 --- a/test/danetest.c +++ b/test/danetest.c @@ -493,8 +493,6 @@ int main(int argc, char *argv[]) return 0; } - SSL_library_init(); - SSL_load_error_strings(); ctx = SSL_CTX_new(TLS_client_method()); if (SSL_CTX_dane_enable(ctx) <= 0) { @@ -526,14 +524,6 @@ end: (void) fclose(f); SSL_CTX_free(ctx); -#ifndef OPENSSL_NO_ENGINE - ENGINE_cleanup(); -#endif - CONF_modules_unload(1); - CRYPTO_cleanup_all_ex_data(); - ERR_free_strings(); - ERR_remove_thread_state(NULL); - EVP_cleanup(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(bio_err) <= 0) ret = 1; diff --git a/test/dsatest.c b/test/dsatest.c index f36b4494d0..b53ee471df 100644 --- a/test/dsatest.c +++ b/test/dsatest.c @@ -140,7 +140,6 @@ int main(int argc, char **argv) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - ERR_load_crypto_strings(); RAND_seed(rnd_seed, sizeof rnd_seed); BIO_printf(bio_err, "test generation of DSA parameters\n"); @@ -211,9 +210,7 @@ int main(int argc, char **argv) ERR_print_errors(bio_err); DSA_free(dsa); BN_GENCB_free(cb); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); + #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(bio_err) <= 0) ret = 0; diff --git a/test/ecdhtest.c b/test/ecdhtest.c index e26fddf08e..e37a020cc7 100644 --- a/test/ecdhtest.c +++ b/test/ecdhtest.c @@ -509,8 +509,7 @@ int main(int argc, char *argv[]) OPENSSL_free(curves); BN_CTX_free(ctx); BIO_free(out); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); + #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) ret = 1; diff --git a/test/ecdsatest.c b/test/ecdsatest.c index feb9f0a6eb..55ebad904c 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -522,7 +522,6 @@ int main(void) p = getenv("OPENSSL_DEBUG_MEMORY"); if (p != NULL && strcmp(p, "on") == 0) CRYPTO_set_mem_debug(1); - ERR_load_crypto_strings(); /* initialize the prng */ RAND_seed(rnd_seed, sizeof(rnd_seed)); @@ -541,9 +540,7 @@ int main(void) BIO_printf(out, "\nECDSA test passed\n"); if (ret) ERR_print_errors(out); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); + #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(out) <= 0) ret = 1; diff --git a/test/ectest.c b/test/ectest.c index 03dfed96c9..0abb54562b 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -1665,7 +1665,6 @@ int main(int argc, char *argv[]) if (p != NULL && strcmp(p, "on") == 0) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - ERR_load_crypto_strings(); RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */ @@ -1680,12 +1679,6 @@ int main(int argc, char *argv[]) /* test the internal curves */ internal_curve_test(); -# ifndef OPENSSL_NO_ENGINE - ENGINE_cleanup(); -# endif - CRYPTO_cleanup_all_ex_data(); - ERR_free_strings(); - ERR_remove_thread_state(NULL); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) return 1; diff --git a/test/enginetest.c b/test/enginetest.c index d8dcca9cc3..873b4eaaad 100644 --- a/test/enginetest.c +++ b/test/enginetest.c @@ -109,7 +109,6 @@ int main(int argc, char *argv[]) p = getenv("OPENSSL_DEBUG_MEMORY"); if (p != NULL && strcmp(p, "on") == 0) CRYPTO_set_mem_debug(1); - ERR_load_crypto_strings(); memset(block, 0, sizeof(block)); if (((new_h1 = ENGINE_new()) == NULL) || @@ -244,10 +243,7 @@ int main(int argc, char *argv[]) ENGINE_free(new_h4); for (loop = 0; loop < 512; loop++) ENGINE_free(block[loop]); - ENGINE_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_free_strings(); - ERR_remove_thread_state(NULL); + #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) to_return = 1; diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 53844ad17d..dbcfb7cbb7 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -422,10 +422,6 @@ int main(void) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - ERR_load_crypto_strings(); - /* Load up the software EVP_CIPHER and EVP_MD definitions */ - OpenSSL_add_all_ciphers(); - OpenSSL_add_all_digests(); if (!test_EVP_DigestSignInit()) { fprintf(stderr, "EVP_DigestSignInit failed\n"); @@ -462,10 +458,6 @@ int main(void) } #endif - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) return 1; diff --git a/test/evp_test.c b/test/evp_test.c index ff2ee10c28..6bc3a8ab39 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -592,9 +592,6 @@ int main(int argc, char **argv) CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - ERR_load_crypto_strings(); - OpenSSL_add_all_algorithms(); - memset(&t, 0, sizeof(t)); t.start_line = -1; in = fopen(argv[1], "r"); @@ -612,10 +609,7 @@ int main(int argc, char **argv) free_key_list(t.public); free_key_list(t.private); fclose(in); - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); + #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) return 1; diff --git a/test/exptest.c b/test/exptest.c index 5cd79e2970..84d76be403 100644 --- a/test/exptest.c +++ b/test/exptest.c @@ -194,8 +194,6 @@ int main(int argc, char *argv[]) * don't even check its return * value (which we should) */ - ERR_load_BN_strings(); - ctx = BN_CTX_new(); if (ctx == NULL) EXIT(1); @@ -298,7 +296,7 @@ int main(int argc, char *argv[]) BN_free(b); BN_free(m); BN_CTX_free(ctx); - ERR_remove_thread_state(NULL); + #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(out) <= 0) goto err; @@ -313,7 +311,6 @@ int main(int argc, char *argv[]) EXIT(0); err: - ERR_load_crypto_strings(); ERR_print_errors(out); #ifdef OPENSSL_SYS_NETWARE printf("ERROR\n"); diff --git a/test/heartbeat_test.c b/test/heartbeat_test.c index 137aa9b2c6..dd7bf11d00 100644 --- a/test/heartbeat_test.c +++ b/test/heartbeat_test.c @@ -440,9 +440,6 @@ int main(int argc, char *argv[]) { int result = 0; - SSL_library_init(); - SSL_load_error_strings(); - ADD_TEST(test_dtls1_not_bleeding); ADD_TEST(test_dtls1_not_bleeding_empty_payload); ADD_TEST(test_dtls1_heartbleed); diff --git a/test/jpaketest.c b/test/jpaketest.c index 7b59855d23..2b61705bf8 100644 --- a/test/jpaketest.c +++ b/test/jpaketest.c @@ -121,8 +121,6 @@ int main(int argc, char **argv) CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); #endif - ERR_load_crypto_strings(); - /*- BN_hex2bn(&p, "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7"); BN_hex2bn(&g, "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a"); @@ -175,9 +173,6 @@ int main(int argc, char **argv) BN_free(g); BN_free(p); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(bio_err) <= 0) return 1; diff --git a/test/methtest.c b/test/methtest.c index adfb244faf..efec15468f 100644 --- a/test/methtest.c +++ b/test/methtest.c @@ -99,7 +99,6 @@ char *argv[]; METH_control(tmp2, METH_CONTROL_DUMP, stdout); EXIT(0); err: - ERR_load_crypto_strings(); ERR_print_errors_fp(stderr); EXIT(1); return (0); diff --git a/test/p5_crpt2_test.c b/test/p5_crpt2_test.c index 2c998bada3..2c136b6488 100644 --- a/test/p5_crpt2_test.c +++ b/test/p5_crpt2_test.c @@ -183,11 +183,7 @@ int main(int argc, char **argv) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - OpenSSL_add_all_digests(); -# ifndef OPENSSL_NO_ENGINE - ENGINE_load_builtin_engines(); - ENGINE_register_all_digests(); -# endif + OPENSSL_INIT_crypto_library_start(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL); printf("PKCS5_PBKDF2_HMAC() tests "); for (i = 0; test->pass != NULL; i++, test++) { @@ -198,13 +194,6 @@ int main(int argc, char **argv) } printf(" done\n"); -# ifndef OPENSSL_NO_ENGINE - ENGINE_cleanup(); -# endif - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) return 1; diff --git a/test/rsa_test.c b/test/rsa_test.c index 9f1f3d69d9..770c376380 100644 --- a/test/rsa_test.c +++ b/test/rsa_test.c @@ -324,9 +324,6 @@ int main(int argc, char *argv[]) RSA_free(key); } - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) err = 1; diff --git a/test/srptest.c b/test/srptest.c index 442a6101d4..8379535029 100644 --- a/test/srptest.c +++ b/test/srptest.c @@ -129,7 +129,6 @@ int main(int argc, char **argv) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - ERR_load_crypto_strings(); /* "Negative" test, expect a mismatch */ if (run_srp("alice", "password1", "password2") == 0) { @@ -143,9 +142,6 @@ int main(int argc, char **argv) return 1; } - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(bio_err) <= 0) return 1; diff --git a/test/ssltest.c b/test/ssltest.c index f217a2073e..b5d44a0c0f 100644 --- a/test/ssltest.c +++ b/test/ssltest.c @@ -1410,7 +1410,6 @@ int main(int argc, char *argv[]) #ifdef OPENSSL_FIPS if (fips_mode) { if (!FIPS_mode_set(1)) { - ERR_load_crypto_strings(); ERR_print_errors(bio_err); EXIT(1); } else @@ -1430,9 +1429,6 @@ int main(int argc, char *argv[]) /* if (cipher == NULL) cipher=getenv("SSL_CIPHER"); */ - SSL_library_init(); - SSL_load_error_strings(); - #ifndef OPENSSL_NO_COMP if (comp == COMP_ZLIB) cm = COMP_zlib(); @@ -1856,14 +1852,6 @@ int main(int argc, char *argv[]) BIO_free(bio_stdout); -#ifndef OPENSSL_NO_ENGINE - ENGINE_cleanup(); -#endif - CONF_modules_unload(1); - CRYPTO_cleanup_all_ex_data(); - ERR_free_strings(); - ERR_remove_thread_state(NULL); - EVP_cleanup(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks(bio_err) <= 0) ret = 1; diff --git a/test/verify_extra_test.c b/test/verify_extra_test.c index 31c391ec1f..8362de4414 100644 --- a/test/verify_extra_test.c +++ b/test/verify_extra_test.c @@ -190,9 +190,6 @@ int main(int argc, char **argv) CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - ERR_load_crypto_strings(); - OpenSSL_add_all_digests(); - if (argc != 4) { fprintf(stderr, "usage: verify_extra_test roots.pem untrusted.pem bad.pem\n"); return 1; @@ -203,10 +200,6 @@ int main(int argc, char **argv) return 1; } - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_thread_state(NULL); - ERR_free_strings(); #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (CRYPTO_mem_leaks_fp(stderr) <= 0) return 1;