From f061d5dfa853edf6ae88b5e4e56bea4cf1e6681d Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 16 Jul 2020 11:01:05 -0400 Subject: [PATCH] Update #778, add CFE test module --- cmake/arch_build.cmake | 1 - cmake/mission_defaults.cmake | 2 +- modules/cfe_test/CMakeLists.txt | 8 +++++ modules/cfe_test/fsw/src/cfe_test.c | 45 ++++++++++++++++++++++++++++ modules/cfe_test/fsw/src/cfe_test.h | 45 ++++++++++++++++++++++++++++ modules/cfe_test/fsw/src/es_test.c | 46 +++++++++++++++++++++++++++++ 6 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 modules/cfe_test/CMakeLists.txt create mode 100644 modules/cfe_test/fsw/src/cfe_test.c create mode 100644 modules/cfe_test/fsw/src/cfe_test.h create mode 100644 modules/cfe_test/fsw/src/es_test.c diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index db99d03e9..d3b98d4d3 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -215,7 +215,6 @@ function(add_unit_test_exe UT_NAME UT_SRCS) add_test(${UT_NAME} ${UT_NAME}) endfunction(add_unit_test_exe) - ################################################################## # # FUNCTION: cfe_exec_do_install diff --git a/cmake/mission_defaults.cmake b/cmake/mission_defaults.cmake index 629125f93..59cf835a4 100644 --- a/cmake/mission_defaults.cmake +++ b/cmake/mission_defaults.cmake @@ -49,6 +49,6 @@ set(psp_SEARCH_PATH ".") # If ENABLE_UNIT_TEST is enabled, then include the cfe_assert library in # all targets. This can still be overridden in targets.cmake. if (ENABLE_UNIT_TESTS) - list(APPEND MISSION_GLOBAL_APPLIST cfe_assert) + list(APPEND MISSION_GLOBAL_APPLIST cfe_assert cfe_test) endif (ENABLE_UNIT_TESTS) diff --git a/modules/cfe_test/CMakeLists.txt b/modules/cfe_test/CMakeLists.txt new file mode 100644 index 000000000..32ea30194 --- /dev/null +++ b/modules/cfe_test/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories("${CFE_ASSERT_SOURCE_DIR}/fsw/inc") +include_directories("${UT_ASSERT_SOURCE_DIR}/inc") + +# Create the app module +add_cfe_app(cfe_test + fsw/src/cfe_test.c + fsw/src/es_test.c +) diff --git a/modules/cfe_test/fsw/src/cfe_test.c b/modules/cfe_test/fsw/src/cfe_test.c new file mode 100644 index 000000000..fe5842928 --- /dev/null +++ b/modules/cfe_test/fsw/src/cfe_test.c @@ -0,0 +1,45 @@ +/************************************************************************* +** +** 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: cfe_test.c +** +** Purpose: +** Initialization routine for CFE functional test +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +/* + * Includes + */ + +#include "cfe_test.h" + +/* + * Initialization function + * Register this test routine with CFE Assert + */ +int32 CFE_Test_Init(int32 LibId) +{ + UtTest_Add(ES_Test_AppId, NULL, NULL, "ES AppID"); + return CFE_SUCCESS; +} + + diff --git a/modules/cfe_test/fsw/src/cfe_test.h b/modules/cfe_test/fsw/src/cfe_test.h new file mode 100644 index 000000000..77acd1e8a --- /dev/null +++ b/modules/cfe_test/fsw/src/cfe_test.h @@ -0,0 +1,45 @@ +/************************************************************************* +** +** 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: cfe_test.c +** +** Purpose: +** Initialization routine for CFE functional test +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +#ifndef CFE_TEST_H +#define CFE_TEST_H + +/* + * Includes + */ + +#include + +#include "uttest.h" +#include "utassert.h" + +void ES_Test_AppId(void); +int32 CFE_Test_Init(int32 LibId); + + +#endif /* CFE_TEST_H */ diff --git a/modules/cfe_test/fsw/src/es_test.c b/modules/cfe_test/fsw/src/es_test.c new file mode 100644 index 000000000..632b084aa --- /dev/null +++ b/modules/cfe_test/fsw/src/es_test.c @@ -0,0 +1,46 @@ +/************************************************************************* +** +** 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_AppId(void) +{ + uint32 AppId; + char AppNameBuf[OS_MAX_API_NAME+4]; + + UtAssert_INT32_EQ(CFE_ES_GetAppID(&AppId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ES_GetAppName(AppNameBuf, AppId, sizeof(AppNameBuf)), CFE_SUCCESS); + UtAssert_StrCmp(AppNameBuf, "ASSERT_APP", "CFE_ES_GetAppName() returned ASSERT_APP"); +} +