diff options
author | Pauli <paul.dale@oracle.com> | 2017-08-02 13:48:29 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2017-08-04 07:37:21 +1000 |
commit | 2326bba0e5cbe98f4d00855a6909b1f14b6f5427 (patch) | |
tree | 70000f14b8108fccf5f6cc02086845c12c3becee /test/cipherlist_test.c | |
parent | fbf9d108dfca2f578594c1f00bd9dbd2adca7505 (diff) |
Test fixtures changed to pointers.
Change the fixture types to pointers to structures that are heap allocated in the tests that use SETUP_TEST_FIXTURE. This will permit error returns from the setup function and allow for future running tests in parallel.
Also removed a call of `exit(2)` which allows the remaining tests to run if one fails to initialise.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4071)
Diffstat (limited to 'test/cipherlist_test.c')
-rw-r--r-- | test/cipherlist_test.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/test/cipherlist_test.c b/test/cipherlist_test.c index c193976540..2cfddb0d82 100644 --- a/test/cipherlist_test.c +++ b/test/cipherlist_test.c @@ -34,21 +34,23 @@ static void tear_down(CIPHERLIST_TEST_FIXTURE *fixture) SSL_CTX_free(fixture->server); SSL_CTX_free(fixture->client); fixture->server = fixture->client = NULL; + OPENSSL_free(fixture); } } static CIPHERLIST_TEST_FIXTURE *set_up(const char *const test_case_name) { - static CIPHERLIST_TEST_FIXTURE fixture; + CIPHERLIST_TEST_FIXTURE *fixture; - memset(&fixture, 0, sizeof(fixture)); - fixture.test_case_name = test_case_name; - if (!TEST_ptr(fixture.server = SSL_CTX_new(TLS_server_method())) - || !TEST_ptr(fixture.client = SSL_CTX_new(TLS_client_method()))) { - tear_down(&fixture); + if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))) + return NULL; + fixture->test_case_name = test_case_name; + if (!TEST_ptr(fixture->server = SSL_CTX_new(TLS_server_method())) + || !TEST_ptr(fixture->client = SSL_CTX_new(TLS_client_method()))) { + tear_down(fixture); return NULL; } - return &fixture; + return fixture; } /* |