diff --git a/modules/cfe_testcase/CMakeLists.txt b/modules/cfe_testcase/CMakeLists.txt index 8189dba9b..e6c30fb99 100644 --- a/modules/cfe_testcase/CMakeLists.txt +++ b/modules/cfe_testcase/CMakeLists.txt @@ -2,6 +2,7 @@ # Create the app module add_cfe_app(cfe_testcase src/cfe_test.c + src/es_application_control_test.c src/es_info_test.c src/es_task_test.c src/es_cds_test.c diff --git a/modules/cfe_testcase/src/cfe_test.c b/modules/cfe_testcase/src/cfe_test.c index dbc522b5c..5501c34a3 100644 --- a/modules/cfe_testcase/src/cfe_test.c +++ b/modules/cfe_testcase/src/cfe_test.c @@ -53,6 +53,7 @@ void CFE_TestMain(void) /* * Register test cases in UtAssert */ + ESApplicationControlTestSetup(); ESCDSTestSetup(); ESInfoTestSetup(); ESMemPoolTestSetup(); diff --git a/modules/cfe_testcase/src/cfe_test.h b/modules/cfe_testcase/src/cfe_test.h index a1881bc71..4859c18a7 100644 --- a/modules/cfe_testcase/src/cfe_test.h +++ b/modules/cfe_testcase/src/cfe_test.h @@ -84,6 +84,7 @@ extern CFE_FT_Global_t CFE_FT_Global; bool TimeInRange(CFE_TIME_SysTime_t Time, CFE_TIME_SysTime_t Target, OS_time_t difference); void CFE_TestMain(void); +void ESApplicationControlTestSetup(void); void ESCDSTestSetup(void); void ESInfoTestSetup(void); void ESMemPoolTestSetup(void); diff --git a/modules/cfe_testcase/src/es_application_control_test.c b/modules/cfe_testcase/src/es_application_control_test.c new file mode 100644 index 000000000..22fa4c1e2 --- /dev/null +++ b/modules/cfe_testcase/src/es_application_control_test.c @@ -0,0 +1,62 @@ +/************************************************************************* +** +** 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_application_control_test.c +** +** Purpose: +** Functional test of ES Application Control APIs +** +** Tests only invalid calls to the application control functions. +** +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +/* + * Includes + */ + +#include "cfe_test.h" + +void TestApplicationControl(void) +{ + UtPrintf("Testing: CFE_ES_RestartApp, CFE_ES_ReloadApp, CFE_ES_DeleteApp"); + CFE_ES_AppId_t TestAppId; + UtAssert_INT32_EQ(CFE_ES_GetAppID(&TestAppId), CFE_SUCCESS); + + UtAssert_UINT32_EQ(CFE_ES_RestartApp(CFE_ES_APPID_UNDEFINED), CFE_ES_ERR_RESOURCEID_NOT_VALID); + /* + * This seems a bit strange that it throws a file io error + * CFE_ES_ReloadApp calls OS_stat with the null filename + * OS_stat should return OS_INVALID_POINTER, but the exact + * error is ignored in CFE_ES_ReloadApp and file io error is returned + * most other functions return a CFE_ES_BAD_ARGUMENT in this situation + */ + UtAssert_UINT32_EQ(CFE_ES_ReloadApp(TestAppId, NULL), CFE_ES_FILE_IO_ERR); + UtAssert_UINT32_EQ(CFE_ES_ReloadApp(TestAppId, "/cf/NOT_cfe_testcase.so"), CFE_ES_FILE_IO_ERR); + UtAssert_UINT32_EQ(CFE_ES_ReloadApp(CFE_ES_APPID_UNDEFINED, "/cf/cfe_testcase.so"), + CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_UINT32_EQ(CFE_ES_DeleteApp(CFE_ES_APPID_UNDEFINED), CFE_ES_ERR_RESOURCEID_NOT_VALID); +} + +void ESApplicationControlTestSetup(void) +{ + UtTest_Add(TestApplicationControl, NULL, NULL, "Test Application Control API"); +}