diff options
author | Emilia Kasper <emilia@openssl.org> | 2016-11-04 16:06:12 +0100 |
---|---|---|
committer | Emilia Kasper <emilia@openssl.org> | 2016-11-07 16:55:16 +0100 |
commit | d836d71b2da026b4ed9a2233657b2289ab8e4be0 (patch) | |
tree | c4c9b9e2112eaea750871d66914868ea8585a6da /test/ssl_test.c | |
parent | 8e47ee18c8f7e59575effdd8dfcfbfff1a365ede (diff) |
Simplify tests part 2
1) Remove some unnecessary fixtures
2) Add EXECUTE_TEST_NO_TEARDOWN shorthand when a fixture exists but has
no teardown.
3) Fix return values in ct_test.c (introduced by an earlier refactoring,
oops)
Note that for parameterized tests, the index (test vector) usually holds all the
customization, and there should be no need for a separate test
fixture. The CTS test is an exception: it demonstrates how to combine
customization with parameterization.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'test/ssl_test.c')
-rw-r--r-- | test/ssl_test.c | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/test/ssl_test.c b/test/ssl_test.c index fb6214e9fe..e53889b37a 100644 --- a/test/ssl_test.c +++ b/test/ssl_test.c @@ -23,18 +23,6 @@ static CONF *conf = NULL; /* Currently the section names are of the form test-<number>, e.g. test-15. */ #define MAX_TESTCASE_NAME_LENGTH 100 -typedef struct ssl_test_ctx_test_fixture { - const char *test_case_name; - char test_app[MAX_TESTCASE_NAME_LENGTH]; -} SSL_TEST_FIXTURE; - -static SSL_TEST_FIXTURE set_up(const char *const test_case_name) -{ - SSL_TEST_FIXTURE fixture; - fixture.test_case_name = test_case_name; - return fixture; -} - static const char *print_alert(int alert) { return alert ? SSL_alert_desc_string_long(alert) : "no alert"; @@ -222,15 +210,18 @@ static int check_test(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx) return ret; } -static int execute_test(SSL_TEST_FIXTURE fixture) +static int test_handshake(int idx) { int ret = 0; SSL_CTX *server_ctx = NULL, *server2_ctx = NULL, *client_ctx = NULL, *resume_server_ctx = NULL, *resume_client_ctx = NULL; SSL_TEST_CTX *test_ctx = NULL; HANDSHAKE_RESULT *result = NULL; + char test_app[MAX_TESTCASE_NAME_LENGTH]; + + BIO_snprintf(test_app, sizeof(test_app), "test-%d", idx); - test_ctx = SSL_TEST_CTX_create(conf, fixture.test_app); + test_ctx = SSL_TEST_CTX_create(conf, test_app); if (test_ctx == NULL) goto err; @@ -272,7 +263,7 @@ static int execute_test(SSL_TEST_FIXTURE fixture) TEST_check(server_ctx != NULL); TEST_check(client_ctx != NULL); - TEST_check(CONF_modules_load(conf, fixture.test_app, 0) > 0); + TEST_check(CONF_modules_load(conf, test_app, 0) > 0); if (!SSL_CTX_config(server_ctx, "server") || !SSL_CTX_config(client_ctx, "client")) { @@ -305,23 +296,6 @@ err: return ret; } -static void tear_down(SSL_TEST_FIXTURE fixture) -{ -} - -#define SETUP_SSL_TEST_FIXTURE() \ - SETUP_TEST_FIXTURE(SSL_TEST_FIXTURE, set_up) -#define EXECUTE_SSL_TEST() \ - EXECUTE_TEST(execute_test, tear_down) - -static int test_handshake(int idx) -{ - SETUP_SSL_TEST_FIXTURE(); - BIO_snprintf(fixture.test_app, sizeof(fixture.test_app), - "test-%d", idx); - EXECUTE_SSL_TEST(); -} - int main(int argc, char **argv) { int result = 0; |