Warmcat homepage andy@warmcat.com
libwebsockets
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1750169074, "reponame":"openssl", "desc":"OpenSSL", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://warmcat.com/repo/openssl", "f":3, "items": [ {"schema":"libjg2-1", "cid":"fb2ea25bb09f925e2eebddcbacad687b", "commit": {"type":"commit", "time": 1501639191, "time_ofs": 600, "oid_tree": { "oid": "c070bf8e8acd899ce0fdfed32330b5002138e96c", "alias": []}, "oid":{ "oid": "7e885b7bdfad897596e3c954e7c3a2d53a9a5cbe", "alias": []}, "msg": "Simplify some of the sslapitest code.", "sig_commit": { "git_time": { "time": 1501639191, "offset": 600 }, "name": "Pauli", "email": "paul.dale@oracle.com", "md5": "4616f8cb80bd6ce4dab75d05e07cd125" }, "sig_author": { "git_time": { "time": 1501560559, "offset": 600 }, "name": "Pauli", "email": "paul.dale@oracle.com", "md5": "4616f8cb80bd6ce4dab75d05e07cd125" }}, "body": "Simplify some of the sslapitest code.\n\nRemoving the use of SETUP_TEST_FIXTURE reduces complxity in those tests that\nused it.\n\nReviewed-by: Rich Salz \u003crsalz@openssl.org\u003e\nReviewed-by: Andy Polyakov \u003cappro@openssl.org\u003e\n(Merged from https://github.com/openssl/openssl/pull/4066)\n" , "diff": "diff --git a/test/sslapitest.c b/test/sslapitest.c\nindex a2917da..afb119d 100644\n--- a/test/sslapitest.c\n+++ b/test/sslapitest.c\n@@ -757,32 +757,8 @@ static int test_tlsext_status_type(void)\n }\n #endif\n \n-typedef struct ssl_session_test_fixture {\n- const char *test_case_name;\n- int use_ext_cache;\n- int use_int_cache;\n-} SSL_SESSION_TEST_FIXTURE;\n-\n static int new_called \u003d 0, remove_called \u003d 0;\n \n-static SSL_SESSION_TEST_FIXTURE\n-ssl_session_set_up(const char *const test_case_name)\n-{\n- SSL_SESSION_TEST_FIXTURE fixture;\n-\n- fixture.test_case_name \u003d test_case_name;\n- fixture.use_ext_cache \u003d 1;\n- fixture.use_int_cache \u003d 1;\n-\n- new_called \u003d remove_called \u003d 0;\n-\n- return fixture;\n-}\n-\n-static void ssl_session_tear_down(SSL_SESSION_TEST_FIXTURE fixture)\n-{\n-}\n-\n static int new_session_cb(SSL *ssl, SSL_SESSION *sess)\n {\n new_called++;\n@@ -799,7 +775,7 @@ static void remove_session_cb(SSL_CTX *ctx, SSL_SESSION *sess)\n remove_called++;\n }\n \n-static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n+static int execute_test_session(int use_int_cache, int use_ext_cache)\n {\n SSL_CTX *sctx \u003d NULL, *cctx \u003d NULL;\n SSL *serverssl1 \u003d NULL, *clientssl1 \u003d NULL;\n@@ -810,6 +786,8 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n SSL_SESSION *sess1 \u003d NULL, *sess2 \u003d NULL;\n int testresult \u003d 0;\n \n+ new_called \u003d remove_called \u003d 0;\n+\n if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(),\n TLS_client_method(), \u0026sctx,\n \u0026cctx, cert, privkey)))\n@@ -821,11 +799,11 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n #endif\n \n /* Set up session cache */\n- if (fix.use_ext_cache) {\n+ if (use_ext_cache) {\n SSL_CTX_sess_set_new_cb(cctx, new_session_cb);\n SSL_CTX_sess_set_remove_cb(cctx, remove_session_cb);\n }\n- if (fix.use_int_cache) {\n+ if (use_int_cache) {\n /* Also covers instance where both are set */\n SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT);\n } else {\n@@ -842,9 +820,10 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n goto end;\n \n /* Should fail because it should already be in the cache */\n- if (fix.use_int_cache \u0026\u0026 !TEST_false(SSL_CTX_add_session(cctx, sess1)))\n+ if (use_int_cache \u0026\u0026 !TEST_false(SSL_CTX_add_session(cctx, sess1)))\n goto end;\n- if (fix.use_ext_cache \u0026\u0026 (new_called !\u003d 1 || remove_called !\u003d 0))\n+ if (use_ext_cache \u0026\u0026 !TEST_int_eq(new_called, 1)\n+ \u0026\u0026 !TEST_int_eq(remove_called, 0))\n goto end;\n \n #if !defined(OPENSSL_NO_TLS1_3)\n@@ -861,8 +840,8 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n * In TLSv1.3 we should have created a new session even though we have\n * resumed. The original session should also have been removed.\n */\n- if (fix.use_ext_cache \u0026\u0026 !TEST_true((new_called \u003d\u003d 1\n- \u0026\u0026 remove_called \u003d\u003d 1)))\n+ if (use_ext_cache \u0026\u0026 !TEST_int_eq(new_called, 1)\n+ \u0026\u0026 !TEST_int_eq(remove_called, 1))\n goto end;\n \n SSL_SESSION_free(sess1);\n@@ -882,7 +861,8 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n if (!TEST_ptr(sess2 \u003d SSL_get1_session(clientssl2)))\n goto end;\n \n- if (fix.use_ext_cache \u0026\u0026 !TEST_true(new_called \u003d\u003d 1 \u0026\u0026 remove_called \u003d\u003d 0))\n+ if (use_ext_cache \u0026\u0026 !TEST_int_eq(new_called, 1)\n+ \u0026\u0026 !TEST_int_eq(remove_called, 0))\n goto end;\n \n new_called \u003d remove_called \u003d 0;\n@@ -892,12 +872,13 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n */\n if (!TEST_true(SSL_set_session(clientssl2, sess1)))\n goto end;\n- if (fix.use_ext_cache \u0026\u0026 !TEST_true(new_called \u003d\u003d 0 \u0026\u0026 remove_called \u003d\u003d 1))\n+ if (use_ext_cache \u0026\u0026 !TEST_int_eq(new_called, 0)\n+ \u0026\u0026 !TEST_int_eq(remove_called, 1))\n goto end;\n if (!TEST_ptr_eq(SSL_get_session(clientssl2), sess1))\n goto end;\n \n- if (fix.use_int_cache) {\n+ if (use_int_cache) {\n /* Should succeeded because it should not already be in the cache */\n if (!TEST_true(SSL_CTX_add_session(cctx, sess2))\n || !TEST_true(SSL_CTX_remove_session(cctx, sess2)))\n@@ -909,7 +890,8 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n if (!TEST_false(SSL_CTX_remove_session(cctx, sess2)))\n goto end;\n \n- if (fix.use_ext_cache \u0026\u0026 !TEST_true(new_called \u003d\u003d 0 \u0026\u0026 remove_called \u003d\u003d 1))\n+ if (use_ext_cache \u0026\u0026 !TEST_int_eq(new_called, 0)\n+ \u0026\u0026 !TEST_int_eq(remove_called, 1))\n goto end;\n \n #if !defined(OPENSSL_NO_TLS1_1) \u0026\u0026 !defined(OPENSSL_NO_TLS1_2)\n@@ -925,11 +907,12 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n goto end;\n \n /* We should have automatically removed the session from the cache */\n- if (fix.use_ext_cache \u0026\u0026 !TEST_true(new_called \u003d\u003d 0 \u0026\u0026 remove_called \u003d\u003d 1))\n+ if (use_ext_cache \u0026\u0026 !TEST_int_eq(new_called, 0)\n+ \u0026\u0026 !TEST_int_eq(remove_called, 1))\n goto end;\n \n /* Should succeed because it should not already be in the cache */\n- if (fix.use_int_cache \u0026\u0026 !SSL_CTX_add_session(cctx, sess2))\n+ if (use_int_cache \u0026\u0026 !TEST_true(SSL_CTX_add_session(cctx, sess2)))\n goto end;\n #endif\n \n@@ -954,22 +937,17 @@ static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)\n \n static int test_session_with_only_int_cache(void)\n {\n- SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);\n- fixture.use_ext_cache \u003d 0;\n- EXECUTE_TEST(execute_test_session, ssl_session_tear_down);\n+ return execute_test_session(1, 0);\n }\n \n static int test_session_with_only_ext_cache(void)\n {\n- SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);\n- fixture.use_int_cache \u003d 0;\n- EXECUTE_TEST(execute_test_session, ssl_session_tear_down);\n+ return execute_test_session(0, 1);\n }\n \n static int test_session_with_both_cache(void)\n {\n- SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);\n- EXECUTE_TEST(execute_test_session, ssl_session_tear_down);\n+ return execute_test_session(1, 1);\n }\n \n #define USE_NULL 0\n@@ -1083,27 +1061,9 @@ static int test_ssl_set_bio(int idx)\n return testresult;\n }\n \n-typedef struct ssl_bio_test_fixture {\n- const char *test_case_name;\n- int pop_ssl;\n- enum { NO_BIO_CHANGE, CHANGE_RBIO, CHANGE_WBIO } change_bio;\n-} SSL_BIO_TEST_FIXTURE;\n-\n-static SSL_BIO_TEST_FIXTURE ssl_bio_set_up(const char *const test_case_name)\n-{\n- SSL_BIO_TEST_FIXTURE fixture;\n-\n- fixture.test_case_name \u003d test_case_name;\n- fixture.pop_ssl \u003d 0;\n- fixture.change_bio \u003d NO_BIO_CHANGE;\n- return fixture;\n-}\n-\n-static void ssl_bio_tear_down(SSL_BIO_TEST_FIXTURE fixture)\n-{\n-}\n+typedef enum { NO_BIO_CHANGE, CHANGE_RBIO, CHANGE_WBIO } bio_change_t;\n \n-static int execute_test_ssl_bio(SSL_BIO_TEST_FIXTURE fix)\n+static int execute_test_ssl_bio(int pop_ssl, bio_change_t change_bio)\n {\n BIO *sslbio \u003d NULL, *membio1 \u003d NULL, *membio2 \u003d NULL;\n SSL_CTX *ctx;\n@@ -1125,17 +1085,17 @@ static int execute_test_ssl_bio(SSL_BIO_TEST_FIXTURE fix)\n BIO_push(sslbio, membio1);\n \n /* Verify changing the rbio/wbio directly does not cause leaks */\n- if (fix.change_bio !\u003d NO_BIO_CHANGE) {\n+ if (change_bio !\u003d NO_BIO_CHANGE) {\n if (!TEST_ptr(membio2 \u003d BIO_new(BIO_s_mem())))\n goto end;\n- if (fix.change_bio \u003d\u003d CHANGE_RBIO)\n+ if (change_bio \u003d\u003d CHANGE_RBIO)\n SSL_set0_rbio(ssl, membio2);\n else\n SSL_set0_wbio(ssl, membio2);\n }\n ssl \u003d NULL;\n \n- if (fix.pop_ssl)\n+ if (pop_ssl)\n BIO_pop(sslbio);\n else\n BIO_pop(membio1);\n@@ -1152,29 +1112,22 @@ static int execute_test_ssl_bio(SSL_BIO_TEST_FIXTURE fix)\n \n static int test_ssl_bio_pop_next_bio(void)\n {\n- SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);\n- EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);\n+ return execute_test_ssl_bio(0, NO_BIO_CHANGE);\n }\n \n static int test_ssl_bio_pop_ssl_bio(void)\n {\n- SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);\n- fixture.pop_ssl \u003d 1;\n- EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);\n+ return execute_test_ssl_bio(1, NO_BIO_CHANGE);\n }\n \n static int test_ssl_bio_change_rbio(void)\n {\n- SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);\n- fixture.change_bio \u003d CHANGE_RBIO;\n- EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);\n+ return execute_test_ssl_bio(0, CHANGE_RBIO);\n }\n \n static int test_ssl_bio_change_wbio(void)\n {\n- SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);\n- fixture.change_bio \u003d CHANGE_WBIO;\n- EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);\n+ return execute_test_ssl_bio(0, CHANGE_WBIO);\n }\n \n typedef struct {\n","s":{"c":1750066997,"u": 43512}} ],"g": 2048,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "7d0a"}