Skip to content

Commit

Permalink
Fix nasa#639, Remove ES_APP_DEBUG functionality
Browse files Browse the repository at this point in the history
Deletes now unused CFE_ES_CountObjectCallback
and CFE_ES_ListResourcesDebug.
  • Loading branch information
skliper committed May 8, 2020
1 parent 4c392cc commit 9cb0b5d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 96 deletions.
68 changes: 3 additions & 65 deletions fsw/cfe-core/src/es/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
*/
#define ES_START_BUFF_SIZE 128

/* For extra debug code */
#undef ES_APP_DEBUG

/*
**
** Global Variables
Expand Down Expand Up @@ -1238,11 +1235,6 @@ int32 CFE_ES_CleanUpApp(uint32 AppId)
uint32 MainTaskId;
int32 ReturnCode = CFE_SUCCESS;

#ifdef ES_APP_DEBUG
OS_printf("------------- Starting App Cleanup: AppID = %d -----------\n",AppId);
CFE_ES_ListResourcesDebug();
#endif

/*
** Call the Table Clean up function
*/
Expand Down Expand Up @@ -1332,12 +1324,6 @@ int32 CFE_ES_CleanUpApp(uint32 AppId)

CFE_ES_Global.AppTable[AppId].AppState = CFE_ES_AppState_UNDEFINED;

#ifdef ES_APP_DEBUG
OS_TaskDelay(1000);
CFE_ES_ListResourcesDebug();
printf("--------- Finished CFE_ES_CleanUpApp-------------\n");
#endif

CFE_ES_UnlockSharedData(__func__,__LINE__);

return(ReturnCode);
Expand All @@ -1348,8 +1334,7 @@ int32 CFE_ES_CleanUpApp(uint32 AppId)
/*
* Simple state structure used when cleaning up objects associated with tasks
*
* This is used locally between CFE_ES_CleanupTaskResources and the
* CFE_ES_CountObjectCallback helper function.
* This is used locally by CFE_ES_CleanupTaskResources
*/
typedef struct
{
Expand All @@ -1362,9 +1347,9 @@ typedef struct

/*
**---------------------------------------------------------------------------------------
** Name: CFE_ES_CountObjectCallback
** Name: CFE_ES_CleanupObjectCallback
**
** Purpose: Helper function for CFE_ES_ListResourcesDebug to count all objects.
** Purpose: Helper function clean up all objects.
**
** NOTE: This is called while holding the ES global lock
**---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1528,53 +1513,6 @@ int32 CFE_ES_CleanupTaskResources(uint32 TaskId)

}

/*
**---------------------------------------------------------------------------------------
** Name: CFE_ES_CountObjectCallback
**
** Purpose: Helper function for CFE_ES_ListResourcesDebug to count all objects.
**---------------------------------------------------------------------------------------
*/
void CFE_ES_CountObjectCallback(uint32 ObjectId, void *arg)
{
uint32 *CountState;
uint32 idtype;

CountState = (uint32 *)arg;
idtype = OS_IdentifyObject(ObjectId);
if (idtype < OS_OBJECT_TYPE_USER)
{
++CountState[idtype];
}
}


/*
**---------------------------------------------------------------------------------------
** Name: CFE_ES_ListResourcesDebug
**
** Purpose: List the resources.
**---------------------------------------------------------------------------------------
*/
int32 CFE_ES_ListResourcesDebug(void)
{
uint32 CountState[OS_OBJECT_TYPE_USER];

memset(CountState,0,sizeof(CountState));
OS_ForEachObject (0, CFE_ES_CountObjectCallback, CountState);

OS_printf("OS Resources in Use:\n");
OS_printf("Number of Tasks: %d\n", (int) CountState[OS_OBJECT_TYPE_OS_TASK]);
OS_printf("Number of Queues: %d\n", (int) CountState[OS_OBJECT_TYPE_OS_QUEUE]);
OS_printf("Number of Counting Semaphores: %d\n",(int) CountState[OS_OBJECT_TYPE_OS_COUNTSEM]);
OS_printf("Number of Binary Semaphores: %d\n",(int) CountState[OS_OBJECT_TYPE_OS_BINSEM]);
OS_printf("Number of Mutexes: %d\n", (int) CountState[OS_OBJECT_TYPE_OS_MUTEX]);
OS_printf("Number of Open Files: %d\n",(int) CountState[OS_OBJECT_TYPE_OS_STREAM]);

return CFE_SUCCESS;

}

/*
**---------------------------------------------------------------------------------------
** Name: CFE_ES_GetAppInfoInternal
Expand Down
5 changes: 0 additions & 5 deletions fsw/cfe-core/src/es/cfe_es_apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@ int32 CFE_ES_CleanUpApp(uint32 AppId);
*/
int32 CFE_ES_CleanupTaskResources(uint32 TaskId);

/*
** Debug function to print out resource utilization
*/
int32 CFE_ES_ListResourcesDebug(void);

/*
** Populate the cFE_ES_AppInfo structure with the data for an app
** This is an internal function for use in ES.
Expand Down
25 changes: 0 additions & 25 deletions fsw/cfe-core/unit-test/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,16 +1687,6 @@ void TestApps(void)
/* Test listing the OS resources in use */
ES_ResetUnitTest();

/* Fail the first time, then succeed on the second in order to test
* both paths
*/
UT_SetDeferredRetcode(UT_KEY(OS_TaskGetInfo), 2, OS_ERROR);
UT_Report(__FILE__, __LINE__,
CFE_ES_ListResourcesDebug() == CFE_SUCCESS &&
UT_GetStubCount(UT_KEY(OS_printf)) == 7,
"CFE_ES_ListResourcesDebug",
"Get task info failed");

/* Test populating the application information structure with data */
ES_ResetUnitTest();
OS_TaskCreate(&TestObjId, "UT", NULL, NULL, 0, 0, 0);
Expand Down Expand Up @@ -2092,21 +2082,6 @@ void TestApps(void)
CFE_ES_CleanupTaskResources(TestObjId) == CFE_SUCCESS,
"CFE_ES_CleanupTaskResources",
"Get OS information failures");

