Skip to content

Commit

Permalink
Fix #1788, Add tests for TBL DumpToBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
nmullane committed Aug 18, 2021
1 parent 1715a32 commit 73fd3a5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
35 changes: 27 additions & 8 deletions modules/tbl/ut-coverage/tbl_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void UtTest_Setup(void)
UT_ADD_TEST(Test_CFE_TBL_ReleaseAddresses);
UT_ADD_TEST(Test_CFE_TBL_Validate);
UT_ADD_TEST(Test_CFE_TBL_Manage);
UT_ADD_TEST(Test_CFE_TBL_DumpToBuffer);
UT_ADD_TEST(Test_CFE_TBL_Update);
UT_ADD_TEST(Test_CFE_TBL_GetStatus);
UT_ADD_TEST(Test_CFE_TBL_GetInfo);
Expand Down Expand Up @@ -2836,6 +2837,32 @@ void Test_CFE_TBL_Manage(void)
CFE_UtAssert_EVENTCOUNT(0);
}

/*
** Test function for dumping to a buffer
*/
void Test_CFE_TBL_DumpToBuffer(void)
{
UtPrintf("Begin Test Dump To Buffer");

/* Test successfully dumping to a buffer */
UT_InitData();
CFE_UtAssert_SUCCESS(CFE_TBL_DumpToBuffer(App1TblHandle1));

/* Test response to an attempt to dump the buffer on a table that the
* application is not allowed to see
*/
UT_InitData();
UT_SetAppID(CFE_ES_APPID_UNDEFINED);
UtAssert_INT32_EQ(CFE_TBL_DumpToBuffer(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS);
CFE_UtAssert_EVENTCOUNT(0);

/* Test response to an attempt to dump the buffer on a bad table handle */
UT_InitData();
UT_SetAppID(CFE_ES_APPID_UNDEFINED);
UtAssert_INT32_EQ(CFE_TBL_DumpToBuffer(CFE_TBL_BAD_TABLE_HANDLE), CFE_TBL_ERR_INVALID_HANDLE);
CFE_UtAssert_EVENTCOUNT(0);
}

/*
** Test function that updates the contents of a table if an update is pending
*/
Expand Down Expand Up @@ -2912,14 +2939,6 @@ void Test_CFE_TBL_GetStatus(void)
UT_SetAppID(CFE_ES_APPID_UNDEFINED);
UtAssert_INT32_EQ(CFE_TBL_GetStatus(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS);
CFE_UtAssert_EVENTCOUNT(0);

/* Test response to an attempt to dump the buffer on a table that the
* application is not allowed to see
*/
UT_InitData();
UT_SetAppID(CFE_ES_APPID_UNDEFINED);
UtAssert_INT32_EQ(CFE_TBL_DumpToBuffer(App1TblHandle1), CFE_TBL_ERR_NO_ACCESS);
CFE_UtAssert_EVENTCOUNT(0);
}

/*
Expand Down
15 changes: 15 additions & 0 deletions modules/tbl/ut-coverage/tbl_UT.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,21 @@ void Test_CFE_TBL_Validate(void);
******************************************************************************/
void Test_CFE_TBL_Manage(void);

/*****************************************************************************/
/**
** \brief Test function for dumping to a buffer
**
** \par Description
** This function tests the function for dumping a table to a buffer
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** This function does not return a value.
******************************************************************************/
void Test_CFE_TBL_DumpToBuffer(void);

/*****************************************************************************/
/**
** \brief Test function that updates the contents of a table if an update
Expand Down

0 comments on commit 73fd3a5

Please sign in to comment.