Skip to content

Commit

Permalink
Fix #711, Add msg module unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Aug 14, 2020
1 parent 97682b8 commit 164c75e
Show file tree
Hide file tree
Showing 26 changed files with 2,496 additions and 0 deletions.
63 changes: 63 additions & 0 deletions modules/msg/unit-test-coverage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
##################################################################
#
# cFE unit test build recipe
#
# This CMake file contains the recipe for building the cFE unit tests.
# It is invoked from the parent directory when unit tests are enabled.
#
##################################################################

# Unit test object library sources, options, and includes
add_library(ut_${DEP}_objs OBJECT ${${DEP}_SRC})
target_compile_options(ut_${DEP}_objs PRIVATE ${UT_COVERAGE_COMPILE_FLAGS})
target_include_directories(ut_${DEP}_objs PRIVATE
$<TARGET_PROPERTY:${DEP},INCLUDE_DIRECTORIES>)

set (ut_${DEP}_tests
msg_UT.c
test_msg_utils.c
test_msg_not.c
test_msg_pri_not.c
test_cfe_msg_init.c
test_cfe_msg_ccsdspri.c
test_cfe_msg_msgid_shared.c
test_cfe_msg_checksum.c
test_cfe_msg_fc.c
test_cfe_msg_time.c
$<TARGET_OBJECTS:ut_${DEP}_objs>)

# Add extended header tests if appropriate
if (MISSION_INCLUDE_CCSDSEXT_HEADER)
list(APPEND ut_${DEP}_tests
test_msg_ext_not.c
test_cfe_msg_ccsdsext.c)
else (MISSION_INCLUDE_CCSDSEXT_HEADER)
list(APPEND ut_${DEP}_tests
test_msg_prionly.c)
endif (MISSION_INCLUDE_CCSDSEXT_HEADER)

# Add the correct message id test
if (MISSION_MSGID_V2)
list(APPEND ut_${DEP}_tests
test_cfe_msg_msgid_v2.c)
else (MISSION_MSGID_V2)
list(APPEND ut_${DEP}_tests
test_cfe_msg_msgid_v1.c)
endif (MISSION_MSGID_V2)

# Add executable
add_executable(${DEP}_UT ${ut_${DEP}_tests})

# Add include to get private defaults
target_include_directories(${DEP}_UT PRIVATE ../private_inc)

# Also add the UT_COVERAGE_LINK_FLAGS to the link command
# This should enable coverage analysis on platforms that support this
target_link_libraries(${DEP}_UT
${UT_COVERAGE_LINK_FLAGS}
ut_cfe-core_support
ut_cfe-core_stubs
ut_assert)

add_test(${DEP}_UT ${DEP}_UT)
install(TARGETS ${DEP}_UT DESTINATION ${TGTNAME}/${UT_INSTALL_SUBDIR})
55 changes: 55 additions & 0 deletions modules/msg/unit-test-coverage/msg_UT.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
** 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.
*/

/*
* Message header unit tests
*/

/*
* Includes
*/
#include "utassert.h"
#include "ut_support.h"
#include "test_cfe_msg_init.h"
#include "test_cfe_msg_ccsdspri.h"
#include "test_cfe_msg_ccsdsext.h"
#include "test_cfe_msg_msgid_shared.h"
#include "test_cfe_msg_msgid.h"
#include "test_cfe_msg_fc.h"
#include "test_cfe_msg_checksum.h"
#include "test_cfe_msg_time.h"

/*
* Functions
*/
void UtTest_Setup(void)
{
UT_Init("msg");
UT_Text("Message header coverage test...");

UT_ADD_TEST(Test_MSG_Init);
UT_ADD_TEST(Test_MSG_CCSDSPri);
UT_ADD_TEST(Test_MSG_CCSDSExt);
UT_ADD_TEST(Test_MSG_MsgId_Shared);
UT_ADD_TEST(Test_MSG_MsgId);
UT_ADD_TEST(Test_MSG_Checksum);
UT_ADD_TEST(Test_MSG_FcnCode);
UT_ADD_TEST(Test_MSG_Time);
}
Loading

0 comments on commit 164c75e

Please sign in to comment.