@@ -532,15 +532,6 @@ int tmpDirNameSet = 0;
532532 | Constants
533533 *----------------------------------------------------------------------------*/
534534
535- /* Test result constants and macros. */
536-
537- /* Test succeeded. */
538- #define TEST_SUCCESS (1)
539- /* Test failed. */
540- #define TEST_FAIL (0)
541- /* Test skipped - not run. */
542- #define TEST_SKIPPED (-7777)
543-
544535/* Returns the result based on whether check is true.
545536 *
546537 * @param [in] check Condition for success.
@@ -7291,7 +7282,7 @@ static WC_INLINE int test_ssl_memio_read_cb(WOLFSSL *ssl, char *data, int sz,
72917282
72927283static WC_INLINE int test_ssl_memio_setup(test_ssl_memio_ctx *ctx)
72937284{
7294- EXPECT_DECLS ;
7285+ EXPECT_DECLS_NO_MSGS(-2000) ;
72957286#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
72967287 int c_sharedCtx = 0;
72977288 int s_sharedCtx = 0;
@@ -7564,7 +7555,7 @@ static int test_ssl_memio_do_handshake(test_ssl_memio_ctx* ctx, int max_rounds,
75647555
75657556static int test_ssl_memio_read_write(test_ssl_memio_ctx* ctx)
75667557{
7567- EXPECT_DECLS ;
7558+ EXPECT_DECLS_NO_MSGS(-3000) ;
75687559 char input[1024];
75697560 int idx = 0;
75707561 const char* msg_c = "hello wolfssl!";
@@ -7653,7 +7644,14 @@ static void test_ssl_memio_cleanup(test_ssl_memio_ctx* ctx)
76537644int test_wolfSSL_client_server_nofail_memio(test_ssl_cbf* client_cb,
76547645 test_ssl_cbf* server_cb, cbType client_on_handshake)
76557646{
7656- EXPECT_DECLS;
7647+ /* We use EXPECT_DECLS_NO_MSGS() here because this helper routine is used
7648+ * for numerous but varied expected-to-fail scenarios that should not emit
7649+ * error messages on the expected failures. Instead, we return a distinct
7650+ * code for each failure point, allowing the caller to assert on a
7651+ * particular mode of expected failure. On success, the usual TEST_SUCCESS
7652+ * is returned.
7653+ */
7654+ EXPECT_DECLS_NO_MSGS(-1000);
76577655 struct test_ssl_memio_ctx test_ctx;
76587656#ifdef WOLFSSL_HAVE_TLS_UNIQUE
76597657 size_t msg_len;
@@ -7665,8 +7663,8 @@ int test_wolfSSL_client_server_nofail_memio(test_ssl_cbf* client_cb,
76657663
76667664 test_ctx.c_ctx = client_cb->ctx;
76677665 test_ctx.s_ctx = server_cb->ctx;
7668- test_ctx.c_cb.return_code = TEST_FAIL ;
7669- test_ctx.s_cb.return_code = TEST_FAIL ;
7666+ test_ctx.c_cb.return_code = EXPECT_FAILURE_CODEPOINT_ID ;
7667+ test_ctx.s_cb.return_code = EXPECT_FAILURE_CODEPOINT_ID ;
76707668
76717669 ExpectIntEQ(test_ssl_memio_setup(&test_ctx), TEST_SUCCESS);
76727670 ExpectIntEQ(test_ssl_memio_do_handshake(&test_ctx, 10, NULL), TEST_SUCCESS);
@@ -9575,10 +9573,10 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_3(void)
95759573 * therefore, handshake becomes failure.
95769574 */
95779575 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&client_cbf,
9578- &server_cbf, NULL), TEST_FAIL );
9576+ &server_cbf, NULL), -1001 );
95799577
9580- ExpectIntEQ(client_cbf.return_code, TEST_FAIL );
9581- ExpectIntEQ(server_cbf.return_code, TEST_FAIL );
9578+ ExpectIntEQ(client_cbf.return_code, -1000 );
9579+ ExpectIntEQ(server_cbf.return_code, -1000 );
95829580 ExpectIntEQ(client_cbf.last_err, WC_NO_ERR_TRACE(MAX_CHAIN_ERROR));
95839581 ExpectIntEQ(server_cbf.last_err, WC_NO_ERR_TRACE(FATAL_ERROR));
95849582#endif /* OPENSSL_EXTRA && HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
@@ -14120,7 +14118,7 @@ static int test_wolfSSL_X509_TLS_version_test_1(void)
1412014118
1412114119#ifndef OPENSSL_COMPATIBLE_DEFAULTS
1412214120 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&func_cb_client,
14123- &func_cb_server, NULL), TEST_FAIL );
14121+ &func_cb_server, NULL), -1001 );
1412414122#else
1412514123 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&func_cb_client,
1412614124 &func_cb_server, NULL), TEST_SUCCESS);
@@ -61861,7 +61859,7 @@ static int test_wolfSSL_curves_mismatch(void)
6186161859 func_cb_server.method = test_params[i].server_meth;
6186261860
6186361861 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&func_cb_client,
61864- &func_cb_server, NULL), TEST_FAIL );
61862+ &func_cb_server, NULL), -1001 );
6186561863 ExpectIntEQ(func_cb_client.last_err, test_params[i].client_last_err);
6186661864 ExpectIntEQ(func_cb_server.last_err, test_params[i].server_last_err);
6186761865
@@ -69656,10 +69654,16 @@ static int test_wolfSSL_SESSION_expire_downgrade(void)
6965669654
6965769655#if defined(OPENSSL_EXTRA) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && \
6965869656 defined(HAVE_EX_DATA) && !defined(NO_SESSION_CACHE)
69659- static int clientSessRemCountMalloc = 0;
69660- static int serverSessRemCountMalloc = 0;
69661- static int clientSessRemCountFree = 0;
69662- static int serverSessRemCountFree = 0;
69657+ #ifdef WOLFSSL_ATOMIC_OPS
69658+ typedef wolfSSL_Atomic_Int SessRemCounter_t;
69659+ #else
69660+ typedef int SessRemCounter_t;
69661+ #endif
69662+ static SessRemCounter_t clientSessRemCountMalloc;
69663+ static SessRemCounter_t serverSessRemCountMalloc;
69664+ static SessRemCounter_t clientSessRemCountFree;
69665+ static SessRemCounter_t serverSessRemCountFree;
69666+
6966369667static WOLFSSL_CTX* serverSessCtx = NULL;
6966469668static WOLFSSL_SESSION* serverSess = NULL;
6966569669#if (defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)) || \
@@ -69680,9 +69684,9 @@ static void SessRemCtxCb(WOLFSSL_CTX *ctx, WOLFSSL_SESSION *sess)
6968069684 side = (int*)SSL_SESSION_get_ex_data(sess, serverSessRemIdx);
6968169685 if (side != NULL) {
6968269686 if (*side == WOLFSSL_CLIENT_END)
69683- clientSessRemCountFree++ ;
69687+ (void)wolfSSL_Atomic_Int_FetchAdd(& clientSessRemCountFree, 1) ;
6968469688 else
69685- serverSessRemCountFree++ ;
69689+ (void)wolfSSL_Atomic_Int_FetchAdd(& serverSessRemCountFree, 1) ;
6968669690
6968769691 SSL_SESSION_set_ex_data(sess, serverSessRemIdx, NULL);
6968869692 }
@@ -69719,14 +69723,14 @@ static int SessRemSslSetupCb(WOLFSSL* ssl)
6971969723
6972069724 if (SSL_is_server(ssl)) {
6972169725 side = &sessRemCtx_Server;
69722- serverSessRemCountMalloc++ ;
69726+ (void)wolfSSL_Atomic_Int_FetchAdd(& serverSessRemCountMalloc, 1) ;
6972369727 ExpectNotNull(serverSess = SSL_get1_session(ssl));
6972469728 ExpectIntEQ(SSL_CTX_up_ref(serverSessCtx = SSL_get_SSL_CTX(ssl)),
6972569729 SSL_SUCCESS);
6972669730 }
6972769731 else {
6972869732 side = &sessRemCtx_Client;
69729- clientSessRemCountMalloc++ ;
69733+ (void)wolfSSL_Atomic_Int_FetchAdd(& clientSessRemCountMalloc, 1) ;
6973069734 #if (defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)) || \
6973169735 !defined(NO_SESSION_CACHE_REF)
6973269736 ExpectNotNull(clientSess = SSL_get1_session(ssl));
@@ -69750,6 +69754,11 @@ static int test_wolfSSL_CTX_sess_set_remove_cb(void)
6975069754 * session object */
6975169755 test_ssl_cbf func_cb;
6975269756
69757+ wolfSSL_Atomic_Int_Init(&clientSessRemCountMalloc, 0);
69758+ wolfSSL_Atomic_Int_Init(&serverSessRemCountMalloc, 0);
69759+ wolfSSL_Atomic_Int_Init(&clientSessRemCountFree, 0);
69760+ wolfSSL_Atomic_Int_Init(&serverSessRemCountFree, 0);
69761+
6975369762 XMEMSET(&func_cb, 0, sizeof(func_cb));
6975469763 func_cb.ctx_ready = SessRemCtxSetupCb;
6975569764 func_cb.on_result = SessRemSslSetupCb;
@@ -78615,7 +78624,7 @@ static int test_DhCallbacks(void)
7861578624 func_cb_server.method = wolfTLSv1_2_server_method;
7861678625
7861778626 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&func_cb_client,
78618- &func_cb_server, NULL), TEST_FAIL );
78627+ &func_cb_server, NULL), -1001 );
7861978628#endif
7862078629 return EXPECT_RESULT();
7862178630}
@@ -85792,7 +85801,7 @@ static int test_multiple_crls_same_issuer(void)
8579285801 client_cbs.ctx_ready = test_multiple_crls_same_issuer_ctx_ready;
8579385802
8579485803 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&client_cbs,
85795- &server_cbs, NULL), TEST_FAIL );
85804+ &server_cbs, NULL), -1001 );
8579685805 }
8579785806#endif
8579885807 return EXPECT_RESULT();
@@ -90339,7 +90348,7 @@ static int test_wolfSSL_CRL_CERT_REVOKED_alert(void)
9033990348 server_cbs.on_cleanup = test_wolfSSL_CRL_CERT_REVOKED_alert_on_cleanup;
9034090349
9034190350 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&client_cbs,
90342- &server_cbs, NULL), TEST_FAIL );
90351+ &server_cbs, NULL), -1001 );
9034390352
9034490353 return EXPECT_RESULT();
9034590354}
@@ -91146,7 +91155,7 @@ static int test_override_alt_cert_chain(void)
9114691155 {test_override_alt_cert_chain_client_ctx_ready,
9114791156 test_override_alt_cert_chain_server_ctx_ready, TEST_SUCCESS},
9114891157 {test_override_alt_cert_chain_client_ctx_ready2,
91149- test_override_alt_cert_chain_server_ctx_ready, TEST_FAIL },
91158+ test_override_alt_cert_chain_server_ctx_ready, -1001 },
9115091159 };
9115191160
9115291161 for (i = 0; i < sizeof(params)/sizeof(*params); i++) {
@@ -91162,8 +91171,10 @@ static int test_override_alt_cert_chain(void)
9116291171 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&client_cbs,
9116391172 &server_cbs, NULL), params[i].result);
9116491173
91165- ExpectIntEQ(client_cbs.return_code, params[i].result);
91166- ExpectIntEQ(server_cbs.return_code, params[i].result);
91174+ ExpectIntEQ(client_cbs.return_code,
91175+ params[i].result <= 0 ? -1000 : TEST_SUCCESS);
91176+ ExpectIntEQ(server_cbs.return_code,
91177+ params[i].result <= 0 ? -1000 : TEST_SUCCESS);
9116791178 }
9116891179
9116991180 return EXPECT_RESULT();
@@ -93766,7 +93777,7 @@ static int test_revoked_loaded_int_cert(void)
9376693777 client_cbf.ctx_ready = test_params[i].client_ctx_ready;
9376793778
9376893779 ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&client_cbf,
93769- &server_cbf, NULL), TEST_FAIL );
93780+ &server_cbf, NULL), -1001 );
9377093781 ExpectIntEQ(client_cbf.last_err, WC_NO_ERR_TRACE(CRL_CERT_REVOKED));
9377193782 ExpectIntEQ(server_cbf.last_err, WC_NO_ERR_TRACE(FATAL_ERROR));
9377293783
0 commit comments