/* Test cleaning up the OS resources for a task with failure to
* obtain information on mutex, binary, and counter semaphores, and
* queues, timers, and file descriptors
*/
ES_ResetUnitTest();
UT_SetDeferredRetcode(UT_KEY(OS_MutSemGetInfo), 1, OS_ERROR);
UT_SetDeferredRetcode(UT_KEY(OS_BinSemGetInfo), 1, OS_ERROR);
UT_SetDeferredRetcode(UT_KEY(OS_CountSemGetInfo), 1, OS_ERROR);
UT_SetDeferredRetcode(UT_KEY(OS_QueueGetInfo), 1, OS_ERROR);
UT_SetDeferredRetcode(UT_KEY(OS_FDGetInfo), 1, OS_ERROR);
UT_Report(__FILE__, __LINE__,
CFE_ES_ListResourcesDebug() == CFE_SUCCESS,
"CFE_ES_ListResourcesDebug",
"Get OS information failures");
}

void TestERLog(void)
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/unit-test/es_UT.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void TestStartupErrorPaths(void);
** \sa #UT_Report, #UT_SetOSFail, #CFE_ES_ParseFileEntry
** \sa #UT_SetBSPloadAppFileResult, #CFE_ES_AppCreate, #UT_SetDummyFuncRtn
** \sa #CFE_ES_LoadLibrary, #CFE_ES_ScanAppTable, #CFE_ES_ProcessControlRequest
** \sa #CFE_ES_ListResourcesDebug, #CFE_ES_GetAppInfo, #CFE_ES_CleanUpApp
** \sa #CFE_ES_GetAppInfo, #CFE_ES_CleanUpApp
** \sa #CFE_ES_CleanupTaskResources
**
******************************************************************************/
Expand Down

0 comments on commit 9cb0b5d

Please sign in to comment.