Skip to content

Commit

Permalink
Merge pull request #2377 from avan989:1930-Null-Pointer-Coverage-Test
Browse files Browse the repository at this point in the history
Fix #1930, add code coverage for null check
  • Loading branch information
dzbaker committed Oct 23, 2023
2 parents 9de5db7 + 9a16fd3 commit 3822447
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
33 changes: 33 additions & 0 deletions modules/es/fsw/src/cfe_es_generic_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,39 @@ int32 CFE_ES_GenPoolInitialize(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t StartO
*/
int32 CFE_ES_GenPoolGetBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t *BlockOffsetPtr, size_t ReqSize);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Create a new block of the given size.
*
* \note Internal helper routine only, not part of API.
*
* \param[inout] PoolRecPtr Pointer to pool structure
* \param[in] BucketId Bucket ID
* \param[in] NewSize Size of block
* \param[out] BlockOffsetPtr Location to output new block offset
*
* \return #CFE_SUCCESS, or error code #CFE_ES_BUFFER_NOT_IN_POOL #CFE_ES_ERR_MEM_BLOCK_SIZE
* \ref CFEReturnCodes
*/
int32 CFE_ES_GenPoolCreatePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, size_t NewSize,
size_t *BlockOffsetPtr);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Find and re-allocate a previously returned block
*
* \note Internal helper routine only, not part of API.
*
* \param[inout] PoolRecPtr Pointer to pool structure
* \param[in] BucketId Bucket ID
* \param[in] NewSize Size of block
* \param[out] BlockOffsetPtr Location to output new block offset
*
* \return #CFE_SUCCESS, or error code #CFE_ES_BUFFER_NOT_IN_POOL \ref CFEReturnCodes
*/
int32 CFE_ES_GenPoolRecyclePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, size_t NewSize,
size_t *BlockOffsetPtr);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Returns a block to the pool
Expand Down
10 changes: 10 additions & 0 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,16 @@ void TestGenericPool(void)
/* Reset the structure so it will rebuild */
Pool1.TailPosition = 0;
CFE_UtAssert_SUCCESS(CFE_ES_GenPoolRebuild(&Pool1));

/* Branch coverage for no buffer in pool */
ES_ResetUnitTest();
UtAssert_INT32_EQ(CFE_ES_GenPoolCreatePoolBlock(&Pool1, 0, Pool1.Buckets[0].BlockSize, &Offset1),
CFE_ES_BUFFER_NOT_IN_POOL);

ES_ResetUnitTest();
UtAssert_INT32_EQ(CFE_ES_GenPoolRecyclePoolBlock(&Pool1, 0, Pool1.Buckets[0].BlockSize, &Offset1),
CFE_ES_BUFFER_NOT_IN_POOL);

}

void TestTask(void)
Expand Down

0 comments on commit 3822447

Please sign in to comment.