Skip to content

Commit

Permalink
Merge pull request $2633 from jphickey:fix-2625-tbl-validate
Browse files Browse the repository at this point in the history
Fix #2625, add initialization of table indices
  • Loading branch information
dzbaker committed Jan 31, 2025
2 parents 3b4135a + 3091b2a commit e91b7c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
7 changes: 5 additions & 2 deletions modules/tbl/fsw/src/cfe_tbl_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ int32 CFE_TBL_TaskInit(void)
/*
** Task startup event message
*/
CFE_Config_GetVersionString(VersionString, CFE_CFG_MAX_VERSION_STR_LEN, "cFE",
CFE_SRC_VERSION, CFE_BUILD_CODENAME, CFE_LAST_OFFICIAL);
CFE_Config_GetVersionString(VersionString, CFE_CFG_MAX_VERSION_STR_LEN, "cFE", CFE_SRC_VERSION, CFE_BUILD_CODENAME,
CFE_LAST_OFFICIAL);
Status = CFE_EVS_SendEvent(CFE_TBL_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "cFE TBL Initialized: %s",
VersionString);

Expand Down Expand Up @@ -199,4 +199,7 @@ void CFE_TBL_InitData(void)
/* Message ID is set when sent, so OK as 0 here */
CFE_MSG_Init(CFE_MSG_PTR(CFE_TBL_Global.NotifyMsg.CommandHeader), CFE_SB_INVALID_MSG_ID,
sizeof(CFE_TBL_Global.NotifyMsg));

CFE_TBL_Global.LastValidationResultId = CFE_ResourceId_FromInteger(CFE_TBL_VALRESULTID_BASE);
CFE_TBL_Global.LastDumpCtrlBlockId = CFE_ResourceId_FromInteger(CFE_TBL_DUMPCTRLID_BASE);
}
19 changes: 16 additions & 3 deletions modules/tbl/ut-coverage/tbl_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ void Test_CFE_TBL_ValidateCmd(void)
ValidateCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_ACTIVE;
CFE_TBL_Global.Registry[0].Buffers[CFE_TBL_Global.Registry[0].ActiveBufferIndex].BufferPtr = BuffPtr;

UT_SetDeferredRetcode(UT_KEY(CFE_ResourceId_FindNext), 1, 0);
UT_SetDeferredRetcode(UT_KEY(CFE_ResourceId_FindNext), 1, -1);
UtAssert_INT32_EQ(CFE_TBL_ValidateCmd(&ValidateCmd), CFE_TBL_INC_ERR_CTR);

/* Test where the active buffer has data, but there is no validation
Expand Down Expand Up @@ -1127,6 +1127,19 @@ void Test_CFE_TBL_DumpCmd(void)
snprintf(DumpCmd.Payload.TableName, sizeof(DumpCmd.Payload.TableName), "%d", CFE_PLATFORM_TBL_MAX_NUM_TABLES + 1);
UtAssert_INT32_EQ(CFE_TBL_DumpCmd(&DumpCmd), CFE_TBL_INC_ERR_CTR);

/* Test where the active buffer has data, but no dump control buffer is available
*/
UT_InitData();
strncpy(CFE_TBL_Global.Registry[2].Name, "DumpCmdTest", sizeof(CFE_TBL_Global.Registry[2].Name) - 1);
strncpy(DumpCmd.Payload.TableName, CFE_TBL_Global.Registry[2].Name, sizeof(DumpCmd.Payload.TableName) - 1);
CFE_TBL_Global.Registry[2].DumpOnly = true;
DumpCmd.Payload.TableName[sizeof(DumpCmd.Payload.TableName) - 1] = '\0';
DumpCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_ACTIVE;
CFE_TBL_Global.Registry[2].Buffers[CFE_TBL_Global.Registry[2].ActiveBufferIndex].BufferPtr = BuffPtr;

UT_SetDeferredRetcode(UT_KEY(CFE_ResourceId_FindNext), 1, -1);
UtAssert_INT32_EQ(CFE_TBL_DumpCmd(&DumpCmd), CFE_TBL_INC_ERR_CTR);

/* Test with an active buffer, the pointer is created, validation passes,
* the table is dump only, no dump is already in progress, and have a
* working buffer; load in progress, single-buffered
Expand Down Expand Up @@ -4068,7 +4081,7 @@ void Test_CFE_TBL_ResourceID_ValidationResult(void)
UtAssert_BOOL_TRUE(CFE_TBL_CheckValidationResultSlotUsed(PendingId));

/* Test case where no ID is available */
UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), 0);
UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), -1);
UtAssert_VOIDCALL(PendingId = CFE_TBL_GetNextValResultBlock());
UtAssert_BOOL_FALSE(CFE_ResourceId_IsDefined(PendingId));

Expand Down Expand Up @@ -4167,7 +4180,7 @@ void Test_CFE_TBL_ResourceID_DumpControl(void)
UtAssert_BOOL_TRUE(CFE_TBL_CheckDumpCtrlSlotUsed(PendingId));

/* Test case where no ID is available */
UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), 0);
UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), -1);
UtAssert_VOIDCALL(PendingId = CFE_TBL_GetNextDumpCtrlBlock());
UtAssert_BOOL_FALSE(CFE_ResourceId_IsDefined(PendingId));

Expand Down

0 comments on commit e91b7c3

Please sign in to comment.