Skip to content

Commit

Permalink
Merge pull request #1656 from skliper/fix1655_tbl_ut_buffer
Browse files Browse the repository at this point in the history
Fix #1655, Size unit test table load buffer based on config
  • Loading branch information
astrogeco authored Jul 7, 2021
2 parents 063b4d8 + bbbf414 commit fe8fced
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions modules/tbl/ut-coverage/tbl_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ CFE_TBL_Handle_t ArrayOfHandles[2];
#define UT_TBL_APPID_3 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 3))
#define UT_TBL_APPID_10 CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 10))

/* Set up buffer to provide to CFE_ES_GetPoolBuf handler */
#define UT_TBL_LOAD_BUFFER_SIZE \
(CFE_PLATFORM_TBL_MAX_SIMULTANEOUS_LOADS * (CFE_PLATFORM_TBL_MAX_SNGL_TABLE_SIZE + sizeof(CFE_ES_PoolAlign_t)))
static union
{
CFE_ES_PoolAlign_t Align;
uint8 Bytes[UT_TBL_LOAD_BUFFER_SIZE];
} UT_TBL_LoadBuffer;

void * Tbl1Ptr = NULL;
void * Tbl2Ptr = NULL;
void **ArrayOfPtrsToTblPtrs[2];
Expand Down Expand Up @@ -1350,7 +1359,13 @@ void Test_CFE_TBL_HousekeepingCmd(void)
*/
void Test_CFE_TBL_ApiInit(void)
{

UT_ResetCDS();

/* Provide a big enough pool for the load buffers */
UT_ResetState(UT_KEY(CFE_ES_GetPoolBuf));
UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_TBL_LoadBuffer, sizeof(UT_TBL_LoadBuffer), false);

CFE_TBL_EarlyInit();
CFE_TBL_Global.TableTaskAppId = UT_TBL_APPID_10;
}
Expand Down Expand Up @@ -3163,12 +3178,16 @@ void Test_CFE_TBL_Internal(void)
UT_InitData();
UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDSEx), 1, CFE_ES_CDS_ALREADY_EXISTS);
UT_SetDeferredRetcode(UT_KEY(CFE_ES_RestoreFromCDS), 1, CFE_ES_CDS_BLOCK_CRC_ERR);
UT_ResetState(UT_KEY(CFE_ES_GetPoolBuf));
UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_TBL_LoadBuffer, sizeof(UT_TBL_LoadBuffer), false);
CFE_UtAssert_SUCCESS(CFE_TBL_EarlyInit());
CFE_UtAssert_EVENTCOUNT(0);

/* Test CFE_TBL_EarlyInit response when no CDS is available */
UT_InitData();
UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDSEx), 1, CFE_ES_NOT_IMPLEMENTED);
UT_ResetState(UT_KEY(CFE_ES_GetPoolBuf));
UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_TBL_LoadBuffer, sizeof(UT_TBL_LoadBuffer), false);
CFE_UtAssert_SUCCESS(CFE_TBL_EarlyInit());
CFE_UtAssert_EVENTCOUNT(0);

Expand All @@ -3177,13 +3196,17 @@ void Test_CFE_TBL_Internal(void)
*/
UT_InitData();
UT_SetDeferredRetcode(UT_KEY(CFE_ES_CopyToCDS), 1, CFE_ES_ERR_RESOURCEID_NOT_VALID);
UT_ResetState(UT_KEY(CFE_ES_GetPoolBuf));
UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_TBL_LoadBuffer, sizeof(UT_TBL_LoadBuffer), false);
CFE_UtAssert_SUCCESS(CFE_TBL_EarlyInit());
CFE_UtAssert_EVENTCOUNT(0);

/* Reset, then register tables for subsequent tests */
/* a. Reset tables */
UT_InitData();
UT_SetAppID(UT_TBL_APPID_1);
UT_ResetState(UT_KEY(CFE_ES_GetPoolBuf));
UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_TBL_LoadBuffer, sizeof(UT_TBL_LoadBuffer), false);
CFE_UtAssert_SUCCESS(CFE_TBL_EarlyInit());

/* b. Register critical single buffered table */
Expand Down Expand Up @@ -3418,6 +3441,8 @@ void Test_CFE_TBL_Internal(void)
*/
UT_InitData();
UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDSEx), 1, CFE_ES_CDS_ALREADY_EXISTS);
UT_ResetState(UT_KEY(CFE_ES_GetPoolBuf));
UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_TBL_LoadBuffer, sizeof(UT_TBL_LoadBuffer), false);
CFE_UtAssert_SUCCESS(CFE_TBL_EarlyInit());
CFE_UtAssert_EVENTCOUNT(0);

Expand Down

0 comments on commit fe8fced

Please sign in to comment.