Skip to content

Commit

Permalink
Merge pull request #30 from bigbrett/test-custom-server-macro
Browse files Browse the repository at this point in the history
add "custom server" macro for tests
  • Loading branch information
billphipps authored May 20, 2024
2 parents 210d962 + 8fcfd0e commit f4cde33
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/wh_test_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ int whTest_CryptoClientConfig(whClientConfig* config)
WH_ERROR_PRINT("KEY CACHE/EXPORT FAILED TO MATCH\n");
goto exit;
}
#ifndef WH_CFG_TEST_NO_CUSTOM_SERVERS
/* WH_CFG_TEST_NO_CUSTOM_SERVERS protects the client test code that expects to
* interop with the custom server (also defined in this file), so that this
* test can be run against a standard server app
*
* TODO: This is a temporary bodge until we properly split tests into single
* client and multi client */

/* test cache with duplicate keyId for a different user */
WH_TEST_RETURN_ON_FAIL(wh_Client_CommClose(client));
client->comm->client_id = 2;
Expand Down Expand Up @@ -210,6 +218,7 @@ int whTest_CryptoClientConfig(whClientConfig* config)
WH_ERROR_PRINT("KEY CACHE/EXPORT FAILED TO MATCH\n");
goto exit;
}
#endif /* !WH_CFG_TEST_NO_CUSTOM_SERVERS */
/* evict for original client */
if ((ret = wh_Client_KeyEvictRequest(client, keyId)) != 0) {
WH_ERROR_PRINT("Failed to wh_Client_KeyEvictRequest %d\n", ret);
Expand Down Expand Up @@ -417,7 +426,9 @@ int whTest_CryptoServerConfig(whServerConfig* config)
whServerContext server[1] = {0};
whCommConnected am_connected = WH_COMM_CONNECTED;
int ret = 0;
#ifndef WH_CFG_TEST_NO_CUSTOM_SERVERS
int userChange = 0;
#endif

if (config == NULL) {
return WH_ERROR_BADARGS;
Expand All @@ -435,6 +446,8 @@ int whTest_CryptoServerConfig(whServerConfig* config)
break;
}
wh_Server_GetConnected(server, &am_connected);

#ifndef WH_CFG_TEST_NO_CUSTOM_SERVERS
/* keep alive for 2 user changes */
if (am_connected != WH_COMM_CONNECTED && userChange < 2) {
if (userChange == 0)
Expand All @@ -445,8 +458,10 @@ int whTest_CryptoServerConfig(whServerConfig* config)
am_connected = WH_COMM_CONNECTED;
WH_TEST_RETURN_ON_FAIL(wh_Server_SetConnected(server, am_connected));
}
#endif /* !WH_CFG_TEST_NO_CUSTOM_SERVERS */
}
if ((ret == 0) || (ret == WH_ERROR_NOTREADY)){

if ((ret == 0) || (ret == WH_ERROR_NOTREADY)) {
WH_TEST_RETURN_ON_FAIL(wh_Server_Cleanup(server));
} else {
ret = wh_Server_Cleanup(server);
Expand Down Expand Up @@ -581,7 +596,6 @@ static int wh_ClientServer_MemThreadTest(void)
}
#endif /* WH_CFG_TEST_POSIX */


int whTest_Crypto(void)
{
#if defined(WH_CFG_TEST_POSIX)
Expand Down

0 comments on commit f4cde33

Please sign in to comment.