From 883572736717a54ab50e858fe2d726cd31f1b2a2 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Thu, 18 Jul 2024 08:59:48 +0200 Subject: [PATCH] test --- fsw/src/md_app.c | 4 ++-- fsw/src/md_dwell_tbl.c | 6 +++--- fsw/src/md_utils.c | 6 +++--- fsw/src/md_utils.h | 6 +++--- unit-test/md_app_tests.c | 12 +++++++----- unit-test/md_utils_tests.c | 8 ++++---- unit-test/stubs/md_utils_stubs.c | 6 +++--- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/fsw/src/md_app.c b/fsw/src/md_app.c index beaf7d7..21c93b8 100644 --- a/fsw/src/md_app.c +++ b/fsw/src/md_app.c @@ -176,8 +176,8 @@ CFE_Status_t MD_AppInit(void) */ CFE_Status_t Status = CFE_SUCCESS; - MD_AppData.CmdCounter = 0; - MD_AppData.ErrCounter = 0; + /* Zero out the global data structure */ + memset(&MD_AppData, 0, sizeof(MD_AppData)); /* Initialize local control structures */ MD_InitControlStructures(); diff --git a/fsw/src/md_dwell_tbl.c b/fsw/src/md_dwell_tbl.c index 37a86a9..66ede4d 100644 --- a/fsw/src/md_dwell_tbl.c +++ b/fsw/src/md_dwell_tbl.c @@ -343,7 +343,7 @@ CFE_Status_t MD_UpdateTableEnabledField(uint16 TableIndex, uint16 FieldValue) if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(MD_UPDATE_TBL_EN_ERR_EID, CFE_EVS_EventType_ERROR, - "MD_UpdateTableEnabledField, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", + "%s, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", __func__ (int)TableIndex, (unsigned int)Status); } else @@ -375,7 +375,7 @@ CFE_Status_t MD_UpdateTableDwellEntry(uint16 TableIndex, uint16 EntryIndex, uint if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(MD_UPDATE_TBL_DWELL_ERR_EID, CFE_EVS_EventType_ERROR, - "MD_UpdateTableDwellEntry, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", + "%s, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", __func__ (int)TableIndex, (unsigned int)Status); } else @@ -421,7 +421,7 @@ CFE_Status_t MD_UpdateTableSignature(uint16 TableIndex, char NewSignature[MD_SIG if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(MD_UPDATE_TBL_SIG_ERR_EID, CFE_EVS_EventType_ERROR, - "MD_UpdateTableSignature, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", (int)TableIndex, + "%s, TableIndex %d: CFE_TBL_GetAddress Returned 0x%08x", (int)TableIndex, __func__ (unsigned int)Status); } else diff --git a/fsw/src/md_utils.c b/fsw/src/md_utils.c index 62e174e..ae88c3a 100644 --- a/fsw/src/md_utils.c +++ b/fsw/src/md_utils.c @@ -101,7 +101,7 @@ bool MD_ValidEntryId(uint16 EntryId) /******************************************************************************/ -bool MD_ValidAddrRange(cpuaddr Addr, uint32 Size) +bool MD_ValidAddrRange(cpuaddr Addr, size_t Size) { bool IsValid = false; @@ -142,7 +142,7 @@ bool MD_ValidFieldLength(uint16 FieldLength) /******************************************************************************/ -bool MD_Verify32Aligned(cpuaddr Address, uint32 Size) +bool MD_Verify32Aligned(cpuaddr Address, size_t Size) { bool IsAligned; @@ -164,7 +164,7 @@ bool MD_Verify32Aligned(cpuaddr Address, uint32 Size) /******************************************************************************/ -bool MD_Verify16Aligned(cpuaddr Address, uint32 Size) +bool MD_Verify16Aligned(cpuaddr Address, size_t Size) { bool IsAligned; diff --git a/fsw/src/md_utils.h b/fsw/src/md_utils.h index 00a36e8..6765575 100644 --- a/fsw/src/md_utils.h +++ b/fsw/src/md_utils.h @@ -96,7 +96,7 @@ bool MD_ValidEntryId(uint16 EntryId); * \retval true Address is valid * \retval false Address is not valid */ -bool MD_ValidAddrRange(cpuaddr Addr, uint32 Size); +bool MD_ValidAddrRange(cpuaddr Addr, size_t Size); /** * \brief Validate Table ID @@ -156,7 +156,7 @@ bool MD_ValidFieldLength(uint16 FieldLength); * * \sa #MD_Verify16Aligned */ -bool MD_Verify32Aligned(cpuaddr Address, uint32 Size); +bool MD_Verify32Aligned(cpuaddr Address, size_t Size); /** * \brief Verify 16 bit alignment @@ -178,7 +178,7 @@ bool MD_Verify32Aligned(cpuaddr Address, uint32 Size); * * \sa #MD_Verify32Aligned */ -bool MD_Verify16Aligned(cpuaddr Address, uint32 Size); +bool MD_Verify16Aligned(cpuaddr Address, size_t Size); /** * \brief Resolve symbolic address diff --git a/unit-test/md_app_tests.c b/unit-test/md_app_tests.c index 6599753..12a91f4 100644 --- a/unit-test/md_app_tests.c +++ b/unit-test/md_app_tests.c @@ -868,7 +868,7 @@ void MD_InitTableServices_Test_TblRecoveredNotValid(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_TBL_INFO_RECOVERED_TBL); /* Set to fail condition "GetAddressResult != CFE_TBL_INFO_UPDATED", to - prevent a core dump by assigning MD_LoadTablePtr, and to make MD_TableValidateionFunc() return non-success */ + prevent a core dump by assigning MD_LoadTablePtr, and to make MD_TableValidationFunc() return non-success */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); MD_AppData.MD_DwellTables[0].Enabled = MD_DWELL_STREAM_DISABLED; @@ -927,7 +927,7 @@ void MD_InitTableServices_Test_DwellStreamEnabled(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_TBL_INFO_RECOVERED_TBL); /* Set to fail condition "GetAddressResult != CFE_TBL_INFO_UPDATED", to - prevent a core dump by assigning MD_LoadTablePtr, and to make MD_TableValidateionFunc() return non-success */ + prevent a core dump by assigning MD_LoadTablePtr, and to make MD_TableValidationFunc() return non-success */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); LoadTblPtr->Enabled = MD_DWELL_STREAM_ENABLED; @@ -986,7 +986,7 @@ void MD_InitTableServices_Test_TblNotRecovered(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_TBL_INFO_RECOVERED_TBL); /* Set to fail condition "GetAddressResult != CFE_TBL_INFO_UPDATED", to - prevent a core dump by assigning MD_LoadTablePtr, and to make MD_TableValidateionFunc() return non-success */ + prevent a core dump by assigning MD_LoadTablePtr, and to make MD_TableValidationFunc() return non-success */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); LoadTblPtr->Enabled = MD_DWELL_STREAM_ENABLED; @@ -1160,6 +1160,7 @@ void MD_ManageDwellTable_Test_UpdatePendingDwellStreamEnabled(void) uint8 TblIndex = 0; MD_DwellTableLoad_t LoadTbl; MD_DwellTableLoad_t *LoadTblPtr = &LoadTbl; + uint8 call_count_MD_StartDwellStream; /* Set to satisfy condition "Status == CFE_TBL_INFO_UPDATE_PENDING" */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetStatus), 1, CFE_TBL_INFO_UPDATE_PENDING); @@ -1183,7 +1184,7 @@ void MD_ManageDwellTable_Test_UpdatePendingDwellStreamEnabled(void) UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", call_count_CFE_EVS_SendEvent); - uint8 call_count_MD_StartDwellStream = UT_GetStubCount(UT_KEY(MD_StartDwellStream)); + call_count_MD_StartDwellStream = UT_GetStubCount(UT_KEY(MD_StartDwellStream)); UtAssert_INT32_EQ(call_count_MD_StartDwellStream, 1); } @@ -1193,6 +1194,7 @@ void MD_ManageDwellTable_Test_UpdatePendingDwellStreamDisabled(void) uint8 TblIndex = 0; MD_DwellTableLoad_t LoadTbl; MD_DwellTableLoad_t *LoadTblPtr = &LoadTbl; + uint8 call_count_MD_StartDwellStream; /* Set to satisfy condition "Status == CFE_TBL_INFO_UPDATE_PENDING" */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_GetStatus), 1, CFE_TBL_INFO_UPDATE_PENDING); @@ -1218,7 +1220,7 @@ void MD_ManageDwellTable_Test_UpdatePendingDwellStreamDisabled(void) UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", call_count_CFE_EVS_SendEvent); - uint8 call_count_MD_StartDwellStream = UT_GetStubCount(UT_KEY(MD_StartDwellStream)); + call_count_MD_StartDwellStream = UT_GetStubCount(UT_KEY(MD_StartDwellStream)); UtAssert_INT32_EQ(call_count_MD_StartDwellStream, 0); } diff --git a/unit-test/md_utils_tests.c b/unit-test/md_utils_tests.c index 55cf49a..ac15bd1 100644 --- a/unit-test/md_utils_tests.c +++ b/unit-test/md_utils_tests.c @@ -203,7 +203,7 @@ void MD_ValidAddrRange_Test_Valid(void) { bool Result; cpuaddr Addr = 1; - uint32 Size = 1; + size_t Size = 1; /* Execute the function being tested */ Result = MD_ValidAddrRange(Addr, Size); @@ -221,7 +221,7 @@ void MD_ValidAddrRange_Test_Invalid(void) { bool Result; cpuaddr Addr = 1; - uint32 Size = 1; + size_t Size = 1; /* Set to reach "IsValid = false" */ UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemValidateRange), 1, -1); @@ -378,7 +378,7 @@ void MD_Verify32Aligned_Test(void) { bool Result; cpuaddr Addr; - uint32 Size; + size_t Size; Addr = 0; /* address is aligned */ Size = 4; /* size is aligned */ @@ -412,7 +412,7 @@ void MD_Verify16Aligned_Test(void) { bool Result; cpuaddr Addr; - uint32 Size; + size_t Size; Addr = 0; /* address is aligned */ Size = 4; /* size is aligned */ diff --git a/unit-test/stubs/md_utils_stubs.c b/unit-test/stubs/md_utils_stubs.c index 61eee21..1e61279 100644 --- a/unit-test/stubs/md_utils_stubs.c +++ b/unit-test/stubs/md_utils_stubs.c @@ -48,7 +48,7 @@ bool MD_ValidEntryId(uint16 EntryId) return UT_DEFAULT_IMPL(MD_ValidEntryId) != 0; } -bool MD_ValidAddrRange(cpuaddr Addr, uint32 Size) +bool MD_ValidAddrRange(cpuaddr Addr, size_t Size) { UT_Stub_RegisterContextGenericArg(UT_KEY(MD_ValidAddrRange), Addr); UT_Stub_RegisterContextGenericArg(UT_KEY(MD_ValidAddrRange), Size); @@ -67,14 +67,14 @@ bool MD_ValidFieldLength(uint16 FieldLength) return UT_DEFAULT_IMPL(MD_ValidFieldLength) != 0; } -bool MD_Verify32Aligned(cpuaddr Address, uint32 Size) +bool MD_Verify32Aligned(cpuaddr Address, size_t Size) { UT_Stub_RegisterContextGenericArg(UT_KEY(MD_Verify32Aligned), Address); UT_Stub_RegisterContextGenericArg(UT_KEY(MD_Verify32Aligned), Size); return UT_DEFAULT_IMPL(MD_Verify32Aligned) != 0; } -bool MD_Verify16Aligned(cpuaddr Address, uint32 Size) +bool MD_Verify16Aligned(cpuaddr Address, size_t Size) { UT_Stub_RegisterContextGenericArg(UT_KEY(MD_Verify16Aligned), Address); UT_Stub_RegisterContextGenericArg(UT_KEY(MD_Verify16Aligned), Size);