X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Fssl_test.c;h=61850eb9f6af8c7a7747e48ad802a74136f088ec;hp=fb6214e9fed14d916bf6e430a6043dd44233d7cd;hb=66ed24b1624606593a23c9fe78d459718d26409c;hpb=6ec327eed616deeb4e5ecf1abfb1e1a530ba0701 diff --git a/test/ssl_test.c b/test/ssl_test.c index fb6214e9fe..61850eb9f6 100644 --- a/test/ssl_test.c +++ b/test/ssl_test.c @@ -17,24 +17,13 @@ #include "handshake_helper.h" #include "ssl_test_ctx.h" #include "testutil.h" +#include "test_main_custom.h" static CONF *conf = NULL; /* Currently the section names are of the form test-, 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"; @@ -198,6 +187,17 @@ static int check_resumption(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx) return 1; } +static int check_tmp_key(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx) +{ + if (test_ctx->expected_tmp_key_type == 0 + || test_ctx->expected_tmp_key_type == result->tmp_key_type) + return 1; + fprintf(stderr, "Tmp key type mismatch, %s vs %s\n", + OBJ_nid2ln(test_ctx->expected_tmp_key_type), + OBJ_nid2ln(result->tmp_key_type)); + return 0; +} + /* * This could be further simplified by constructing an expected * HANDSHAKE_RESULT, and implementing comparison methods for @@ -218,19 +218,23 @@ static int check_test(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx) #endif ret &= check_alpn(result, test_ctx); ret &= check_resumption(result, test_ctx); + ret &= check_tmp_key(result, 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 +276,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,24 +309,7 @@ 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 test_main(int argc, char **argv) { int result = 0; long num_tests; @@ -341,5 +328,6 @@ int main(int argc, char **argv) ADD_ALL_TESTS(test_handshake, (int)(num_tests)); result = run_tests(argv[0]); + NCONF_free(conf); return result; }