Skip to content

Commit

Permalink
Fix nasa#2545, migrate TBL, ES, and SB arrays to config list
Browse files Browse the repository at this point in the history
Utilize the compile-time generated list feature of the config module
to replace hardcoded lists of items in ES, SB, and TBL.  In particular
this applies to the ES mempool sizes, SB mempool sizes, and the
spacecraft and processor ID lists in TBL.

Note that the TBL code was not in accordance with coding standards as
it was (by default) compiled out via an #if directive, and thus not
being tested as it should be.  This fixes that, by removing the
conditional compile and always testing the code.
  • Loading branch information
jphickey committed May 29, 2024
1 parent 0cf232e commit 6bda496
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 335 deletions.
2 changes: 1 addition & 1 deletion modules/config/tool/cfeconfig_platformdata_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,4 @@ int main(int argc, char *argv[])
}

return EXIT_SUCCESS;
}
}
47 changes: 16 additions & 31 deletions modules/es/fsw/src/cfe_es_cds_mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,7 @@

#include "cfe_es_module_all.h"

/*****************************************************************************/
/*
** Type Definitions
*/

/*****************************************************************************/
/*
** File Global Data
*/

const size_t CFE_ES_CDSMemPoolDefSize[CFE_ES_CDS_NUM_BLOCK_SIZES] = {
CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15,
CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12,
CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09,
CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06,
CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03,
CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02, CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_01};
#include "cfe_config.h"

/*****************************************************************************/
/*
Expand Down Expand Up @@ -103,27 +87,27 @@ int32 CFE_ES_CDS_PoolCommit(CFE_ES_GenPoolRecord_t *GenPoolRecPtr, size_t Offset
*-----------------------------------------------------------------*/
int32 CFE_ES_CreateCDSPool(size_t CDSPoolSize, size_t StartOffset)
{
CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars;
int32 Status;
size_t SizeCheck;
size_t ActualSize;
CFE_ES_CDS_Instance_t * CDS = &CFE_ES_Global.CDSVars;
int32 Status;
size_t SizeCheck;
CFE_Config_ArrayValue_t CDSMemPoolDefSize;

SizeCheck = CFE_ES_GenPoolCalcMinSize(CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, 1);
ActualSize = CDSPoolSize;
CDSMemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_CDS_MEM_BLOCK_SIZE);
SizeCheck = CFE_ES_GenPoolCalcMinSize(CDSMemPoolDefSize.NumElements, CDSMemPoolDefSize.ElementPtr, 1);

if (ActualSize < SizeCheck)
if (CDSPoolSize < SizeCheck)
{
/* Must be able make Pool verification, block descriptor and at least one of the smallest blocks */
CFE_ES_SysLogWrite_Unsync("%s: Pool size(%lu) too small for one CDS Block, need >=%lu\n", __func__,
(unsigned long)ActualSize, (unsigned long)SizeCheck);
(unsigned long)CDSPoolSize, (unsigned long)SizeCheck);
return CFE_ES_CDS_INVALID_SIZE;
}

Status = CFE_ES_GenPoolInitialize(&CDS->Pool, StartOffset, /* starting offset */
ActualSize, /* total size */
CDSPoolSize, /* total size */
4, /* alignment */
CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, CFE_ES_CDS_PoolRetrieve,
CFE_ES_CDS_PoolCommit);
CDSMemPoolDefSize.NumElements, CDSMemPoolDefSize.ElementPtr,
CFE_ES_CDS_PoolRetrieve, CFE_ES_CDS_PoolCommit);

return Status;
}
Expand Down Expand Up @@ -351,9 +335,10 @@ int32 CFE_ES_CDSBlockRead(void *DataRead, CFE_ES_CDSHandle_t Handle)
*-----------------------------------------------------------------*/
size_t CFE_ES_CDSReqdMinSize(uint32 MaxNumBlocksToSupport)
{
size_t ReqSize;
CFE_Config_ArrayValue_t CDSMemPoolDefSize;

ReqSize = CFE_ES_GenPoolCalcMinSize(CFE_ES_CDS_NUM_BLOCK_SIZES, CFE_ES_CDSMemPoolDefSize, MaxNumBlocksToSupport);
CDSMemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_CDS_MEM_BLOCK_SIZE);

