Skip to content

Commit

Permalink
Merge pull request #49 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
Integration Candidate 2020-03-18
  • Loading branch information
astrogeco authored Mar 27, 2020
2 parents 1f84f20 + 24a5bdb commit 602aabe
Showing 10 changed files with 839 additions and 8 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -8,10 +8,17 @@ include_directories(fsw/platform_inc)
# to call library-provided functions
include_directories(${sample_lib_MISSION_DIR}/fsw/public_inc)

aux_source_directory(fsw/src APP_SRC_FILES)

# Create the app module
add_cfe_app(sample_app ${APP_SRC_FILES})
add_cfe_app(sample_app fsw/src/sample_app.c)

# Add table
add_cfe_tables(sampleTable fsw/src/sample_table.c)

# If UT is enabled, then add the tests from the subdirectory
# Note that this is an app, and therefore does not provide
# stub functions, as other entities would not typically make
# direct function calls into this application.
if (ENABLE_UNIT_TESTS)
add_subdirectory(unit-test)
endif (ENABLE_UNIT_TESTS)

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@ This sample application is a non-flight example application implementation for t
sample_app is an example for how to build and link an application in cFS.

## Version Notes

- 1.1.6
- Minor updates (see https://github.com/nasa/sample_app/pull/49)
- 1.1.5
- Fix to build on RASPBIAN OS
- Minor updates (see https://github.com/nasa/sample_app/pull/47)
3 changes: 1 addition & 2 deletions fsw/src/sample_app.c
Original file line number Diff line number Diff line change
@@ -34,9 +34,8 @@
#include "sample_table.h"

/* The sample_lib module provides the SAMPLE_Function() prototype */
#include <sample_lib.h>

#include <string.h>
#include "sample_lib.h"

/*
** global data
2 changes: 1 addition & 1 deletion fsw/src/sample_app_version.h
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@

#define SAMPLE_APP_MAJOR_VERSION 1
#define SAMPLE_APP_MINOR_VERSION 1
#define SAMPLE_APP_REVISION 5
#define SAMPLE_APP_REVISION 6
#define SAMPLE_APP_MISSION_REV 0


2 changes: 1 addition & 1 deletion fsw/src/sample_table.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
**
** GSC-18128-1, "Core Flight Executive Version 6.6"
** 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.
2 changes: 1 addition & 1 deletion fsw/src/sample_table.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
**
** GSC-18128-1, "Core Flight Executive Version 6.6"
** 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.
75 changes: 75 additions & 0 deletions unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
##################################################################
#
# Coverage Unit Test build recipe
#
# This CMake file contains the recipe for building the sample unit tests.
# It is invoked from the parent directory when unit tests are enabled.
#
##################################################################

#
#
# NOTE on the subdirectory structures here:
#
# - "inc" provides local header files shared between the coveragetest,
# wrappers, and overrides source code units
# - "coveragetest" contains source code for the actual unit test cases
# The primary objective is to get line/path coverage on the FSW
# code units.
# - "wrappers" contains wrappers for the FSW code. The wrapper adds
# any UT-specific scaffolding to facilitate the coverage test, and
# includes the unmodified FSW source file.
#

set(UT_NAME sample_app)

# Use the UT assert public API, and allow direct
# inclusion of source files that are normally private
include_directories(${osal_MISSION_DIR}/ut_assert/inc)
include_directories(${PROJECT_SOURCE_DIR}/fsw/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)

# Generate a dedicated "testrunner" executable that executes the tests for each FSW code unit
# Although sample_app has only one source file, this is done in a loop such that
# the general pattern should work for several files as well.
foreach(SRCFILE sample_app.c)
get_filename_component(UNITNAME "${SRCFILE}" NAME_WE)

set(TESTNAME "${UT_NAME}-${UNITNAME}")
set(UNIT_SOURCE_FILE "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/${UNITNAME}.c")
set(TESTCASE_SOURCE_FILE "coveragetest/coveragetest_${UNITNAME}.c")

# Compile the source unit under test as a OBJECT
add_library(ut_${TESTNAME}_object OBJECT
${UNIT_SOURCE_FILE}
)

# Apply the UT_C_FLAGS to the units under test
# This should enable coverage analysis on platforms that support this
set_target_properties(ut_${TESTNAME}_object PROPERTIES
COMPILE_FLAGS "${UT_C_FLAGS}")

# Compile a test runner application, which contains the
# actual coverage test code (test cases) and the unit under test
add_executable(${TESTNAME}-testrunner
${TESTCASE_SOURCE_FILE}
$<TARGET_OBJECTS:ut_${TESTNAME}_object>
)

# This also needs to be linked with UT_C_FLAGS (for coverage)
set_target_properties(${TESTNAME}-testrunner PROPERTIES
LINK_FLAGS "${UT_C_FLAGS}")

# This is also linked with any other stub libraries needed,
# as well as the UT assert framework
target_link_libraries(${TESTNAME}-testrunner
ut_sample_lib_stubs
ut_cfe-core_stubs
ut_assert
)

# Add it to the set of tests to run as part of "make test"
add_test(${TESTNAME} ${TESTNAME}-testrunner)

endforeach()

Loading

0 comments on commit 602aabe

Please sign in to comment.