Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2067, Only increment SB InternalErrorCounter on errors #2082

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/sb/fsw/src/cfe_sb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1988,8 +1988,8 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe
CFE_SB_DecrBufUseCnt(BufDscPtr);
}

/* Before unlocking, check the PendingEventID and increment relevant error counter */
if (Status != CFE_SUCCESS)
/* Before unlocking, increment relevant error counter if needed */
if (Status != CFE_SUCCESS && Status != CFE_SB_NO_MESSAGE && Status != CFE_SB_TIME_OUT)
{
if (PendingEventID == CFE_SB_RCV_BAD_ARG_EID || PendingEventID == CFE_SB_BAD_PIPEID_EID)
{
Expand Down
13 changes: 13 additions & 0 deletions modules/sb/ut-coverage/sb_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,7 @@ void Test_ReceiveBuffer_InvalidPipeId(void)

CFE_UtAssert_EVENTCOUNT(1);
CFE_UtAssert_EVENTSENT(CFE_SB_BAD_PIPEID_EID);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter, 1);
UT_ClearEventHistory();

/*
Expand All @@ -3683,6 +3684,8 @@ void Test_ReceiveBuffer_InvalidPipeId(void)
UT_SetHandlerFunction(UT_KEY(OS_QueueGet), SB_UT_PipeIdModifyHandler, PipeDscPtr);
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&SBBufPtr, PipeId, CFE_SB_POLL), CFE_SB_PIPE_RD_ERR);
CFE_UtAssert_EVENTSENT(CFE_SB_BAD_PIPEID_EID);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter, 2);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter, 0);
UT_SetHandlerFunction(UT_KEY(OS_QueueGet), NULL, NULL);

/* restore the PipeID so it can be deleted */
Expand All @@ -3709,6 +3712,8 @@ void Test_ReceiveBuffer_InvalidTimeout(void)
CFE_UtAssert_EVENTCOUNT(2);

CFE_UtAssert_EVENTSENT(CFE_SB_RCV_BAD_ARG_EID);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter, 1);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter, 0);

CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId));

Expand All @@ -3730,6 +3735,8 @@ void Test_ReceiveBuffer_Poll(void)
CFE_UtAssert_EVENTCOUNT(1);

CFE_UtAssert_EVENTSENT(CFE_SB_PIPE_ADDED_EID);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter, 0);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter, 0);

CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId));

Expand All @@ -3753,6 +3760,8 @@ void Test_ReceiveBuffer_Timeout(void)
CFE_UtAssert_EVENTCOUNT(1);

CFE_UtAssert_EVENTSENT(CFE_SB_PIPE_ADDED_EID);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter, 0);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter, 0);

CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId));

Expand Down Expand Up @@ -3782,6 +3791,8 @@ void Test_ReceiveBuffer_PipeReadError(void)
UT_SetHandlerFunction(UT_KEY(OS_QueueGet), SB_UT_QueueGetHandler, NULL);
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&SBBufPtr, PipeId, CFE_SB_PEND_FOREVER), CFE_SB_PIPE_RD_ERR);
UT_SetHandlerFunction(UT_KEY(OS_QueueGet), NULL, NULL);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter, 0);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter, 3);

CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId));

Expand Down Expand Up @@ -3820,6 +3831,8 @@ void Test_ReceiveBuffer_PendForever(void)
/* Ensure that calling a second time with no message clears the LastBuffer reference */
UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&SBBufPtr, PipeId, CFE_SB_PEND_FOREVER), CFE_SB_NO_MESSAGE);
UtAssert_NULL(PipeDscPtr->LastBuffer);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.MsgReceiveErrorCounter, 0);
UtAssert_UINT8_EQ(CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter, 0);

CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId));

Expand Down