Skip to content

Commit

Permalink
fix nasa#1055 - CFE_SB_ReceiveBuffer stub returns timeout or empty if…
Browse files Browse the repository at this point in the history
… no buffer
  • Loading branch information
CDKnightNASA committed Jan 5, 2021
1 parent 56397a3 commit 32381af
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions fsw/cfe-core/ut-stubs/ut_sb_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,16 @@ int32 CFE_SB_RcvMsg(CFE_SB_Buffer_t **BufPtr,
**
** \par Description
** This function is used to mimic the response of the cFE SB function
** CFE_SB_ReceiveBuffer. By default it will return the TIMEOUT error response,
** unless the test setup sequence has indicated otherwise.
** CFE_SB_ReceiveBuffer.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns CFE_SUCCESS or overridden unit test value
** If the return value has not been overridden, returns CFE_SUCCESS if there
** is a buffer defined by UT_SetDataBuffer. If no buffer was defined,
** either CFE_SB_TIME_OUT (if the TimeOut parameter is > 0) or CFE_SB_NO_MESSAGE
** is returned. If the return value has been overridden,
**
******************************************************************************/
int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr,
Expand All @@ -471,7 +473,18 @@ int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr,

if (status >= 0)
{
UT_Stub_CopyToLocal(UT_KEY(CFE_SB_ReceiveBuffer), (uint8*)BufPtr, sizeof(*BufPtr));
if(UT_Stub_CopyToLocal(UT_KEY(CFE_SB_ReceiveBuffer), (uint8*)BufPtr, sizeof(*BufPtr)) <= 0)
{
/* no buffer provided, return a non-success return code */
if (TimeOut == CFE_SB_PEND_FOREVER)
{
return CFE_SB_NO_MESSAGE;
}
else
{
return CFE_SB_TIME_OUT;
}
}
}

return status;
Expand Down

0 comments on commit 32381af

Please sign in to comment.