-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #808, ES Info API Functional test
- Loading branch information
Showing
6 changed files
with
203 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/************************************************************************* | ||
** | ||
** GSC-18128-1, "Core Flight Executive Version 6.7" | ||
** | ||
** Copyright (c) 2006-2019 United States Government as represented by | ||
** the Administrator of the National Aeronautics and Space Administration. | ||
** All Rights Reserved. | ||
** | ||
** Licensed under the Apache License, Version 2.0 (the "License"); | ||
** you may not use this file except in compliance with the License. | ||
** You may obtain a copy of the License at | ||
** | ||
** http://www.apache.org/licenses/LICENSE-2.0 | ||
** | ||
** Unless required by applicable law or agreed to in writing, software | ||
** distributed under the License is distributed on an "AS IS" BASIS, | ||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
** See the License for the specific language governing permissions and | ||
** limitations under the License. | ||
** | ||
** File: es_info_test.c | ||
** | ||
** Purpose: | ||
** Functional test of basic ES Information APIs | ||
** | ||
** Demonstration of how to register and use the UT assert functions. | ||
** | ||
*************************************************************************/ | ||
|
||
/* | ||
* Includes | ||
*/ | ||
|
||
#include "cfe_test.h" | ||
|
||
void TestAppInfo(void) | ||
{ | ||
uint32 TestAppId; | ||
uint32 ESAppId; | ||
uint32 AppIdByName; | ||
uint32 InvalidID = 123; | ||
const char * TestAppName = "TESTRUN_APP"; | ||
const char * ESAppName = "CFE_ES"; | ||
const char * InvalidName = "INVALID_NAME"; | ||
char AppNameBuf[OS_MAX_API_NAME + 4]; | ||
CFE_ES_AppInfo_t TestAppInfo; | ||
CFE_ES_AppInfo_t ESAppInfo; | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&AppIdByName, TestAppName), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppID(&TestAppId), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(TestAppId, AppIdByName); | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetAppName(AppNameBuf, TestAppId, sizeof(AppNameBuf)), CFE_SUCCESS); | ||
UtAssert_StrCmp(AppNameBuf, TestAppName, "CFE_ES_GetAppName() = %s", AppNameBuf); | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetAppInfo(&TestAppInfo, TestAppId), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&ESAppId, ESAppName), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppInfo(&ESAppInfo, ESAppId), CFE_SUCCESS); | ||
|
||
UtAssert_True(TestAppInfo.Type == 2, "Test App Info -> Type = %d", TestAppInfo.Type); | ||
UtAssert_True(ESAppInfo.Type == 1, "ES App Info -> Type = %d", ESAppInfo.Type); | ||
|
||
UtAssert_StrCmp(TestAppInfo.Name, TestAppName, "Test App Info -> Name = %s", TestAppInfo.Name); | ||
UtAssert_StrCmp(ESAppInfo.Name, ESAppName, "ES App Info -> Name = %s", ESAppInfo.Name); | ||
|
||
UtAssert_StrCmp(TestAppInfo.EntryPoint, "CFE_TR_AppMain", "Test App Info -> EntryPt = %s", TestAppInfo.EntryPoint); | ||
UtAssert_True(strlen(ESAppInfo.EntryPoint) == 0, "ES App Info -> EntryPt = %s", ESAppInfo.EntryPoint); | ||
|
||
UtAssert_StrCmp(TestAppInfo.FileName, "/cf/cfe_testrunner.so", "Test App Info -> FileName = %s", | ||
TestAppInfo.FileName); | ||
UtAssert_True(strlen(ESAppInfo.FileName) == 0, "ES App Info -> FileName = %s", ESAppInfo.FileName); | ||
|
||
UtAssert_True(TestAppInfo.StackSize > 0, "Test App Info -> StackSz = %d", TestAppInfo.StackSize); | ||
UtAssert_True(ESAppInfo.StackSize > 0, "ES App Info -> StackSz = %d", ESAppInfo.StackSize); | ||
|
||
if (TestAppInfo.AddressesAreValid) | ||
{ | ||
/* ToDo: check these are non 0 */ | ||
UtAssert_True(TestAppInfo.AddressesAreValid > 0, "Test App Info -> AddrsValid? = %d", | ||
TestAppInfo.AddressesAreValid); | ||
UtPrintf("Test App Info -> CodeAddress = %d\n", TestAppInfo.CodeAddress); | ||
UtPrintf("Test App Info -> CodeSize = %d\n", TestAppInfo.CodeSize); | ||
UtPrintf("Test App Info -> DataAddress = %d\n", TestAppInfo.DataAddress); | ||
UtPrintf("Test App Info -> DataSize = %d\n", TestAppInfo.DataSize); | ||
UtPrintf("Test App Info -> BSSAddress = 0x%4x\n", TestAppInfo.BSSAddress); | ||
UtPrintf("Test App Info -> BSSSize = %d\n", TestAppInfo.BSSSize); | ||
} | ||
else | ||
{ | ||
UtAssert_NA("Addresses are Valid not implemented"); | ||
} | ||
|
||
UtAssert_True(ESAppInfo.AddressesAreValid == 0, "ES App Info -> AddrsValid? = %d", ESAppInfo.AddressesAreValid); | ||
|
||
UtAssert_True(TestAppInfo.StartAddress > 0, "Test App Info -> StartAddress = 0x%4x", TestAppInfo.StartAddress); | ||
UtAssert_True(ESAppInfo.StartAddress == 0, "ES App Info -> StartAddress = 0x%4x", ESAppInfo.StartAddress); | ||
|
||
UtAssert_INT32_EQ(TestAppInfo.ExceptionAction, 0); | ||
UtAssert_INT32_EQ(ESAppInfo.ExceptionAction, 1); | ||
|
||
UtAssert_True(TestAppInfo.Priority > 0, "Test App Info -> Priority = %d", TestAppInfo.Priority); | ||
UtAssert_True(ESAppInfo.Priority > 0, "ES App Info -> Priority = %d", ESAppInfo.Priority); | ||
|
||
UtAssert_True(TestAppInfo.NumOfChildTasks == 0, "Test App Info -> Child Tasks = %d", TestAppInfo.NumOfChildTasks); | ||
UtAssert_True(ESAppInfo.NumOfChildTasks > 0, "ES App Info -> Child Tasks = %d", ESAppInfo.NumOfChildTasks); | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&AppIdByName, InvalidName), CFE_ES_ERR_NAME_NOT_FOUND); | ||
UtAssert_INT32_EQ(AppIdByName, CFE_ES_APPID_UNDEFINED); | ||
|
||
// UtAssert_INT32_EQ(CFE_ES_GetAppID(NULL), CFE_ES_BAD_ARGUMENT); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(NULL, TestAppName), CFE_ES_BAD_ARGUMENT); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppName(AppNameBuf, InvalidID, sizeof(AppNameBuf)), CFE_ES_ERR_RESOURCEID_NOT_VALID); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppName(NULL, TestAppId, sizeof(AppNameBuf)), CFE_ES_BAD_ARGUMENT); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppInfo(&TestAppInfo, InvalidID), CFE_ES_ERR_RESOURCEID_NOT_VALID); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppInfo(NULL, InvalidID), CFE_ES_BAD_ARGUMENT); | ||
} | ||
|
||
void TestTaskInfo(void) | ||
{ | ||
uint32 AppId; | ||
CFE_ES_AppInfo_t AppInfo; | ||
CFE_ES_TaskInfo_t TaskInfo; | ||
CFE_ES_TaskId_t TaskId; | ||
uint32 InvalidID = 123; | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppId), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(CFE_ES_GetAppInfo(&AppInfo, AppId), CFE_SUCCESS); | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, AppInfo.MainTaskId), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskId), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(TaskId, AppInfo.MainTaskId); | ||
|
||
UtAssert_StrCmp(TaskInfo.AppName, AppInfo.Name, "TaskInfo.AppName (%s) = AppInfo.name (%s)", TaskInfo.AppName, | ||
AppInfo.Name); | ||
UtAssert_StrCmp(TaskInfo.TaskName, AppInfo.MainTaskName, "TaskInfo.TaskName (%s) = AppInfo.MainTaskName (%s)", | ||
TaskInfo.TaskName, AppInfo.MainTaskName); | ||
|
||
UtAssert_INT32_EQ(TaskInfo.TaskId, AppInfo.MainTaskId); | ||
UtAssert_INT32_EQ(TaskInfo.AppId, AppId); | ||
UtAssert_INT32_EQ(TaskInfo.ExecutionCounter, AppInfo.ExecutionCounter); | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, InvalidID), CFE_ES_ERR_RESOURCEID_NOT_VALID); | ||
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(NULL, InvalidID), CFE_ES_BAD_ARGUMENT); | ||
// UtAssert_INT32_EQ(CFE_ES_GetTaskID(NULL), CFE_ES_BAD_ARGUMENT); | ||
} | ||
|
||
void TestLibInfo(void) | ||
{ | ||
uint32 LibIdByName; | ||
CFE_ES_AppInfo_t LibInfo; | ||
const char * LibName = "ASSERT_LIB"; | ||
const char * InvalidName = "INVALID_NAME"; | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&LibIdByName, LibName), CFE_SUCCESS); | ||
UtAssert_INT32_EQ(CFE_ES_GetLibInfo(&LibInfo, LibIdByName), CFE_SUCCESS); | ||
UtAssert_True(LibInfo.Type == 3, "Lib Info -> Type = %d", LibInfo.Type); | ||
UtAssert_StrCmp(LibInfo.Name, LibName, "Lib Info -> Name = %s", LibInfo.Name); | ||
UtAssert_StrCmp(LibInfo.EntryPoint, "CFE_Assert_LibInit", "Lib Info -> EntryPt = %s", LibInfo.EntryPoint); | ||
UtAssert_StrCmp(LibInfo.FileName, "/cf/cfe_assert.so", "Lib Info -> FileName = %s", LibInfo.FileName); | ||
UtAssert_True(LibInfo.StackSize == 0, "Lib Info -> StackSz = %d", LibInfo.StackSize); | ||
|
||
if (LibInfo.AddressesAreValid) | ||
{ | ||
/* ToDo: check these are non 0 */ | ||
UtAssert_True(LibInfo.AddressesAreValid > 0, "Lib Info -> AddrsValid? = %d", LibInfo.AddressesAreValid); | ||
UtPrintf("Lib Info -> CodeAddress = %d\n", LibInfo.CodeAddress); | ||
UtPrintf("Lib Info -> CodeSize = %d\n", LibInfo.CodeSize); | ||
UtPrintf("Lib Info -> DataAddress = %d\n", LibInfo.DataAddress); | ||
UtPrintf("Lib Info -> DataSize = %d\n", LibInfo.DataSize); | ||
UtPrintf("Lib Info -> BSSAddress = 0x%4x\n", LibInfo.BSSAddress); | ||
UtPrintf("Lib Info -> BSSSize = %d\n", LibInfo.BSSSize); | ||
} | ||
else | ||
{ | ||
UtAssert_NA("Addresses are Valid not implemented"); | ||
} | ||
|
||
UtAssert_INT32_EQ(LibInfo.ExceptionAction, 0); | ||
UtAssert_True(LibInfo.Priority == 0, "Lib Info -> Priority = %d", LibInfo.Priority); | ||
UtAssert_True(LibInfo.MainTaskId == 0, "Lib Info -> MainTaskId = %d", LibInfo.MainTaskId); | ||
UtAssert_True(LibInfo.ExecutionCounter == 0, "Lib Info -> ExecutionCounter = %d", LibInfo.ExecutionCounter); | ||
UtAssert_True(strlen(LibInfo.MainTaskName) == 0, "Lib Info -> Task Name = %s", LibInfo.MainTaskName); | ||
UtAssert_True(LibInfo.NumOfChildTasks == 0, "Lib Info -> Child Tasks = %d", LibInfo.NumOfChildTasks); | ||
|
||
UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&LibIdByName, InvalidName), CFE_ES_ERR_NAME_NOT_FOUND); | ||
UtAssert_INT32_EQ(CFE_ES_GetLibInfo(&LibInfo, LibIdByName), CFE_ES_ERR_RESOURCEID_NOT_VALID); | ||
UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(NULL, LibName), CFE_ES_BAD_ARGUMENT); | ||
UtAssert_INT32_EQ(CFE_ES_GetLibInfo(NULL, LibIdByName), CFE_ES_BAD_ARGUMENT); | ||
} | ||
|
||
int32 ESInfoTestSetup(int32 LibId) | ||
{ | ||
UtTest_Add(TestAppInfo, NULL, NULL, "Test App Info"); | ||
UtTest_Add(TestTaskInfo, NULL, NULL, "Test Task Info"); | ||
UtTest_Add(TestLibInfo, NULL, NULL, "Test Lib Info"); | ||
return CFE_SUCCESS; | ||
} |
This file was deleted.
Oops, something went wrong.