Skip to content

Commit

Permalink
Merge pull request #1785 from zanzaben/fix1776__fix_mem_leak
Browse files Browse the repository at this point in the history
Fixes #1776, #1770, Stop memory leak & add cds size test.
  • Loading branch information
astrogeco authored Aug 13, 2021
2 parents 471b94d + d767a4e commit d6d1c68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modules/cfe_testcase/src/es_cds_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ void TestRegisterCDS(void)
CFE_ES_CDSHandle_t CDSHandlePtr;
CFE_ES_CDSHandle_t CDSHandlePtr2;

size_t BlockSize = 10;
const char * Name = "CDS_Test";
const char * LongName = "VERY_LONG_NAME_CDS_Test";
size_t BlockSize = 10;
size_t BlockSize2 = 15;
const char * Name = "CDS_Test";
const char * LongName = "VERY_LONG_NAME_CDS_Test";
CFE_Status_t status;

UtPrintf("Testing: CFE_ES_RegisterCDS");

status = CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, Name);
status = CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize2, Name);

if (status == CFE_ES_CDS_ALREADY_EXISTS)
{
Expand All @@ -56,7 +57,8 @@ void TestRegisterCDS(void)
UtAssert_INT32_EQ(status, CFE_SUCCESS);
}

UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr2, BlockSize, Name), CFE_ES_CDS_ALREADY_EXISTS);
UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr2, BlockSize2, Name), CFE_ES_CDS_ALREADY_EXISTS);
UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr2, BlockSize, Name), CFE_SUCCESS);

UtAssert_INT32_EQ(CFE_ES_RegisterCDS(NULL, BlockSize, Name), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr, 0, Name), CFE_ES_CDS_INVALID_SIZE);
Expand Down
2 changes: 2 additions & 0 deletions modules/cfe_testcase/src/es_mempool_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ void TestMemPoolCreate(void)
UtAssert_INT32_EQ(CFE_ES_PoolCreateNoSem(NULL, Pool, sizeof(Pool)), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_PoolCreateNoSem(&PoolID, NULL, sizeof(Pool)), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_PoolCreateNoSem(&PoolID, Pool, 0), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_PoolDelete(PoolID), CFE_SUCCESS);

UtAssert_INT32_EQ(CFE_ES_PoolCreate(&PoolID, Pool, sizeof(Pool)), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_PoolCreate(NULL, Pool, sizeof(Pool)), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_PoolCreate(&PoolID, NULL, sizeof(Pool)), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_PoolCreate(&PoolID, Pool, 0), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_PoolDelete(PoolID), CFE_SUCCESS);

UtAssert_INT32_EQ(CFE_ES_PoolCreateEx(&PoolID, Pool, sizeof(Pool), 0, NULL, CFE_ES_NO_MUTEX), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_PoolCreateEx(NULL, Pool, sizeof(Pool), 0, NULL, CFE_ES_NO_MUTEX), CFE_ES_BAD_ARGUMENT);
Expand Down

0 comments on commit d6d1c68

Please sign in to comment.