From 6a5335635a8cfdb460960635d92971a98dd58aef Mon Sep 17 00:00:00 2001 From: Alex Campbell Date: Mon, 22 Mar 2021 09:35:26 -0400 Subject: [PATCH] Fix #808, ES API Functional test --- modules/cfe_testcase/CMakeLists.txt | 1 + modules/cfe_testcase/src/cfe_test.c | 1 + modules/cfe_testcase/src/cfe_test.h | 1 + modules/cfe_testcase/src/es_info_test.c | 92 +++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 modules/cfe_testcase/src/es_info_test.c diff --git a/modules/cfe_testcase/CMakeLists.txt b/modules/cfe_testcase/CMakeLists.txt index a2a48bde9..fd6c31dc2 100644 --- a/modules/cfe_testcase/CMakeLists.txt +++ b/modules/cfe_testcase/CMakeLists.txt @@ -5,4 +5,5 @@ include_directories("${UT_ASSERT_SOURCE_DIR}/inc") add_cfe_app(cfe_testcase src/cfe_test.c src/es_test.c + src/es_info_test.c ) diff --git a/modules/cfe_testcase/src/cfe_test.c b/modules/cfe_testcase/src/cfe_test.c index d9606b9eb..a52a56433 100644 --- a/modules/cfe_testcase/src/cfe_test.c +++ b/modules/cfe_testcase/src/cfe_test.c @@ -39,5 +39,6 @@ int32 CFE_Test_Init(int32 LibId) { UtTest_Add(ES_Test_AppId, NULL, NULL, "ES AppID"); + UtTest_Add(ES_Test_InfoApi, NULL, NULL, "ES Info API"); return CFE_SUCCESS; } diff --git a/modules/cfe_testcase/src/cfe_test.h b/modules/cfe_testcase/src/cfe_test.h index 45f98e890..5a9e6d7b6 100644 --- a/modules/cfe_testcase/src/cfe_test.h +++ b/modules/cfe_testcase/src/cfe_test.h @@ -39,6 +39,7 @@ #include "utassert.h" void ES_Test_AppId(void); +void ES_Test_InfoApi(void); int32 CFE_Test_Init(int32 LibId); #endif /* CFE_TEST_H */ diff --git a/modules/cfe_testcase/src/es_info_test.c b/modules/cfe_testcase/src/es_info_test.c new file mode 100644 index 000000000..4b0617f6c --- /dev/null +++ b/modules/cfe_testcase/src/es_info_test.c @@ -0,0 +1,92 @@ +/************************************************************************* +** +** 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_test.c +** +** Purpose: +** Functional test of basic ES APIs +** +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +/* + * Includes + */ + +#include "cfe_test.h" + +void ES_Test_InfoApi(void) +{ + uint32 AppId; + uint32 AppId2; + const char *AppName = "TESTRUN_APP"; + char AppNameBuf[OS_MAX_API_NAME + 4]; + uint32 resetSubType; + CFE_ES_AppInfo_t appInfo; + CFE_ES_TaskInfo_t taskInfo; + + + UtAssert_SUCCESS(CFE_ES_GetAppIDByName(&AppId, AppName)); + UtAssert_SUCCESS(CFE_ES_GetAppID(&AppId2)); + UtAssert_INT32_EQ(AppId, AppId2); + + UtAssert_SUCCESS(CFE_ES_GetAppName(AppNameBuf, AppId, sizeof(AppNameBuf))); + UtAssert_StrCmp(AppNameBuf, AppName, "CFE_ES_GetAppName() = TESTRUN_APP"); + + UtAssert_INT32_EQ(CFE_ES_GetResetType(&resetSubType),CFE_PSP_RST_TYPE_POWERON); + UtAssert_INT32_EQ(resetSubType,CFE_PSP_RST_SUBTYPE_POWER_CYCLE); + + + + UtAssert_SUCCESS(CFE_ES_GetAppInfo(&appInfo, AppId)); + + UtAssert_True(appInfo.Type == 2, "App Info -> Type = %d", appInfo.Type); + + + UtPrintf ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + + UtAssert_StrCmp(appInfo.Name , AppName, "App Info -> Name = %s",appInfo.Name); + UtAssert_StrCmp(appInfo.EntryPoint , "CFE_TR_AppMain","App Info -> EntryPt = %s",appInfo.EntryPoint); + UtAssert_StrCmp(appInfo.FileName , "/cf/cfe_testrunner.so", "App Info -> FileName = %s",appInfo.FileName); + UtAssert_True(appInfo.StackSize == 16384, "App Info -> StackSz = %d",appInfo.StackSize); + //UtPrintf ("App Info -> ModuleId = %d\n",appInfo.ModuleId); + UtPrintf ("App Info -> AddrsValid? = %d\n",appInfo.AddressesAreValid); + UtPrintf ("App Info -> CodeAddress = %d\n",appInfo.CodeAddress); + UtPrintf ("App Info -> CodeSize = %d\n",appInfo.CodeSize); + UtPrintf ("App Info -> DataAddress = %d\n",appInfo.DataAddress); + UtPrintf ("App Info -> DataSize = %d\n",appInfo.DataSize); + UtPrintf ("App Info -> BSSAddress = 0x%4x\n",appInfo.BSSAddress); + UtPrintf ("App Info -> BSSSize = %d\n",appInfo.BSSSize); + UtPrintf ("App Info -> StartAddress = 0x%4x\n",appInfo.StartAddress); + UtPrintf ("App Info -> ExceptionAction = %d\n",appInfo.ExceptionAction); + UtPrintf ("App Info -> Priority = %d\n",appInfo.Priority); + UtPrintf ("App Info -> MainTaskID = %d\n",appInfo.MainTaskId); + UtPrintf ("App Info -> ExecutionCtr = %d\n",appInfo.ExecutionCounter); + UtPrintf ("App Info -> Task Name = %s\n",appInfo.MainTaskName); + UtPrintf ("App Info -> Child Tasks = %d\n",appInfo.NumOfChildTasks); + + UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&taskInfo, appInfo.MainTaskId), CFE_SUCCESS); + UtPrintf ("Task Info -> TaskId = %d\n",taskInfo.TaskId); + UtPrintf ("Task Info -> ExeCtr = %d\n",taskInfo.ExecutionCounter); + UtPrintf ("Task Info -> Task Name = %s\n",taskInfo.TaskName); + UtPrintf ("Task Info -> AppId = %d\n",taskInfo.AppId); + UtPrintf ("Task Info -> App Name = %s\n",taskInfo.AppName); +} \ No newline at end of file