-
Notifications
You must be signed in to change notification settings - Fork 58
Fix #8, Add sample app tests #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.