return ReqSize;
return CFE_ES_GenPoolCalcMinSize(CDSMemPoolDefSize.NumElements, CDSMemPoolDefSize.ElementPtr,
MaxNumBlocksToSupport);
}
6 changes: 6 additions & 0 deletions modules/es/fsw/src/cfe_es_generic_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ int32 CFE_ES_GenPoolInitialize(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t StartO
uint32 j;
CFE_ES_GenPoolBucket_t *BucketPtr;

if (NumBlockSizes == 0)
{
CFE_ES_WriteToSysLog("%s: cannot create pool with 0 block sizes\n", __func__);
return CFE_ES_BAD_ARGUMENT;
}

/*
* Note - being an internal/non-public API this does not need to
* check the directly-supplied arguments, it is assumed they are already
Expand Down
45 changes: 26 additions & 19 deletions modules/es/fsw/src/cfe_es_mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
** Includes
*/
#include "cfe_es_module_all.h"
#include "cfe_config.h"

#include <stdio.h>
#include <string.h>
Expand All @@ -53,19 +54,6 @@
} *)0) \
->Align)

/*****************************************************************************/
/*
** Type Definitions
*/

const size_t CFE_ES_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = {
CFE_PLATFORM_ES_MAX_BLOCK_SIZE, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01};

/*****************************************************************************/
/*
** Functions
Expand Down Expand Up @@ -158,7 +146,11 @@ CFE_ES_MemPoolRecord_t *CFE_ES_LocateMemPoolRecordByID(CFE_ES_MemHandle_t PoolID
*-----------------------------------------------------------------*/
CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size)
{
return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, CFE_PLATFORM_ES_POOL_MAX_BUCKETS, &CFE_ES_MemPoolDefSize[0],
CFE_Config_ArrayValue_t MemPoolDefSize;

MemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_MEM_BLOCK_SIZE);

return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, MemPoolDefSize.NumElements, MemPoolDefSize.ElementPtr,
CFE_ES_NO_MUTEX);
}

Expand All @@ -170,7 +162,11 @@ CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, void *MemPtr, si
*-----------------------------------------------------------------*/
CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size)
{
return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, CFE_PLATFORM_ES_POOL_MAX_BUCKETS, &CFE_ES_MemPoolDefSize[0],
CFE_Config_ArrayValue_t MemPoolDefSize;

MemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_MEM_BLOCK_SIZE);

return CFE_ES_PoolCreateEx(PoolID, MemPtr, Size, MemPoolDefSize.NumElements, MemPoolDefSize.ElementPtr,
CFE_ES_USE_MUTEX);
}

Expand All @@ -190,6 +186,7 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_
size_t Alignment;
size_t MinimumSize;
char MutexName[OS_MAX_API_NAME];
CFE_Config_ArrayValue_t MemPoolDefSize;

/* Sanity Check inputs */
if (MemPtr == NULL || PoolID == NULL)
Expand All @@ -198,10 +195,10 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_
}

/* If too many sizes are specified, return an error */
if (NumBlockSizes > CFE_PLATFORM_ES_POOL_MAX_BUCKETS)
if (NumBlockSizes > CFE_MISSION_ES_POOL_MAX_BUCKETS)
{
CFE_ES_WriteToSysLog("%s: Num Block Sizes (%d) greater than max (%d)\n", __func__, (int)NumBlockSizes,
CFE_PLATFORM_ES_POOL_MAX_BUCKETS);
CFE_MISSION_ES_POOL_MAX_BUCKETS);
return CFE_ES_BAD_ARGUMENT;
}

Expand All @@ -210,10 +207,20 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_
*/
if (BlockSizes == NULL)
{
BlockSizes = CFE_ES_MemPoolDefSize;
MemPoolDefSize = CFE_Config_GetArrayValue(CFE_CONFIGID_PLATFORM_ES_MEM_BLOCK_SIZE);

BlockSizes = MemPoolDefSize.ElementPtr;
if (NumBlockSizes == 0)
{
NumBlockSizes = CFE_PLATFORM_ES_POOL_MAX_BUCKETS;
NumBlockSizes = MemPoolDefSize.NumElements;
}

/* If too many sizes are specified, return an error */
if (NumBlockSizes > MemPoolDefSize.NumElements)
{
CFE_ES_WriteToSysLog("%s: Num Block Sizes (%d) greater than max (%lu)\n", __func__, (int)NumBlockSizes,
(unsigned long)MemPoolDefSize.NumElements);
return CFE_ES_BAD_ARGUMENT;
}
}

