Skip to content

Commit

Permalink
Merge pull request nasa#485 from dmknutsen/issue_274
Browse files Browse the repository at this point in the history
Fix nasa#274, NumOfChildTasks not decremented
  • Loading branch information
astrogeco authored Feb 25, 2020
2 parents 75558f1 + 8558411 commit dccf3b2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
7 changes: 1 addition & 6 deletions fsw/cfe-core/src/es/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,12 +1074,7 @@ int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr,
strncpy((char *)CFE_ES_Global.TaskTable[TaskId].TaskName,TaskName,OS_MAX_API_NAME);
CFE_ES_Global.TaskTable[TaskId].TaskName[OS_MAX_API_NAME - 1] = '\0';
CFE_ES_Global.RegisteredTasks++;

/*
** Increment the "Registered" child task count for the App
*/
CFE_ES_Global.AppTable[AppId].TaskInfo.NumOfChildTasks ++;


ReturnCode = CFE_SUCCESS;
}
else
Expand Down
16 changes: 14 additions & 2 deletions fsw/cfe-core/src/es/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ int32 CFE_ES_AppCreate(uint32 *ApplicationIdPtr,
*/
strncpy((char *)CFE_ES_Global.AppTable[i].TaskInfo.MainTaskName, AppName, OS_MAX_API_NAME);
CFE_ES_Global.AppTable[i].TaskInfo.MainTaskName[OS_MAX_API_NAME - 1] = '\0';
CFE_ES_Global.AppTable[i].TaskInfo.NumOfChildTasks = 0;

/*
** Fill out the Task State info
Expand Down Expand Up @@ -1541,6 +1540,7 @@ void CFE_ES_GetAppInfoInternal(uint32 AppId, CFE_ES_AppInfo_t *AppInfoPtr )
int32 ReturnCode;
OS_module_prop_t ModuleInfo;
uint32 TaskIndex;
uint32 i;


CFE_ES_LockSharedData(__func__,__LINE__);
Expand Down Expand Up @@ -1571,7 +1571,19 @@ void CFE_ES_GetAppInfoInternal(uint32 AppId, CFE_ES_AppInfo_t *AppInfoPtr )
strncpy((char *)AppInfoPtr->MainTaskName, (char *)CFE_ES_Global.AppTable[AppId].TaskInfo.MainTaskName,
sizeof(AppInfoPtr->MainTaskName) - 1);
AppInfoPtr->MainTaskName[sizeof(AppInfoPtr->MainTaskName) - 1] = '\0';
AppInfoPtr->NumOfChildTasks = CFE_ES_Global.AppTable[AppId].TaskInfo.NumOfChildTasks;

/*
** Calculate the number of child tasks
*/
AppInfoPtr->NumOfChildTasks = 0;
for (i=0; i<OS_MAX_TASKS; i++ )
{
if ( CFE_ES_Global.TaskTable[i].AppId == AppId && CFE_ES_Global.TaskTable[i].RecordUsed == true
&& CFE_ES_Global.TaskTable[i].TaskId != AppInfoPtr->MainTaskId )
{
AppInfoPtr->NumOfChildTasks++;
}
}

/*
** Get the execution counter for the main task
Expand Down
2 changes: 0 additions & 2 deletions fsw/cfe-core/src/es/cfe_es_apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ typedef struct
{
uint32 MainTaskId; /* The Application's Main Task ID */
char MainTaskName[OS_MAX_API_NAME]; /* The Application's Main Task ID */
uint32 NumOfChildTasks; /* Number of Child tasks for an App */

} CFE_ES_MainTaskInfo_t;


Expand Down
1 change: 0 additions & 1 deletion fsw/cfe-core/src/es/cfe_es_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,6 @@ void CFE_ES_CreateObjects(void)
*/
strncpy((char *)CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName, (char *)CFE_ES_ObjectTable[i].ObjectName, OS_MAX_API_NAME);
CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName[OS_MAX_API_NAME - 1] = '\0';
CFE_ES_Global.AppTable[j].TaskInfo.NumOfChildTasks = 0;

/*
** Create the task
Expand Down
25 changes: 17 additions & 8 deletions fsw/cfe-core/unit-test/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -4286,8 +4286,8 @@ void TestAPI(void)
char CDSName[CFE_MISSION_ES_CDS_MAX_NAME_LENGTH + 2];
int i;
uint32 ExceptionContext = 0;
int32 Return;
uint8 Data[12];
int32 Return;
uint8 Data[12];
uint32 ResetType;
uint32 *ResetTypePtr;
uint32 AppId;
Expand All @@ -4298,6 +4298,7 @@ void TestAPI(void)
uint32 CounterCount;
CFE_ES_CDSHandle_t CDSHandle;
CFE_ES_TaskInfo_t TaskInfo;
CFE_ES_AppInfo_t AppInfo;

#ifdef UT_VERBOSE
UT_Text("Begin Test API\n");
Expand Down Expand Up @@ -4777,12 +4778,20 @@ void TestAPI(void)
CFE_ES_Global.AppTable[0].AppState = CFE_ES_AppState_RUNNING;
CFE_ES_Global.AppTable[0].TaskInfo.MainTaskId = 15;
OS_TaskCreate(&CFE_ES_Global.TaskTable[1].TaskId, NULL, NULL, NULL,
0, 0, 0);
UT_Report(__FILE__, __LINE__,
CFE_ES_DeleteChildTask(CFE_ES_Global.TaskTable[1].TaskId) ==
CFE_SUCCESS,
"CFE_ES_DeleteChildTask",
"Delete child task successful");
0, 0, 0);
Return = CFE_ES_GetAppInfo(&AppInfo,CFE_ES_Global.TaskTable[1].AppId);
UtAssert_True(Return == CFE_SUCCESS,
"CFE_ES_GetAppInfo() return=%x", (unsigned int)Return);
UtAssert_True(AppInfo.NumOfChildTasks == 1,
"AppInfo.NumOfChildTaskss == %u", (unsigned int)AppInfo.NumOfChildTasks);
Return = CFE_ES_DeleteChildTask(CFE_ES_Global.TaskTable[1].TaskId);
UtAssert_True(Return == CFE_SUCCESS,
"DeleteChildResult() return=%x", (unsigned int)Return);
Return = CFE_ES_GetAppInfo(&AppInfo,CFE_ES_Global.TaskTable[1].AppId);
UtAssert_True(Return == CFE_SUCCESS,
"CFE_ES_GetAppInfo() return=%x", (unsigned int)Return);
UtAssert_True(AppInfo.NumOfChildTasks == 0,
"AppInfo.NumOfChildTaskss == %u", (unsigned int)AppInfo.NumOfChildTasks);

/* Test deleting a child task with an OS task delete failure */
ES_ResetUnitTest();
Expand Down

0 comments on commit dccf3b2

Please sign in to comment.