Skip to content

Commit 602aabe

Browse files
authored
Merge pull request #49 from nasa/integration-candidate
Integration Candidate 2020-03-18
2 parents 1f84f20 + 24a5bdb commit 602aabe

10 files changed

+839
-8
lines changed

CMakeLists.txt

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ include_directories(fsw/platform_inc)
88
# to call library-provided functions
99
include_directories(${sample_lib_MISSION_DIR}/fsw/public_inc)
1010

11-
aux_source_directory(fsw/src APP_SRC_FILES)
12-
1311
# Create the app module
14-
add_cfe_app(sample_app ${APP_SRC_FILES})
12+
add_cfe_app(sample_app fsw/src/sample_app.c)
1513

1614
# Add table
1715
add_cfe_tables(sampleTable fsw/src/sample_table.c)
16+
17+
# If UT is enabled, then add the tests from the subdirectory
18+
# Note that this is an app, and therefore does not provide
19+
# stub functions, as other entities would not typically make
20+
# direct function calls into this application.
21+
if (ENABLE_UNIT_TESTS)
22+
add_subdirectory(unit-test)
23+
endif (ENABLE_UNIT_TESTS)
24+

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ This sample application is a non-flight example application implementation for t
77
sample_app is an example for how to build and link an application in cFS.
88

99
## Version Notes
10+
11+
- 1.1.6
12+
- Minor updates (see https://github.com/nasa/sample_app/pull/49)
1013
- 1.1.5
1114
- Fix to build on RASPBIAN OS
1215
- Minor updates (see https://github.com/nasa/sample_app/pull/47)

fsw/src/sample_app.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434
#include "sample_table.h"
3535

3636
/* The sample_lib module provides the SAMPLE_Function() prototype */
37-
#include <sample_lib.h>
38-
3937
#include <string.h>
38+
#include "sample_lib.h"
4039

4140
/*
4241
** global data

fsw/src/sample_app_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#define SAMPLE_APP_MAJOR_VERSION 1
3535
#define SAMPLE_APP_MINOR_VERSION 1
36-
#define SAMPLE_APP_REVISION 5
36+
#define SAMPLE_APP_REVISION 6
3737
#define SAMPLE_APP_MISSION_REV 0
3838

3939

fsw/src/sample_table.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
**
3-
** GSC-18128-1, "Core Flight Executive Version 6.6"
3+
** GSC-18128-1, "Core Flight Executive Version 6.7"
44
**
55
** Copyright (c) 2006-2019 United States Government as represented by
66
** the Administrator of the National Aeronautics and Space Administration.

fsw/src/sample_table.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
**
3-
** GSC-18128-1, "Core Flight Executive Version 6.6"
3+
** GSC-18128-1, "Core Flight Executive Version 6.7"
44
**
55
** Copyright (c) 2006-2019 United States Government as represented by
66
** the Administrator of the National Aeronautics and Space Administration.

unit-test/CMakeLists.txt

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
##################################################################
2+
#
3+
# Coverage Unit Test build recipe
4+
#
5+
# This CMake file contains the recipe for building the sample unit tests.
6+
# It is invoked from the parent directory when unit tests are enabled.
7+
#
8+
##################################################################
9+
10+
#
11+
#
12+
# NOTE on the subdirectory structures here:
13+
#
14+
# - "inc" provides local header files shared between the coveragetest,
15+
# wrappers, and overrides source code units
16+
# - "coveragetest" contains source code for the actual unit test cases
17+
# The primary objective is to get line/path coverage on the FSW
18+
# code units.
19+
# - "wrappers" contains wrappers for the FSW code. The wrapper adds
20+
# any UT-specific scaffolding to facilitate the coverage test, and
21+
# includes the unmodified FSW source file.
22+
#
23+
24+
set(UT_NAME sample_app)
25+
26+
# Use the UT assert public API, and allow direct
27+
# inclusion of source files that are normally private
28+
include_directories(${osal_MISSION_DIR}/ut_assert/inc)
29+
include_directories(${PROJECT_SOURCE_DIR}/fsw/src)
30+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
31+
32+
# Generate a dedicated "testrunner" executable that executes the tests for each FSW code unit
33+
# Although sample_app has only one source file, this is done in a loop such that
34+
# the general pattern should work for several files as well.
35+
foreach(SRCFILE sample_app.c)
36+
get_filename_component(UNITNAME "${SRCFILE}" NAME_WE)
37+
38+
set(TESTNAME "${UT_NAME}-${UNITNAME}")
39+
set(UNIT_SOURCE_FILE "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/${UNITNAME}.c")
40+
set(TESTCASE_SOURCE_FILE "coveragetest/coveragetest_${UNITNAME}.c")
41+
42+
# Compile the source unit under test as a OBJECT
43+
add_library(ut_${TESTNAME}_object OBJECT
44+
${UNIT_SOURCE_FILE}
45+
)
46+
47+
# Apply the UT_C_FLAGS to the units under test
48+
# This should enable coverage analysis on platforms that support this
49+
set_target_properties(ut_${TESTNAME}_object PROPERTIES
50+
COMPILE_FLAGS "${UT_C_FLAGS}")
51+
52+
# Compile a test runner application, which contains the
53+
# actual coverage test code (test cases) and the unit under test
54+
add_executable(${TESTNAME}-testrunner
55+
${TESTCASE_SOURCE_FILE}
56+
$<TARGET_OBJECTS:ut_${TESTNAME}_object>
57+
)
58+
59+
# This also needs to be linked with UT_C_FLAGS (for coverage)
60+
set_target_properties(${TESTNAME}-testrunner PROPERTIES
61+
LINK_FLAGS "${UT_C_FLAGS}")
62+
63+
# This is also linked with any other stub libraries needed,
64+
# as well as the UT assert framework
65+
target_link_libraries(${TESTNAME}-testrunner
66+
ut_sample_lib_stubs
67+
ut_cfe-core_stubs
68+
ut_assert
69+
)
70+
71+
# Add it to the set of tests to run as part of "make test"
72+
add_test(${TESTNAME} ${TESTNAME}-testrunner)
73+
74+
endforeach()
75+

0 commit comments

Comments
 (0)