Expand Down
135 changes: 2 additions & 133 deletions modules/es/fsw/src/cfe_es_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@
/*
** Intermediate ES Memory Pool Block Sizes
*/
#if CFE_PLATFORM_ES_MAX_BLOCK_SIZE < CFE_MISSION_SB_MAX_SB_MSG_SIZE
#error CFE_PLATFORM_ES_MAX_BLOCK_SIZE must be equal to or larger than CFE_MISSION_SB_MAX_SB_MSG_SIZE!
#if CFE_MISSION_ES_POOL_MAX_BUCKETS < CFE_PLATFORM_ES_POOL_MAX_BUCKETS
#error CFE_MISSION_ES_POOL_MAX_BUCKETS must be equal to or larger than CFE_PLATFORM_ES_POOL_MAX_BUCKETS!
#endif

#if CFE_PLATFORM_ES_MAX_BLOCK_SIZE < CFE_PLATFORM_TBL_MAX_SNGL_TABLE_SIZE
Expand All @@ -178,137 +178,6 @@
#error CFE_PLATFORM_ES_MAX_BLOCK_SIZE must be equal to or larger than CFE_PLATFORM_TBL_MAX_DBL_TABLE_SIZE!
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15 > CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15 must be less than CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16
#endif

#if CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16 > CFE_PLATFORM_ES_MAX_BLOCK_SIZE
#error CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16 must be less than CFE_PLATFORM_ES_MAX_BLOCK_SIZE
#endif

/*
** Intermediate ES Critical Data Store Memory Pool Block Sizes
*/
#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_01 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_01 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_02 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_03 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_04 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_05 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_06 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_07 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_08 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_09 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_10 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_11 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_12 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_13 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_14 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15 > CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_15 must be less than CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16
#endif

#if CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16 > CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE
#error CFE_PLATFORM_ES_CDS_MEM_BLOCK_SIZE_16 must be less than CFE_PLATFORM_ES_CDS_MAX_BLOCK_SIZE
#endif

/*
** Validate task stack size...
*/
Expand Down
24 changes: 24 additions & 0 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ typedef struct
CFE_ES_GMP_DirectBuffer_t UT_MemPoolDirectBuffer;
CFE_ES_GMP_IndirectBuffer_t UT_MemPoolIndirectBuffer;

/*
* Memory pool block sizes used for unit test
* The platform config values are not used for UT as the test cases
* require certain sizes. A large max block and small min block
* are needed for testing size thresholds when creating pools.
*/
static const size_t UT_MemPoolSizeArray[5] = {131072, 512, 128, 32, 8};
static const CFE_Config_ArrayValue_t UT_MemPoolAV = {5, UT_MemPoolSizeArray};

/* Create a startup script buffer for a maximum of 5 lines * 80 chars/line */
char StartupScript[MAX_STARTUP_SCRIPT];

Expand Down Expand Up @@ -624,6 +633,12 @@ static int32 ES_UT_SetAppStateHook(void *UserObj, int32 StubRetcode, uint32 Call
return StubRetcode;
}

static void UT_ArrayConfigHandler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
CFE_Config_ArrayValue_t Val = *((const CFE_Config_ArrayValue_t *)UserObj);
UT_Stub_SetReturnValue(FuncKey, Val);
}

void UtTest_Setup(void)
{
UT_Init("es");
Expand Down Expand Up @@ -674,10 +689,19 @@ void ES_ResetUnitTest(void)
* so it must be re-initialized here every time CFE_ES_Global is reset.
*/
CFE_ES_Global.ResetDataPtr = ES_UT_PersistentResetData;

UT_SetHandlerFunction(UT_KEY(CFE_Config_GetArrayValue), UT_ArrayConfigHandler, (void *)&UT_MemPoolAV);

} /* end ES_ResetUnitTest() */

void TestInit(void)
{
size_t SizeValue;
CFE_Config_ArrayValue_t UTAV = {1, &SizeValue};

SizeValue = 1;
UT_SetHandlerFunction(UT_KEY(CFE_Config_GetArrayValue), UT_ArrayConfigHandler, &UTAV);

UtPrintf("Begin Test Init");

UT_SetCDSSize(128 * 1024);
Expand Down
Loading

0 comments on commit 6bda496

Please sign in to comment.