Tests can now be built as part of FSFW and versioning moved to CMake #500
Labels
No Label
API Change
Breaking API Change
bug
build
cosmetics
Documentation
duplicate
feature
help wanted
hotfix
invalid
question
Refactor
Tests
wontfix
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: fsfw/fsfw#500
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "KSat/fsfw:mueller/integrated-unittests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The versioning of the FSFW was moved into the
CMakeLists.txt
file.The build system then has access to the version of the FSFW and the built version is now displayed when building the static library.
This PR refactores the tests so they are built as part of the FSFW.
This is done by adding Catch2 with the
FetchContent
directive.CMake also checks whether Catch2 is already available as a package, either because the user
submoduled it or because it was installed.
The custom configuration folder testcfg was moved from the user folder
to the actual unittest folder.
The tests can be built by setting the CMake FSFW_BUILD_UNITTESTS option
to TRUE/ON. They are built with the static library and dropped inside
the build folders fsfw directory.
Coverage information can be built with HTML format using the
cmake-modules
package.It requires a
lcov
(Linux) orgcovr
(Windows) installation.The README was updated with the instructions on how to build the unittests (with coverage).
This PR makes the https://egit.irs.uni-stuttgart.de/fsfw/fsfw-tests repository obsolete. The FSFW forks can now supply tests for new features more easily by simply adding the tests in FSFW and building them with the new instructions.
WIP: Tests can now be built as part of FSFW and versioning moved to CMaketo Tests can now be built as part of FSFW and versioning moved to CMakeTried to run it, with some problems:
/tests/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h
includes"common/events/commonSubsystemIds.h"
,/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h
includes"common/objects/commonObjectsList.h"
and/tests/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h
includes"common/returnvalues/commonClassIds.h"
, all of which I could not find any trace of. Deleting the includes (and in two cases adjusting the starting value of the enums) made the tests compile and run.Additional problems below...
@ -30,0 +56,4 @@
FetchContent_MakeAvailable(Catch2)
endif()
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in tests/FSFWConfig.h)
Needed to move this into the root folder, so that the fsfw components could find it.
This was not an issue for the KSat integration and tests in the hosted FSFW example. It should be enough to have an own configure file for the actualy FSFW application
I can now see what can be problematic.. I am not entirely sure how to solve this
I just changed it to
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h)
@ -30,0 +58,4 @@
configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in tests/FSFWConfig.h)
configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h)
configure_file(tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in tests/OBSWConfig.h)
Seems to be not used atm, only instance is in
/hal/src/fsfw_hal/linux/uart/UartComIF.cpp
, where it is expected in the root folder as well.These configuration files are private to the tests. I wil look into it to figure out how to solve this..
@ -29,1 +40,4 @@
add_library(${LIB_FSFW_NAME})
if(FSFW_BUILD_UNITTESTS)
message(STATUS "Building the FSFW unittests in addition to the static library")
had to set
set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg)
That is possible as well. The path was always set to the user configuration path for my examples
There is an older bug in l.225, where
FSFW_CONFIG_PATH
is checked but not set to the default value if empty, which then breaks the following checks on it.Also, the encoded default location is
defaultcfg/fsfwconfig
while the code location ismisc/defaultcfg/fsfwconfig
Bug in line 225 fixed and includes removed. It might be worth a thought to simply exit here with a fatal error, but I think it is worth the effort to make it still work out of the box.
I am not sure how to solve the issue with the test specific configuration.. It requires adding the tests path inside the build directoryto the include directories for the tests. But the FSFW already specifies the FSFW_CONFIG_PATH as an interface include path, so there will be a conflict. Right now I can't think of a solution which does not make the tests dependant on the user application FSFW configuration in some way..
Regarding the configuration files, I must admit I do not fully understand all the implications of the CMake System here.
But I think when building for unit tests, we can generate the config files in the build path root. I do not think that users will build the unit tests and their FSW in the same build folder/configuration, if that is the problem here.
@ -191,0 +315,4 @@
)
string(CONCAT POST_BUILD_COMMENT
"######################################################################\n"
And a small one, shouldn't this read "built FSFW [...]"
@ -0,0 +1,11 @@
#ifndef FSFW_VERSION_H_
#define FSFW_VERSION_H_
const char* const FSFW_VERSION_NAME = "ASTP";
I think we should remove this as well, not specific to the PR but as we are touching the version anyway...
@ -0,0 +12,4 @@
*/
namespace SUBSYSTEM_ID {
enum: uint8_t {
SUBSYSTEM_ID_START = 0,
FW_SUBSYSTEM_ID_RANGE
iinstead of0
@ -0,0 +1 @@
#include "testCmdExecutor.h"
This feature is has not been merged yet.
@ -0,0 +1,10 @@
#ifndef FSFW_TESTS_SRC_FSFW_TESTS_INTERNAL_OSAL_TESTCMDEXECUTOR_H_
See comment in .cpp
@ -0,0 +12,4 @@
*/
namespace apid {
static const uint16_t DEFAULT_APID = 0x00;
static const uint16_t SOURCE_OBSW = 0x73;
Copy and Paste error
All changes and review suggestions added.
@ -0,0 +2,4 @@
#define CONFIG_DEVICES_LOGICALADDRESSES_H_
#include <fsfw/devicehandlers/CookieIF.h>
#include "common/devices/commonAddresses.h"
another leftover
common
Compiler does not seem to mind, ist the
devices/
folder used?I think it is not used anywhere.. probably can be deleted
I deleted the include, might keep the file for the future
@ -0,0 +2,4 @@
* @brief Auto-generated event translation file. Contains 81 translations.
* @details
* Generated on: 2021-05-18 16:28:16
*/
As this file does not seem to contain 81 translations, we might want to delete the header
file deleted
@ -0,0 +3,4 @@
* @details
* Contains 69 translations.
* Generated on: 2021-05-18 16:37:37
*/
same as with the event translation
file deleted
@ -97,0 +193,4 @@
)
elseif(UNIX)
set(COVERAGE_EXCLUDES
"/usr/include/*" "/usr/bin/*" "Catch2/*"
for me,
"*/catch2-src/*"
was needed to get catch2 out of the reports.How do you feel about adding
"*/fsfw_tests/*"
as well, seems to be a bit too meta to coverage the coverage tests.I actually installed catch2 and did not have that issue, I can add that directive. Adding the tests makes sense as well
Added the excludes
missing a leading * as in
"*/catch2-src/*"
, as catch2 is stashed away somewhere by cmake.Done
I can also not find any use of
tests/user
, is that obsolete as well?It is now. I moved the testtemplate and removed the folder
Phew, I think we're good now. As soon as @gaisser signals contentment, we can close this.