From eb9ef5a5d31405a09c4bf0bbb622db8d424ed660 Mon Sep 17 00:00:00 2001 From: jackctj117 Date: Wed, 19 Nov 2025 17:36:09 -0600 Subject: [PATCH 1/2] Fix verbose macro mismatch and HexDump formatting --- test/wh_test_clientserver.c | 82 ++++++++++++++++++------------------- test/wh_test_common.h | 2 +- test/wh_test_crypto.c | 12 +++--- test/wh_test_nvm_flash.c | 32 ++++++++------- test/wh_test_she.c | 8 ++-- 5 files changed, 70 insertions(+), 66 deletions(-) diff --git a/test/wh_test_clientserver.c b/test/wh_test_clientserver.c index 86025f2b9..1c5401208 100644 --- a/test/wh_test_clientserver.c +++ b/test/wh_test_clientserver.c @@ -418,7 +418,7 @@ static int _testClientCounter(whClientContext* client) whNvmId avail_objects; whNvmId reclaim_objects; -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Testing NVM counters...\n"); #endif @@ -480,7 +480,7 @@ static int _testClientCounter(whClientContext* client) WH_TEST_RETURN_ON_FAIL(rc = wh_Client_NvmGetAvailable( client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailable:%d, server_rc:%d, avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", rc, (int)server_rc, (int)avail_size, (int)avail_objects, @@ -920,7 +920,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL( wh_Client_EchoRequest(client, send_len, send_buffer)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client EchoRequest:%d, len:%d, %.*s\n", ret, send_len, send_len, send_buffer); #endif @@ -933,14 +933,14 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Server HandleRequestMessage:%d\n", ret); #endif WH_TEST_RETURN_ON_FAIL( wh_Client_EchoResponse(client, &recv_len, recv_buffer)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client EchoResponse:%d, len:%d, %.*s, expected:%.*s\n", ret, recv_len, recv_len, recv_buffer, send_len, send_buffer); #endif @@ -954,7 +954,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL( wh_Client_NvmInitResponse(client, &server_rc, &client_id, &server_id)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmInitResponse:%d, server_rc:%d, clientid:%d serverid:%d\n", ret, (int)server_rc, (int)client_id, (int)server_id); #endif @@ -966,7 +966,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Client_NvmGetAvailableResponse( client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailableResponse:%d, server_rc:%d avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, @@ -997,7 +997,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) len = snprintf(send_buffer, sizeof(send_buffer), "Data:%d Counter:%d", id, counter); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmAddObjectRequest:%d, id:%u, access:0x%x, flags:0x%x, " "len:%u label:%s\nData:%s\n", ret, id, access, flags, len, label, send_buffer); @@ -1011,7 +1011,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL( wh_Client_NvmAddObjectResponse(client, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmAddObjectResponse:%d, server_rc:%d\n", ret, (int)server_rc); #endif @@ -1022,7 +1022,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Client_NvmGetAvailableResponse( client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailableResponse:%d, server_rc:%d, avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, @@ -1038,7 +1038,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Client_NvmGetMetadataResponse( client, &server_rc, &gid, &gaccess, &gflags, &glen, sizeof(glabel), (uint8_t*)glabel)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetMetadataResponse:%d, id:%u, access:0x%x, " "flags:0x%x, len:%u label:%s\n", ret, gid, gaccess, gflags, glen, glabel); @@ -1053,7 +1053,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL(wh_Client_NvmReadResponse( client, &server_rc, &rlen, (uint8_t*)recv_buffer)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT( "Client NvmReadResponse:%d, server_rc:%d id:%u, len:%u data:%s\n", ret, (int)server_rc, (unsigned int)gid, (unsigned int)rlen, recv_buffer); @@ -1079,7 +1079,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL(wh_Client_NvmListResponse( client, &server_rc, &list_count, &list_id)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmListResponse:%d, server_rc:%d count:%u id:%u\n", ret, (int)server_rc, (unsigned int)list_count, (unsigned int)list_id); #endif @@ -1094,7 +1094,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL( wh_Client_NvmDestroyObjectsResponse(client, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmDestroyObjectsResponse:%d, server_rc:%d for " "id:%u with count:%u\n", ret, (int)server_rc, (unsigned int)list_id, (unsigned int)list_count); @@ -1109,7 +1109,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) client, &server_rc, NULL, NULL, NULL, NULL, 0, NULL)); WH_TEST_ASSERT_RETURN(WH_ERROR_NOTFOUND == server_rc); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmListResponse:%d, server_rc:%d count:%u id:%u\n", ret, (int)server_rc, (unsigned int)list_count, (unsigned int)list_id); #endif @@ -1150,7 +1150,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) len = snprintf(send_buffer, sizeof(send_buffer), "Data:%d Counter:%d", meta.id, counter); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmAddObjectDmaRequest:%d, id:%u, access:0x%x, " "flags:0x%x, len:%u label:%s\nData:%s\n", ret, meta.id, meta.access, meta.flags, len, meta.label, @@ -1164,7 +1164,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL( wh_Client_NvmAddObjectDmaResponse(client, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmAddObjectDmaResponse:%d, server_rc:%d, meta.len:%u\n", ret, (int)server_rc, (unsigned int)meta.len); #endif @@ -1175,7 +1175,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Client_NvmGetAvailableResponse( client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailableResponse:%d, server_rc:%d, avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, @@ -1189,7 +1189,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Client_NvmGetMetadataResponse( client, &server_rc, &gid, &gaccess, &gflags, &glen, sizeof(glabel), (uint8_t*)glabel)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetMetadataResponse:%d, id:%u, access:0x%x, " "flags:0x%x, len:%u label:%s\n", ret, gid, gaccess, gflags, glen, glabel); @@ -1205,7 +1205,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL( wh_Client_NvmReadDmaResponse(client, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmReadDmaResponse:%d, server_rc:%d id:%u, len:%u " "data:%s\n", ret, (int)server_rc, (unsigned int)gid, (unsigned int)glen, recv_buffer); @@ -1224,7 +1224,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL(wh_Client_NvmListResponse( client, &server_rc, &list_count, &list_id)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmListResponse:%d, server_rc:%d count:%u id:%u\n", ret, (int)server_rc, (unsigned int)list_count, (unsigned int)list_id); #endif @@ -1242,7 +1242,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) wh_Client_NvmDestroyObjectsResponse(client, &server_rc)); WH_TEST_ASSERT_RETURN(server_rc == WH_ERROR_OK); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmDestroyObjectsResponse:%d, server_rc:%d for " "id:%u with count:%u\n", ret, (int)server_rc, (unsigned int)list_id, (unsigned int)list_count); @@ -1264,7 +1264,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Client_NvmCleanupRequest(client)); WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server)); WH_TEST_RETURN_ON_FAIL(wh_Client_NvmCleanupResponse(client, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmCleanupResponse:%d, server_rc:%d\n", ret, (int)server_rc); #endif WH_TEST_ASSERT_RETURN(server_rc == WH_ERROR_OK); @@ -1274,7 +1274,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType) WH_TEST_RETURN_ON_FAIL(wh_Client_NvmGetAvailableResponse( client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailableResponse:%d, server_rc:%d, avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, @@ -1357,7 +1357,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL(ret = wh_Client_Echo(client, send_len, send_buffer, &recv_len, recv_buffer)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client Echo:%d, len:%d, %.*s, expected:%.*s\n", ret, recv_len, recv_len, recv_buffer, send_len, send_buffer); #endif @@ -1374,7 +1374,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailable:%d, server_rc:%d avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, @@ -1411,7 +1411,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) client, id, access, flags, label_len, (uint8_t*)label, len, (uint8_t*)send_buffer, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmAddObject:%d, server_rc:%d\n", ret, (int)server_rc); #endif @@ -1421,7 +1421,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailable:%d, server_rc:%d, avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, @@ -1437,7 +1437,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) &gaccess, &gflags, &glen, sizeof(glabel), (uint8_t*)glabel)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetMetadata:%d, id:%u, access:0x%x, " "flags:0x%x, len:%u label:%s\n", ret, gid, gaccess, gflags, glen, glabel); @@ -1452,7 +1452,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) &server_rc, &rlen, (uint8_t*)recv_buffer)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT( "Client NvmRead:%d, server_rc:%d id:%u, len:%u data:%s\n", ret, (int)server_rc, (unsigned int)gid, (unsigned int)rlen, recv_buffer); @@ -1473,7 +1473,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL( ret = wh_Client_NvmList(client, list_access, list_flags, list_id, &server_rc, &list_count, &list_id)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmList:%d, server_rc:%d count:%u id:%u\n", ret, (int)server_rc, (unsigned int)list_count, (unsigned int)list_id); #endif @@ -1486,7 +1486,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL( ret = wh_Client_NvmDestroyObjects(client, 1, &list_id, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmDestroyObjects:%d, server_rc:%d for " "id:%u with count:%u\n", ret, (int)server_rc, (unsigned int)list_id, (unsigned int)list_count); @@ -1497,7 +1497,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL(ret = wh_Client_NvmGetMetadata(client, list_id, &server_rc, NULL, NULL, NULL, NULL, 0, NULL)); WH_TEST_ASSERT_RETURN(WH_ERROR_NOTFOUND == server_rc); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetMetadata:%d, server_rc:%d count:%u id:%u\n", ret, (int)server_rc, (unsigned int)list_count, (unsigned int)list_id); #endif @@ -1540,7 +1540,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL(ret = wh_Client_NvmAddObjectDma(client, &meta, len, (uint8_t*)send_buffer, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmAddObjectDma:%d, server_rc:%d, meta.len:%u\n", ret, (int)server_rc, meta.len); #endif @@ -1548,7 +1548,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL(ret = wh_Client_NvmGetAvailable(client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailable:%d, server_rc:%d, avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, @@ -1558,7 +1558,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL(ret = wh_Client_NvmGetMetadata(client, meta.id, &server_rc, &gid, &gaccess, &gflags, &glen, sizeof(glabel), (uint8_t*)glabel)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetMetadata:%d, id:%u, access:0x%x, " "flags:0x%x, len:%u label:%s\n", ret, (unsigned int)gid, (unsigned int)gaccess, (unsigned int)gflags, (unsigned int)glen, glabel); @@ -1572,7 +1572,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL( ret = wh_Client_NvmReadDma(client, meta.id, 0, glen, (uint8_t*)recv_buffer, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmReadDma:%d, server_rc:%d id:%u, len:%u " "data:%s\n", ret, (int)server_rc, (unsigned int)gid, (unsigned int)glen, recv_buffer); @@ -1589,7 +1589,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL( ret = wh_Client_NvmList(client, list_access, list_flags, list_id, &server_rc, &list_count, &list_id)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmList:%d, server_rc:%d count:%u id:%u\n", ret, (int)server_rc, (unsigned int)list_count, (unsigned int)list_id); #endif @@ -1605,7 +1605,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_ASSERT_RETURN(server_rc == WH_ERROR_OK); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmDestroyObjects:%d, server_rc:%d for " "id:%u with count:%u\n", ret, (int)server_rc, (unsigned int)list_id, (unsigned int)list_count); @@ -1621,7 +1621,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL(ret = wh_Client_NvmCleanup(client, &server_rc)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmCleanup:%d, server_rc:%d\n", ret, (int)server_rc); #endif WH_TEST_ASSERT_RETURN(server_rc == WH_ERROR_OK); @@ -1630,7 +1630,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg) WH_TEST_RETURN_ON_FAIL(ret = wh_Client_NvmGetAvailable( client, &server_rc, &avail_size, &avail_objects, &reclaim_size, &reclaim_objects)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("Client NvmGetAvailable:%d, server_rc:%d, avail_size:%d " "avail_objects:%d, reclaim_size:%d reclaim_objects:%d\n", ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, diff --git a/test/wh_test_common.h b/test/wh_test_common.h index dcf2d9646..ab5630253 100644 --- a/test/wh_test_common.h +++ b/test/wh_test_common.h @@ -41,7 +41,7 @@ /* Test-specific debug print with function and line info * This internally uses WOLFHSM_CFG_PRINTF for consistency */ -#ifdef WOLFHSM_CFG_TEST_VERBOSE +#ifdef WOLFHSM_CFG_DEBUG_VERBOSE #if !defined(__CCRH__) #define WH_TEST_DEBUG_PRINT(fmt, ...) \ WOLFHSM_CFG_PRINTF("[%s:%d]: " fmt, __func__, __LINE__, ##__VA_ARGS__) diff --git a/test/wh_test_crypto.c b/test/wh_test_crypto.c index 174950f1e..5d07602ae 100644 --- a/test/wh_test_crypto.c +++ b/test/wh_test_crypto.c @@ -100,7 +100,7 @@ static uint16_t* cancelSeqP; WOLFHSM_CFG_ENABLE_SERVER && WOLFHSM_CFG_CANCEL_API */ #endif /* WOLFHSM_CFG_IS_TEST_SERVER */ -#if defined(WOLFHSM_CFG_TEST_VERBOSE) && defined(WOLFHSM_CFG_ENABLE_CLIENT) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) && defined(WOLFHSM_CFG_ENABLE_CLIENT) static int whTest_ShowNvmAvailable(whClientContext* ctx) { int ret = 0; @@ -124,7 +124,7 @@ static int whTest_ShowNvmAvailable(whClientContext* ctx) } return ret; } -#endif /* WOLFHSM_CFG_TEST_VERBOSE && WOLFHSM_CFG_ENABLE_CLIENT */ +#endif /* WOLFHSM_CFG_DEBUG_VERBOSE && WOLFHSM_CFG_ENABLE_CLIENT */ #ifdef WOLFHSM_CFG_ENABLE_CLIENT static int whTest_CryptoRng(whClientContext* ctx, int devId, WC_RNG* rng) @@ -4206,11 +4206,11 @@ int whTest_CryptoClientConfig(whClientConfig* config) WH_ERROR_PRINT("Failed to comm init:%d\n", ret); } -#ifdef WOLFHSM_CFG_TEST_VERBOSE +#ifdef WOLFHSM_CFG_DEBUG_VERBOSE if (ret == 0) { (void)whTest_ShowNvmAvailable(client); } -#endif /* WOLFHSM_CFG_TEST_VERBOSE */ +#endif /* WOLFHSM_CFG_DEBUG_VERBOSE */ /* First crypto test should be of RNG so we can iterate over and test all * devIds before choosing one to run the rest of the tests on */ @@ -4392,11 +4392,11 @@ int whTest_CryptoClientConfig(whClientConfig* config) #endif /* HAVE_DILITHIUM */ -#ifdef WOLFHSM_CFG_TEST_VERBOSE +#ifdef WOLFHSM_CFG_DEBUG_VERBOSE if (ret == 0) { (void)whTest_ShowNvmAvailable(client); } -#endif /* WOLFHSM_CFG_TEST_VERBOSE */ +#endif /* WOLFHSM_CFG_DEBUG_VERBOSE */ /* Clean up used resources */ if (rngInited) { diff --git a/test/wh_test_nvm_flash.c b/test/wh_test_nvm_flash.c index f18a47550..51949501d 100644 --- a/test/wh_test_nvm_flash.c +++ b/test/wh_test_nvm_flash.c @@ -49,30 +49,34 @@ #define FLASH_SECTOR_SIZE (4096) /* 4KB */ #define FLASH_PAGE_SIZE (8) /* 8B */ -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) static void _HexDump(const char* p, size_t data_len) { const size_t bytesPerLine = 16; const unsigned char two_digits = 0x10; const unsigned char* u = (const unsigned char*)p; + + /* Header line - use WH_TEST_DEBUG_PRINT for context */ WH_TEST_DEBUG_PRINT(" HD:%p for %lu bytes\n", p, data_len); if ((p == NULL) || (data_len == 0)) return; + size_t off = 0; for (off = 0; off < data_len; off++) { + /* Use WH_TEST_PRINT for hex data - no prefix */ if ((off % bytesPerLine) == 0) - WH_TEST_DEBUG_PRINT(" "); + WH_TEST_PRINT(" "); if (u[off] < two_digits) { - WH_TEST_DEBUG_PRINT("0%X ", u[off]); + WH_TEST_PRINT("0%X ", u[off]); } else { - WH_TEST_DEBUG_PRINT("%X ", u[off]); + WH_TEST_PRINT("%X ", u[off]); } if ((off % bytesPerLine) == (bytesPerLine - 1)) - WH_TEST_DEBUG_PRINT("\n"); + WH_TEST_PRINT("\n"); } if ((off % bytesPerLine) != 0) - WH_TEST_DEBUG_PRINT("\n"); + WH_TEST_PRINT("\n"); } static void _ShowAvailable(const whNvmCb* cb, void* context) @@ -127,7 +131,7 @@ static void _ShowList(const whNvmCb* cb, void* context) myMetadata.len); while ( (rc == 0) && - ((myMetadata.len - offset) > sizeof(data))) { + ((myMetadata.len - offset) > (whNvmSize)sizeof(data))) { /* Read the data from this object */ rc = cb->Read(context, id, offset, sizeof(data), data); @@ -322,7 +326,7 @@ int whTest_NvmFlashCfg(void* cfg, void* context, const whNvmCb* cb) WH_TEST_RETURN_ON_FAIL(cb->Init(context, cfg)); -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) WH_TEST_DEBUG_PRINT("--Initial NVM contents\n"); _ShowAvailable(cb, context); _ShowList(cb, context); @@ -362,7 +366,7 @@ int whTest_NvmFlashCfg(void* cfg, void* context, const whNvmCb* cb) goto cleanup; } -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) _ShowAvailable(cb, context); _ShowList(cb, context); #endif @@ -375,7 +379,7 @@ int whTest_NvmFlashCfg(void* cfg, void* context, const whNvmCb* cb) goto cleanup; } -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) _ShowAvailable(cb, context); _ShowList(cb, context); #endif @@ -396,7 +400,7 @@ int whTest_NvmFlashCfg(void* cfg, void* context, const whNvmCb* cb) } -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) _ShowAvailable(cb, context); _ShowList(cb, context); #endif @@ -407,7 +411,7 @@ int whTest_NvmFlashCfg(void* cfg, void* context, const whNvmCb* cb) goto cleanup; } -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) _ShowAvailable(cb, context); _ShowList(cb, context); #endif @@ -439,7 +443,7 @@ int whTest_NvmFlashCfg(void* cfg, void* context, const whNvmCb* cb) goto cleanup; } -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) _ShowAvailable(cb, context); _ShowList(cb, context); #endif @@ -452,7 +456,7 @@ int whTest_NvmFlashCfg(void* cfg, void* context, const whNvmCb* cb) goto cleanup; } -#if defined(WOLFHSM_CFG_TEST_VERBOSE) +#if defined(WOLFHSM_CFG_DEBUG_VERBOSE) _ShowAvailable(cb, context); _ShowList(cb, context); #endif diff --git a/test/wh_test_she.c b/test/wh_test_she.c index afd61e4cc..24020d9c1 100644 --- a/test/wh_test_she.c +++ b/test/wh_test_she.c @@ -164,7 +164,7 @@ int whTest_SheClientConfig(whClientConfig* config) WH_TEST_RETURN_ON_FAIL(wh_Client_Init(client, config)); WH_TEST_RETURN_ON_FAIL(wh_Client_CommInit(client, &outClientId, &outServerId)); -#ifdef WOLFHSM_CFG_TEST_VERBOSE +#ifdef WOLFHSM_CFG_DEBUG_VERBOSE { int32_t server_rc = 0; whNvmId avail_objects = 0; @@ -182,7 +182,7 @@ int whTest_SheClientConfig(whClientConfig* config) ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, (int)reclaim_objects); } -#endif /* WOLFHSM_CFG_TEST_VERBOSE */ +#endif /* WOLFHSM_CFG_DEBUG_VERBOSE */ /* generate a new cmac key */ if ((ret = wc_InitRng_ex(rng, NULL, WH_DEV_ID)) != 0) { @@ -391,7 +391,7 @@ int whTest_SheClientConfig(whClientConfig* config) } WH_TEST_PRINT("SHE CMAC SUCCESS\n"); -#ifdef WOLFHSM_CFG_TEST_VERBOSE +#ifdef WOLFHSM_CFG_DEBUG_VERBOSE { int32_t server_rc = 0; whNvmId avail_objects = 0; @@ -409,7 +409,7 @@ int whTest_SheClientConfig(whClientConfig* config) ret, (int)server_rc, (int)avail_size, (int)avail_objects, (int)reclaim_size, (int)reclaim_objects); } -#endif /* WOLFHSM_CFG_TEST_VERBOSE */ +#endif /* WOLFHSM_CFG_DEBUG_VERBOSE */ exit: From 05423bf791adabf8d5aef9021ad8f39c9ec91afd Mon Sep 17 00:00:00 2001 From: jackctj117 Date: Fri, 12 Dec 2025 13:03:48 -0700 Subject: [PATCH 2/2] Removed comments, clang format --- examples/posix/wh_posix_server/wh_posix_server.c | 13 +++++++------ test/wh_test_nvm_flash.c | 6 ++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/posix/wh_posix_server/wh_posix_server.c b/examples/posix/wh_posix_server/wh_posix_server.c index 54b6bd0c8..e1b13153a 100644 --- a/examples/posix/wh_posix_server/wh_posix_server.c +++ b/examples/posix/wh_posix_server/wh_posix_server.c @@ -266,12 +266,13 @@ static int _hardwareCryptoCb(int devId, struct wc_CryptoInfo* info, void* ctx) #endif static void Usage(const char* exeName) { - WOLFHSM_CFG_PRINTF("Usage: %s --key --id --client " - "--nvminit --type \n", - exeName); + WOLFHSM_CFG_PRINTF( + "Usage: %s --key --id --client " + "--nvminit --type \n", + exeName); WOLFHSM_CFG_PRINTF("Example: %s --key key.bin --id 123 --client 456 " - "--nvminit nvm_init.txt --type tcp\n", - exeName); + "--nvminit nvm_init.txt --type tcp\n", + exeName); WOLFHSM_CFG_PRINTF("type: tcp (default), shm, dma\n"); } @@ -282,7 +283,7 @@ int main(int argc, char** argv) const char* keyFilePath = NULL; const char* nvmInitFilePath = NULL; int keyId = WH_KEYID_ERASED; /* Default key ID if none provided */ - int clientId = 12; /* Default client ID if none provided */ + int clientId = 12; /* Default client ID if none provided */ uint8_t memory[WH_POSIX_FLASH_RAM_SIZE] = {0}; whServerConfig s_conf[1]; diff --git a/test/wh_test_nvm_flash.c b/test/wh_test_nvm_flash.c index 51949501d..172e0ac45 100644 --- a/test/wh_test_nvm_flash.c +++ b/test/wh_test_nvm_flash.c @@ -56,14 +56,12 @@ static void _HexDump(const char* p, size_t data_len) const unsigned char two_digits = 0x10; const unsigned char* u = (const unsigned char*)p; - /* Header line - use WH_TEST_DEBUG_PRINT for context */ WH_TEST_DEBUG_PRINT(" HD:%p for %lu bytes\n", p, data_len); if ((p == NULL) || (data_len == 0)) return; size_t off = 0; for (off = 0; off < data_len; off++) { - /* Use WH_TEST_PRINT for hex data - no prefix */ if ((off % bytesPerLine) == 0) WH_TEST_PRINT(" "); if (u[off] < two_digits) { @@ -130,8 +128,8 @@ static void _ShowList(const whNvmCb* cb, void* context) myMetadata.label, myMetadata.access, myMetadata.flags, myMetadata.len); - while ( (rc == 0) && - ((myMetadata.len - offset) > (whNvmSize)sizeof(data))) { + while ((rc == 0) && + ((myMetadata.len - offset) > (whNvmSize)sizeof(data))) { /* Read the data from this object */ rc = cb->Read(context, id, offset, sizeof(data), data);