Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Jul 18, 2024
1 parent 40aeed1 commit 8835727
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions fsw/src/md_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/md_dwell_tbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/md_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions fsw/src/md_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 7 additions & 5 deletions unit-test/md_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions unit-test/md_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions unit-test/stubs/md_utils_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 8835727

Please sign in to comment.