Skip to content

Commit

Permalink
Fixes nasa#274, NumOfChildTasks not decremented
Browse files Browse the repository at this point in the history
  • Loading branch information
dmknutsen committed Jan 29, 2020
1 parent 3356da6 commit 7fff455
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 20 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
20 changes: 17 additions & 3 deletions fsw/cfe-core/src/es/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,9 @@ 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;

/*
CFE_ES_Global.AppTable[i].TaskInfo.NumOfChildTasks = 0;
*/
/*
** Fill out the Task State info
*/
Expand Down Expand Up @@ -1545,6 +1546,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 @@ -1575,7 +1577,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
63 changes: 55 additions & 8 deletions fsw/cfe-core/unit-test/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@
** Includes
*/
#include "es_UT.h"
#include "cfe_es.h"
#include "cfe_es_apps.h"
#include <stdio.h>


#include "private/cfe_private.h"
#include "cfe_platform_cfg.h"
#include "cfe_version.h"
#include "cfe_es_global.h"
#include "cfe_es_apps.h"
#include "cfe_es_events.h"
#include "cfe_es_verify.h"
#include "cfe_es_task.h"
#include "cfe_es_shell.h"
#include "cfe_es_log.h"
#include "cfe_es_cds.h"
#include "cfe_fs.h"
#include "cfe_psp.h"
#include "cfe_msgids.h"

#include <string.h>

extern CFE_ES_PerfData_t *Perf;
extern CFE_ES_Global_t CFE_ES_Global;
Expand Down Expand Up @@ -4319,6 +4340,8 @@ void TestAPI(void)
CFE_ES_CDSHandle_t CDSHandle;
CFE_ES_TaskInfo_t TaskInfo;

CFE_ES_AppInfo_t AppInfo;

#ifdef UT_VERBOSE
UT_Text("Begin Test API\n");
#endif
Expand Down Expand Up @@ -4793,14 +4816,38 @@ void TestAPI(void)
/* Test successfully deleting a child task */
ES_ResetUnitTest();
CFE_ES_Global.TaskTable[1].RecordUsed = true;
CFE_ES_Global.TaskTable[1].AppId = 0;
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,
CFE_ES_Global.TaskTable[1].AppId = 15;

CFE_ES_Global.TaskTable[16].RecordUsed = true;
CFE_ES_Global.TaskTable[16].AppId = 15;
CFE_ES_Global.TaskTable[17].RecordUsed = true;
CFE_ES_Global.TaskTable[17].AppId = 15;
CFE_ES_Global.TaskTable[17].TaskId = 25;
CFE_ES_Global.TaskTable[18].RecordUsed = true;
CFE_ES_Global.TaskTable[18].AppId = 15;
CFE_ES_Global.AppTable[15].AppState = CFE_ES_AppState_RUNNING;
CFE_ES_Global.AppTable[15].TaskInfo.MainTaskId = 25;

OS_TaskCreate(&CFE_ES_Global.TaskTable[16].TaskId, NULL, NULL, NULL,
0, 0, 0);

CFE_ES_GetAppInfo(&AppInfo,CFE_ES_Global.TaskTable[1].AppId);
uint32 NumORegTasksTemp = CFE_ES_Global.RegisteredTasks;
uint32 NumOChildTastTemp1 = AppInfo.NumOfChildTasks;

int32 DeleteChildResult = CFE_ES_DeleteChildTask(CFE_ES_Global.TaskTable[1].TaskId);
int32 DeleteChildTestResult = 0xFFFFFFFF;

CFE_ES_GetAppInfo(&AppInfo,CFE_ES_Global.TaskTable[1].AppId);
uint32 NumOChildTastTemp2 = AppInfo.NumOfChildTasks;

if( DeleteChildResult == CFE_SUCCESS && CFE_ES_Global.RegisteredTasks == NumORegTasksTemp - 1
&& NumOChildTastTemp2 == NumOChildTastTemp1 - 1 )
{
DeleteChildTestResult = CFE_SUCCESS;
}
UT_Report(__FILE__, __LINE__,
CFE_ES_DeleteChildTask(CFE_ES_Global.TaskTable[1].TaskId) ==
CFE_SUCCESS,
DeleteChildTestResult == CFE_SUCCESS,
"CFE_ES_DeleteChildTask",
"Delete child task successful");

Expand Down Expand Up @@ -5572,7 +5619,7 @@ void TestAPI(void)
"Host ID doesn't match OS task ID");

/* Test handling of logging and reset where CFE_ES_GetTaskInfo fails */
ES_ResetUnitTest();
ES_ResetUnitTest();
OS_TaskCreate(&TestObjId, "UT", NULL, NULL, 0, 0, 0);
Id = ES_UT_OSALID_TO_ARRAYIDX(TestObjId);
OS_TaskCreate(&TestObjId2, "UT", NULL, NULL, 0, 0, 0);
Expand All @@ -5586,7 +5633,7 @@ void TestAPI(void)
CFE_ES_Global.AppTable[Id2].AppState = CFE_ES_AppState_UNDEFINED;
CFE_ES_Global.AppTable[Id2].StartParams.ExceptionAction =
CFE_ES_ExceptionAction_RESTART_APP;
CFE_ES_ProcessCoreException(Id,
CFE_ES_ProcessCoreException(Id,
"Reason String",
&ExceptionContext,
sizeof(ExceptionContext));
Expand Down

0 comments on commit 7fff455

Please sign in to comment.