From ade15ad16d9d03512b148fa83e1be14cb3d48570 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Oct 2021 13:24:46 +0200 Subject: [PATCH] tests can now be built as part of FSFW This PR refactores the tests so they are built as part of the FSFW. This is done by adding Catch2 with the FetchContent directive. A future implementation might also use a system installation of Catch2 by first checking whether Catch2 can already be found as a package 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. --- CMakeLists.txt | 129 +++++++++++++++++- README.md | 76 ++++++++++- scripts/coverage.py | 74 ++++++++++ tests/src/fsfw_tests/CMakeLists.txt | 2 +- .../internal/InternalUnitTester.cpp | 6 +- .../fsfw_tests/internal/osal/CMakeLists.txt | 6 +- .../internal/osal/testCmdExecutor.cpp | 1 + .../internal/osal/testCmdExecutor.h | 10 ++ .../osal/{IntTestMq.cpp => testMq.cpp} | 2 +- .../internal/osal/{IntTestMq.h => testMq.h} | 0 .../osal/{IntTestMutex.cpp => testMutex.cpp} | 2 +- .../osal/{IntTestMutex.h => testMutex.h} | 0 ...IntTestSemaphore.cpp => testSemaphore.cpp} | 2 +- .../{IntTestSemaphore.h => testSemaphore.h} | 0 tests/src/fsfw_tests/unit/CMakeLists.txt | 9 +- tests/src/fsfw_tests/unit/CatchFactory.h | 2 +- tests/src/fsfw_tests/unit/CatchRunner.cpp | 2 +- tests/src/fsfw_tests/unit/CatchRunner.h | 2 +- .../src/fsfw_tests/unit/action/CMakeLists.txt | 2 +- .../fsfw_tests/unit/container/CMakeLists.txt | 2 +- .../unit/datapoollocal/CMakeLists.txt | 2 +- .../unit/globalfunctions/CMakeLists.txt | 2 +- tests/src/fsfw_tests/unit/osal/CMakeLists.txt | 2 +- .../fsfw_tests/unit/serialize/CMakeLists.txt | 2 +- .../unit/storagemanager/CMakeLists.txt | 2 +- .../fsfw_tests/unit/testcfg/CMakeLists.txt | 28 ++++ .../fsfw_tests/unit}/testcfg/FSFWConfig.h.in | 39 +++--- .../fsfw_tests/unit/testcfg/OBSWConfig.h.in | 15 ++ .../fsfw_tests/unit}/testcfg/TestsConfig.h.in | 0 .../testcfg/devices/logicalAddresses.cpp | 0 .../unit}/testcfg/devices/logicalAddresses.h | 3 +- .../testcfg/devices/powerSwitcherList.cpp | 0 .../unit}/testcfg/devices/powerSwitcherList.h | 0 .../unit}/testcfg/events/subsystemIdRanges.h | 7 +- .../unit/testcfg/events/translateEvents.cpp | 15 ++ .../unit/testcfg/events/translateEvents.h | 8 ++ .../unit}/testcfg/ipc/MissionMessageTypes.cpp | 0 .../unit}/testcfg/ipc/MissionMessageTypes.h | 0 .../unit}/testcfg/objects/systemObjectList.h | 7 +- .../unit/testcfg/objects/translateObjects.cpp | 19 +++ .../unit/testcfg/objects/translateObjects.h | 8 ++ .../PollingSequenceFactory.cpp | 2 +- .../pollingsequence/PollingSequenceFactory.h | 0 .../unit}/testcfg/returnvalues/classIds.h | 3 +- .../fsfw_tests/unit}/testcfg/tmtc/apid.h | 1 + .../fsfw_tests/unit}/testcfg/tmtc/pusIds.h | 0 .../unit/timemanager/CMakeLists.txt | 2 +- .../fsfw_tests/unit/tmtcpacket/CMakeLists.txt | 2 +- tests/user/README.md | 19 --- tests/user/testcfg/CMakeLists.txt | 11 -- tests/user/testcfg/OBSWConfig.h.in | 8 -- 51 files changed, 429 insertions(+), 107 deletions(-) create mode 100755 scripts/coverage.py create mode 100644 tests/src/fsfw_tests/internal/osal/testCmdExecutor.cpp create mode 100644 tests/src/fsfw_tests/internal/osal/testCmdExecutor.h rename tests/src/fsfw_tests/internal/osal/{IntTestMq.cpp => testMq.cpp} (96%) rename tests/src/fsfw_tests/internal/osal/{IntTestMq.h => testMq.h} (100%) rename tests/src/fsfw_tests/internal/osal/{IntTestMutex.cpp => testMutex.cpp} (96%) rename tests/src/fsfw_tests/internal/osal/{IntTestMutex.h => testMutex.h} (100%) rename tests/src/fsfw_tests/internal/osal/{IntTestSemaphore.cpp => testSemaphore.cpp} (98%) rename tests/src/fsfw_tests/internal/osal/{IntTestSemaphore.h => testSemaphore.h} (100%) create mode 100644 tests/src/fsfw_tests/unit/testcfg/CMakeLists.txt rename tests/{user => src/fsfw_tests/unit}/testcfg/FSFWConfig.h.in (67%) create mode 100644 tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in rename tests/{user => src/fsfw_tests/unit}/testcfg/TestsConfig.h.in (100%) rename tests/{user => src/fsfw_tests/unit}/testcfg/devices/logicalAddresses.cpp (100%) rename tests/{user => src/fsfw_tests/unit}/testcfg/devices/logicalAddresses.h (84%) rename tests/{user => src/fsfw_tests/unit}/testcfg/devices/powerSwitcherList.cpp (100%) rename tests/{user => src/fsfw_tests/unit}/testcfg/devices/powerSwitcherList.h (100%) rename tests/{user => src/fsfw_tests/unit}/testcfg/events/subsystemIdRanges.h (64%) create mode 100644 tests/src/fsfw_tests/unit/testcfg/events/translateEvents.cpp create mode 100644 tests/src/fsfw_tests/unit/testcfg/events/translateEvents.h rename tests/{user => src/fsfw_tests/unit}/testcfg/ipc/MissionMessageTypes.cpp (100%) rename tests/{user => src/fsfw_tests/unit}/testcfg/ipc/MissionMessageTypes.h (100%) rename tests/{user => src/fsfw_tests/unit}/testcfg/objects/systemObjectList.h (84%) create mode 100644 tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.cpp create mode 100644 tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.h rename tests/{user => src/fsfw_tests/unit}/testcfg/pollingsequence/PollingSequenceFactory.cpp (97%) rename tests/{user => src/fsfw_tests/unit}/testcfg/pollingsequence/PollingSequenceFactory.h (100%) rename tests/{user => src/fsfw_tests/unit}/testcfg/returnvalues/classIds.h (76%) rename tests/{user => src/fsfw_tests/unit}/testcfg/tmtc/apid.h (90%) rename tests/{user => src/fsfw_tests/unit}/testcfg/tmtc/pusIds.h (100%) delete mode 100644 tests/user/README.md delete mode 100644 tests/user/testcfg/CMakeLists.txt delete mode 100644 tests/user/testcfg/OBSWConfig.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ff66a6d..ff631201 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.13) +set(FSFW_VERSION 2) +set(FSFW_SUBVERSION 0) +set(FSFW_REVISION 0) + option(FSFW_GENERATE_SECTIONS "Generate function and data sections. Required to remove unused code" ON ) @@ -7,6 +11,11 @@ if(FSFW_GENERATE_SECTIONS) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() +option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF) +if(FSFW_BUILD_UNITTESTS) + option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) +endif() + option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON) # Options to exclude parts of the FSFW from compilation. option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON) @@ -26,11 +35,57 @@ option(FSFW_ADD_TMSTORAGE "Compile with tm storage components" OFF) option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) set(LIB_FSFW_NAME fsfw) +set(FSFW_TEST_TGT fsfw-tests) + add_library(${LIB_FSFW_NAME}) + +if(FSFW_BUILD_UNITTESTS) + # Check whether the user has already installed Catch2 first + find_package(Catch2 3) + # Not installed, so use FetchContent to download and provide Catch2 + if(NOT Catch2_FOUND) + include(FetchContent) + + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.0.0-preview3 + ) + + FetchContent_MakeAvailable(Catch2) + endif() + + 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) + add_executable(${FSFW_TEST_TGT}) + + if(FSFW_TESTS_GEN_COV) + include(FetchContent) + FetchContent_Declare( + cmake-modules + GIT_REPOSITORY https://github.com/bilke/cmake-modules.git + ) + FetchContent_MakeAvailable(cmake-modules) + list(APPEND CMAKE_MODULE_PATH ${cmake-modules_SOURCE_DIR}) + include(CodeCoverage) + endif() +endif() + set(FSFW_CORE_INC_PATH "inc") set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos) +# Configure Files +target_include_directories(${LIB_FSFW_NAME} PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} +) +target_include_directories(${LIB_FSFW_NAME} INTERFACE + ${CMAKE_CURRENT_BINARY_DIR} +) +configure_file(src/fsfw/FSFW.h.in FSFW.h) +configure_file(src/fsfw/FSFWVersion.h.in FSFWVersion.h) + if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -63,29 +118,29 @@ endif() set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST) if(FSFW_OSAL MATCHES host) - set(OS_FSFW_NAME "Host") + set(FSFW_OS_NAME "Host") set(FSFW_OSAL_HOST ON) elseif(FSFW_OSAL MATCHES linux) - set(OS_FSFW_NAME "Linux") + set(FSFW_OS_NAME "Linux") set(FSFW_OSAL_LINUX ON) elseif(FSFW_OSAL MATCHES freertos) - set(OS_FSFW_NAME "FreeRTOS") + set(FSFW_OS_NAME "FreeRTOS") set(FSFW_OSAL_FREERTOS ON) target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_OS_NAME} ) elseif(FSFW_OSAL STREQUAL rtems) - set(OS_FSFW_NAME "RTEMS") + set(FSFW_OS_NAME "RTEMS") set(FSFW_OSAL_RTEMS ON) else() message(WARNING "Invalid operating system for FSFW specified! Setting to host.." ) - set(OS_FSFW_NAME "Host") + set(FSFW_OS_NAME "Host") set(OS_FSFW "host") endif() -message(STATUS "Compiling FSFW for the ${OS_FSFW_NAME} operating system.") +message(STATUS "Compiling FSFW for the ${FSFW_OS_NAME} operating system.") add_subdirectory(src) add_subdirectory(tests) @@ -94,6 +149,66 @@ if(FSFW_ADD_HAL) endif() add_subdirectory(contrib) +if(FSFW_BUILD_UNITTESTS) + if(FSFW_TESTS_GEN_COV) + if(CMAKE_COMPILER_IS_GNUCXX) + include(CodeCoverage) + + # Remove quotes. + separate_arguments(COVERAGE_COMPILER_FLAGS + NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}" + ) + + # Add compile options manually, we don't want coverage for Catch2 + target_compile_options(${FSFW_TEST_TGT} PRIVATE + "${COVERAGE_COMPILER_FLAGS}" + ) + target_compile_options(${LIB_FSFW_NAME} PRIVATE + "${COVERAGE_COMPILER_FLAGS}" + ) + + # Exclude directories here + if(WIN32) + set(GCOVR_ADDITIONAL_ARGS + "--exclude-throw-branches" + "--exclude-unreachable-branches" + ) + set(COVERAGE_EXCLUDES + "/c/msys64/mingw64/*" + ) + elseif(UNIX) + set(COVERAGE_EXCLUDES + "/usr/include/*" "/usr/bin/*" "Catch2/*" + ) + endif() + + target_link_options(${FSFW_TEST_TGT} PRIVATE + -fprofile-arcs + -ftest-coverage + ) + target_link_options(${LIB_FSFW_NAME} PRIVATE + -fprofile-arcs + -ftest-coverage + ) + + if(WIN32) + setup_target_for_coverage_gcovr_html( + NAME ${FSFW_TEST_TGT}_coverage + EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT} + ) + else() + setup_target_for_coverage_lcov( + NAME ${FSFW_TEST_TGT}_coverage + EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT} + ) + endif() + endif() + endif() + target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME}) +endif() + # The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. # If this is not given, we include the default configuration and emit a warning. if(NOT FSFW_CONFIG_PATH) @@ -186,4 +301,4 @@ target_compile_options(${LIB_FSFW_NAME} PRIVATE target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ADDITIONAL_LINK_LIBS} -) \ No newline at end of file +) diff --git a/README.md b/README.md index 48d2b8e7..a7ae0e20 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,83 @@ Currently, the FSFW provides the following OSALs: - FreeRTOS - RTEMS -The recommended hardware is a microprocessor with more than 1 MB of RAM and 1 MB of non-volatile Memory. For reference, current applications use a Cobham Gaisler UT699 (LEON3FT), a ISISPACE IOBC or a Zynq-7020 SoC. The `fsfw` was also successfully run on the STM32H743ZI-Nucleo board and on a Raspberry Pi and is currently running on the active satellite mission Flying Laptop. +The recommended hardware is a microprocessor with more than 1 MB of RAM and 1 MB of non-volatile +memory. For reference, current applications use a Cobham Gaisler UT699 (LEON3FT), a +ISISPACE IOBC or a Zynq-7020 SoC. The `fsfw` was also successfully run on the +STM32H743ZI-Nucleo board and on a Raspberry Pi and is currently running on the active +satellite mission Flying Laptop. ## Getting started -The [FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example) provides a good starting point and a demo to see the FSFW capabilities and build it with the Make or the CMake build system. It is recommended to evaluate the FSFW by building and playing around with the demo application. +The [Hosted FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-hosted) provides a +good starting point and a demo to see the FSFW capabilities. +It is recommended to get started by building and playing around with the demo application. +There are also other examples provided for all OSALs using the popular embedded platforms +Raspberry Pi, Beagle Bone Black and STM32H7. -Generally, the FSFW is included in a project by compiling the FSFW sources and providing -a configuration folder and adding it to the include path. There are some functions like `printChar` which are different depending on the target architecture and need to be implemented by the mission developer. +Generally, the FSFW is included in a project by providing +a configuration folder, building the static library and linking against it. +There are some functions like `printChar` which are different depending on the target architecture +and need to be implemented by the mission developer. A template configuration folder was provided and can be copied into the project root to have -a starting point. The [configuration section](doc/README-config.md#top) provides more specific information about the possible options. +a starting point. The [configuration section](doc/README-config.md#top) provides more specific +information about the possible options. + +## Adding the library + +The following steps show how to add and use FSFW components. It is still recommended to +try out the example mentioned above to get started, but the following steps show how to +add and link against the FSFW library in general. + +1. Add this repository as a submodule + + ```sh + git submodule add https://egit.irs.uni-stuttgart.de/fsfw/fsfw.git fsfw + ``` + +2. Add the following directive inside the uppermost `CMakeLists.txt` file of your project + + ```cmake + add_subdirectory(fsfw) + ``` + +3. Make sure to provide a configuration folder and supply the path to that folder with + the `FSFW_CONFIG_PATH` CMake variable from the uppermost `CMakeLists.txt` file. + It is also necessary to provide the `printChar` function. You can find an example + implementation for a hosted build + [here](https://egit.irs.uni-stuttgart.de/fsfw/fsfw-example-hosted/src/branch/master/bsp_hosted/utility/printChar.c). + +4. Link against the FSFW library + + ```cmake + target_link_libraries( PRIVATE fsfw) + ``` + +5. It should now be possible use the FSFW as a static library from the user code. + +## Building the unittests + +The FSFW also has unittests which use the [Catch2 library](https://github.com/catchorg/Catch2). +These are built by setting the CMake option `FSFW_BUILD_UNITTESTS` to `ON` or `TRUE` +from your project `CMakeLists.txt` file or from the command line. + +The fsfw-tests binary will be built as part of the static library and dropped alongside it inside +the `fsfw` folder of the build folder. + +If the unittests are built, the library and the tests will be built with coverage information by +default. This can be disabled by setting the `FSFW_TESTS_COV_GEN` option to `OFF` or `FALSE`. + +Coverage data in HTML format can be generated using the `CodeCoverage` +[CMake module](https://github.com/bilke/cmake-modules/tree/master). +To build the unittests, run them and then generare the coverage data in this format, +the following command can be used inside the build directory after the build system was set up + +```sh +cmake --build . -- fsfw-tests_coverage -j +``` + +The `coverage.py` script located in the `script` folder can also be used to do this conveniently. ## Index diff --git a/scripts/coverage.py b/scripts/coverage.py new file mode 100755 index 00000000..d15c3154 --- /dev/null +++ b/scripts/coverage.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -* +"""Small portable helper script to generate LCOV HTML coverage data""" +import os +import platform +import sys +import time +import argparse +from typing import List + + +"""Copy this helper script into your project folder. It will try to determine a CMake build folder +and then attempt to build your project with coverage information. + +See Unittest documentation at https://egit.irs.uni-stuttgart.de/fsfw/fsfw for more +information how to set up the build folder. +""" +def main(): + + parser = argparse.ArgumentParser(description="Processing arguments for LCOV helper script.") + + build_dir_list = [] + for directory in os.listdir("."): + if os.path.isdir(directory): + os.chdir(directory) + check_for_cmake_build_dir(build_dir_list) + os.chdir("..") + + if len(build_dir_list) == 0: + print("No valid CMake build directory found. Trying to set up hosted build") + build_directory = 'build-Debug-Host' + os.mkdir(build_directory) + os.chdir(build_directory) + os.system('cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..') + os.chdir('..') + elif len(build_dir_list) == 1: + build_directory = build_dir_list[0] + else: + print("Multiple build directories found!") + build_directory = determine_build_dir(build_dir_list) + perform_lcov_operation(build_directory) + + +def check_for_cmake_build_dir(build_dir_dict: list): + if os.path.isfile("CMakeCache.txt"): + build_dir_dict.append(os.getcwd()) + + +def perform_lcov_operation(directory): + os.chdir(directory) + os.system("cmake --build . -- fsfw-tests_coverage -j") + + +def determine_build_dir(build_dir_list: List[str]): + build_directory = "" + for idx, directory in enumerate(build_dir_list): + print(f"{idx + 1}: {directory}") + while True: + idx = input("Pick the directory to perform LCOV HTML generation by index: ") + if not idx.isdigit(): + print("Invalid input!") + continue + + idx = int(idx) + if idx > len(build_dir_list) or idx < 1: + print("Invalid input!") + continue + build_directory = build_dir_list[idx - 1] + break + return build_directory + + +if __name__ == "__main__": + main() diff --git a/tests/src/fsfw_tests/CMakeLists.txt b/tests/src/fsfw_tests/CMakeLists.txt index e4a6be80..80efdeaf 100644 --- a/tests/src/fsfw_tests/CMakeLists.txt +++ b/tests/src/fsfw_tests/CMakeLists.txt @@ -3,6 +3,6 @@ if(FSFW_ADD_INTERNAL_TESTS) add_subdirectory(internal) endif() -if(FSFW_ADD_UNITTESTS) +if(FSFW_BUILD_UNITTESTS) add_subdirectory(unit) endif() diff --git a/tests/src/fsfw_tests/internal/InternalUnitTester.cpp b/tests/src/fsfw_tests/internal/InternalUnitTester.cpp index 20998d64..3c8eec1e 100644 --- a/tests/src/fsfw_tests/internal/InternalUnitTester.cpp +++ b/tests/src/fsfw_tests/internal/InternalUnitTester.cpp @@ -1,9 +1,9 @@ #include "fsfw_tests/internal/InternalUnitTester.h" #include "fsfw_tests/internal/UnittDefinitions.h" -#include "fsfw_tests/internal/osal/IntTestMq.h" -#include "fsfw_tests/internal/osal/IntTestSemaphore.h" -#include "fsfw_tests/internal/osal/IntTestMutex.h" +#include "fsfw_tests/internal/osal/testMq.h" +#include "fsfw_tests/internal/osal/testSemaphore.h" +#include "fsfw_tests/internal/osal/testMutex.h" #include "fsfw_tests/internal/serialize/IntTestSerialization.h" #include "fsfw_tests/internal/globalfunctions/TestArrayPrinter.h" diff --git a/tests/src/fsfw_tests/internal/osal/CMakeLists.txt b/tests/src/fsfw_tests/internal/osal/CMakeLists.txt index 84316089..8d79d759 100644 --- a/tests/src/fsfw_tests/internal/osal/CMakeLists.txt +++ b/tests/src/fsfw_tests/internal/osal/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(${LIB_FSFW_NAME} PRIVATE - IntTestMq.cpp - IntTestMutex.cpp - IntTestSemaphore.cpp + testMq.cpp + testMutex.cpp + testSemaphore.cpp ) diff --git a/tests/src/fsfw_tests/internal/osal/testCmdExecutor.cpp b/tests/src/fsfw_tests/internal/osal/testCmdExecutor.cpp new file mode 100644 index 00000000..f0bed8ad --- /dev/null +++ b/tests/src/fsfw_tests/internal/osal/testCmdExecutor.cpp @@ -0,0 +1 @@ +#include "testCmdExecutor.h" diff --git a/tests/src/fsfw_tests/internal/osal/testCmdExecutor.h b/tests/src/fsfw_tests/internal/osal/testCmdExecutor.h new file mode 100644 index 00000000..4779dde9 --- /dev/null +++ b/tests/src/fsfw_tests/internal/osal/testCmdExecutor.h @@ -0,0 +1,10 @@ +#ifndef FSFW_TESTS_SRC_FSFW_TESTS_INTERNAL_OSAL_TESTCMDEXECUTOR_H_ +#define FSFW_TESTS_SRC_FSFW_TESTS_INTERNAL_OSAL_TESTCMDEXECUTOR_H_ + +namespace testcmdexec { + +} + + + +#endif /* FSFW_TESTS_SRC_FSFW_TESTS_INTERNAL_OSAL_TESTCMDEXECUTOR_H_ */ diff --git a/tests/src/fsfw_tests/internal/osal/IntTestMq.cpp b/tests/src/fsfw_tests/internal/osal/testMq.cpp similarity index 96% rename from tests/src/fsfw_tests/internal/osal/IntTestMq.cpp rename to tests/src/fsfw_tests/internal/osal/testMq.cpp index 6c31b354..8a252910 100644 --- a/tests/src/fsfw_tests/internal/osal/IntTestMq.cpp +++ b/tests/src/fsfw_tests/internal/osal/testMq.cpp @@ -1,4 +1,4 @@ -#include "fsfw_tests/internal/osal/IntTestMq.h" +#include "testMq.h" #include "fsfw_tests/internal/UnittDefinitions.h" #include diff --git a/tests/src/fsfw_tests/internal/osal/IntTestMq.h b/tests/src/fsfw_tests/internal/osal/testMq.h similarity index 100% rename from tests/src/fsfw_tests/internal/osal/IntTestMq.h rename to tests/src/fsfw_tests/internal/osal/testMq.h diff --git a/tests/src/fsfw_tests/internal/osal/IntTestMutex.cpp b/tests/src/fsfw_tests/internal/osal/testMutex.cpp similarity index 96% rename from tests/src/fsfw_tests/internal/osal/IntTestMutex.cpp rename to tests/src/fsfw_tests/internal/osal/testMutex.cpp index d9184cd8..9b50121a 100644 --- a/tests/src/fsfw_tests/internal/osal/IntTestMutex.cpp +++ b/tests/src/fsfw_tests/internal/osal/testMutex.cpp @@ -1,4 +1,4 @@ -#include "fsfw_tests/internal/osal/IntTestMutex.h" +#include "testMutex.h" #include "fsfw_tests/internal/UnittDefinitions.h" #include "fsfw/platform.h" diff --git a/tests/src/fsfw_tests/internal/osal/IntTestMutex.h b/tests/src/fsfw_tests/internal/osal/testMutex.h similarity index 100% rename from tests/src/fsfw_tests/internal/osal/IntTestMutex.h rename to tests/src/fsfw_tests/internal/osal/testMutex.h diff --git a/tests/src/fsfw_tests/internal/osal/IntTestSemaphore.cpp b/tests/src/fsfw_tests/internal/osal/testSemaphore.cpp similarity index 98% rename from tests/src/fsfw_tests/internal/osal/IntTestSemaphore.cpp rename to tests/src/fsfw_tests/internal/osal/testSemaphore.cpp index 4b28f961..458dcb04 100644 --- a/tests/src/fsfw_tests/internal/osal/IntTestSemaphore.cpp +++ b/tests/src/fsfw_tests/internal/osal/testSemaphore.cpp @@ -1,5 +1,5 @@ #include "fsfw/FSFW.h" -#include "fsfw_tests/internal/osal/IntTestSemaphore.h" +#include "testSemaphore.h" #include "fsfw_tests/internal/UnittDefinitions.h" #include "fsfw/tasks/SemaphoreFactory.h" diff --git a/tests/src/fsfw_tests/internal/osal/IntTestSemaphore.h b/tests/src/fsfw_tests/internal/osal/testSemaphore.h similarity index 100% rename from tests/src/fsfw_tests/internal/osal/IntTestSemaphore.h rename to tests/src/fsfw_tests/internal/osal/testSemaphore.h diff --git a/tests/src/fsfw_tests/unit/CMakeLists.txt b/tests/src/fsfw_tests/unit/CMakeLists.txt index f30e4b6b..164e3bde 100644 --- a/tests/src/fsfw_tests/unit/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/CMakeLists.txt @@ -1,16 +1,17 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE CatchDefinitions.cpp CatchFactory.cpp printChar.cpp ) -if(FSFW_CUSTOM_UNITTEST_RUNNER) - target_sources(${TARGET_NAME} PRIVATE +# if(FSFW_CUSTOM_UNITTEST_RUNNER) + target_sources(${FSFW_TEST_TGT} PRIVATE CatchRunner.cpp CatchSetup.cpp ) -endif() +# endif() +add_subdirectory(testcfg) add_subdirectory(action) add_subdirectory(container) add_subdirectory(osal) diff --git a/tests/src/fsfw_tests/unit/CatchFactory.h b/tests/src/fsfw_tests/unit/CatchFactory.h index 38ec46bd..cc14e3d9 100644 --- a/tests/src/fsfw_tests/unit/CatchFactory.h +++ b/tests/src/fsfw_tests/unit/CatchFactory.h @@ -1,7 +1,7 @@ #ifndef FSFW_CATCHFACTORY_H_ #define FSFW_CATCHFACTORY_H_ -#include "TestsConfig.h" +#include "tests/TestsConfig.h" #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/objectmanager/ObjectManager.h" diff --git a/tests/src/fsfw_tests/unit/CatchRunner.cpp b/tests/src/fsfw_tests/unit/CatchRunner.cpp index c96db7f4..1ea3ab35 100644 --- a/tests/src/fsfw_tests/unit/CatchRunner.cpp +++ b/tests/src/fsfw_tests/unit/CatchRunner.cpp @@ -14,7 +14,7 @@ extern int customSetup(); -int fsfwtest::customMain(int argc, char* argv[]) { +int main(int argc, char* argv[]) { customSetup(); // Catch internal function call diff --git a/tests/src/fsfw_tests/unit/CatchRunner.h b/tests/src/fsfw_tests/unit/CatchRunner.h index 720625c6..06ff07b6 100644 --- a/tests/src/fsfw_tests/unit/CatchRunner.h +++ b/tests/src/fsfw_tests/unit/CatchRunner.h @@ -7,7 +7,7 @@ namespace fsfwtest { * Can be called by upper level main() if default Catch2 main is overriden * @return */ -int customMain(int argc, char* argv[]); +//int customMain(int argc, char* argv[]); } diff --git a/tests/src/fsfw_tests/unit/action/CMakeLists.txt b/tests/src/fsfw_tests/unit/action/CMakeLists.txt index 0339000f..659f251a 100644 --- a/tests/src/fsfw_tests/unit/action/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/action/CMakeLists.txt @@ -1,3 +1,3 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE TestActionHelper.cpp ) diff --git a/tests/src/fsfw_tests/unit/container/CMakeLists.txt b/tests/src/fsfw_tests/unit/container/CMakeLists.txt index 966c5834..5dae974c 100644 --- a/tests/src/fsfw_tests/unit/container/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/container/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE RingBufferTest.cpp TestArrayList.cpp TestDynamicFifo.cpp diff --git a/tests/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt b/tests/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt index 1c98e7dc..bf465282 100644 --- a/tests/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE LocalPoolVariableTest.cpp LocalPoolVectorTest.cpp DataSetTest.cpp diff --git a/tests/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt b/tests/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt index 617c7f5a..209ce75f 100644 --- a/tests/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt @@ -1,3 +1,3 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE testDleEncoder.cpp ) diff --git a/tests/src/fsfw_tests/unit/osal/CMakeLists.txt b/tests/src/fsfw_tests/unit/osal/CMakeLists.txt index 5ca5e400..293be2e8 100644 --- a/tests/src/fsfw_tests/unit/osal/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/osal/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE TestMessageQueue.cpp TestSemaphore.cpp ) diff --git a/tests/src/fsfw_tests/unit/serialize/CMakeLists.txt b/tests/src/fsfw_tests/unit/serialize/CMakeLists.txt index 5a9d9a0f..96c80f4a 100644 --- a/tests/src/fsfw_tests/unit/serialize/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/serialize/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE TestSerialBufferAdapter.cpp TestSerialization.cpp TestSerialLinkedPacket.cpp diff --git a/tests/src/fsfw_tests/unit/storagemanager/CMakeLists.txt b/tests/src/fsfw_tests/unit/storagemanager/CMakeLists.txt index ed7be7d5..7b6280df 100644 --- a/tests/src/fsfw_tests/unit/storagemanager/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/storagemanager/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE TestNewAccessor.cpp TestPool.cpp ) diff --git a/tests/src/fsfw_tests/unit/testcfg/CMakeLists.txt b/tests/src/fsfw_tests/unit/testcfg/CMakeLists.txt new file mode 100644 index 00000000..3272958a --- /dev/null +++ b/tests/src/fsfw_tests/unit/testcfg/CMakeLists.txt @@ -0,0 +1,28 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + ipc/MissionMessageTypes.cpp + pollingsequence/PollingSequenceFactory.cpp +) + +# Add include paths for the executable +target_include_directories(${FSFW_TEST_TGT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +# These translation files are actually not that relevant for the tests. However, the FSFW tests +# compile against a user-configured variant of the FSFW, which might be configured to include +# translation information. Therefore, empty dummy translation files are compiled here +# so the tests compile in any case. + +# If a special translation file for object IDs exists, compile it. +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") + target_sources(${FSFW_TEST_TGT} PRIVATE + objects/translateObjects.cpp + ) +endif() + +# If a special translation file for events exists, compile it. +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") + target_sources(${FSFW_TEST_TGT} PRIVATE + events/translateEvents.cpp + ) +endif() \ No newline at end of file diff --git a/tests/user/testcfg/FSFWConfig.h.in b/tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in similarity index 67% rename from tests/user/testcfg/FSFWConfig.h.in rename to tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in index d38f0648..d03ec3e5 100644 --- a/tests/user/testcfg/FSFWConfig.h.in +++ b/tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in @@ -7,33 +7,30 @@ //! Used to determine whether C++ ostreams are used which can increase //! the binary size significantly. If this is disabled, //! the C stdio functions can be used alternatively -#define FSFW_CPP_OSTREAM_ENABLED 0 +#define FSFW_CPP_OSTREAM_ENABLED 0 -//! More FSFW related printouts. Useful for development. -#define FSFW_ENHANCED_PRINTOUT 0 +//! More FSFW related printouts depending on level. Useful for development. +#define FSFW_VERBOSE_LEVEL 1 //! Can be used to completely disable printouts, even the C stdio ones. -//! By default, printouts will be disabled for the unit tests. -#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_ENHANCED_PRINTOUT == 0 - #ifndef FSFW_DISABLE_PRINTOUT - #define FSFW_DISABLE_PRINTOUT 1 - #endif +#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_VERBOSE_LEVEL == 0 + #define FSFW_DISABLE_PRINTOUT 0 #endif -//! Can be used to enable additional debugging printouts for developing the FSFW -#define FSFW_PRINT_VERBOSITY_LEVEL 0 +#define FSFW_USE_PUS_C_TELEMETRY 1 +#define FSFW_USE_PUS_C_TELECOMMANDS 1 //! Can be used to disable the ANSI color sequences for C stdio. -#define FSFW_COLORED_OUTPUT 0 +#define FSFW_COLORED_OUTPUT 1 //! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! additional output which requires the translation files translateObjects //! and translateEvents (and their compiled source files) -#define FSFW_OBJ_EVENT_TRANSLATION 0 +#define FSFW_OBJ_EVENT_TRANSLATION 0 #if FSFW_OBJ_EVENT_TRANSLATION == 1 //! Specify whether info events are printed too. -#define FSFW_DEBUG_INFO 1 +#define FSFW_DEBUG_INFO 1 #include "objects/translateObjects.h" #include "events/translateEvents.h" #else @@ -41,22 +38,22 @@ //! When using the newlib nano library, C99 support for stdio facilities //! will not be provided. This define should be set to 1 if this is the case. -#define FSFW_NO_C99_IO 1 +#define FSFW_NO_C99_IO 1 //! Specify whether a special mode store is used for Subsystem components. -#define FSFW_USE_MODESTORE 0 +#define FSFW_USE_MODESTORE 0 //! Defines if the real time scheduler for linux should be used. //! If set to 0, this will also disable priority settings for linux //! as most systems will not allow to set nice values without privileges //! For embedded linux system set this to 1. //! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run -#define FSFW_USE_REALTIME_FOR_LINUX 1 +#define FSFW_USE_REALTIME_FOR_LINUX 1 namespace fsfwconfig { -//! Default timestamp size. The default timestamp will be an eight byte CDC -//! short timestamp. -static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8; + +//! Default timestamp size. The default timestamp will be an seven byte CDC short timestamp. +static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 7; //! Configure the allocated pool sizes for the event manager. static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; @@ -65,13 +62,13 @@ static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; //! Defines the FIFO depth of each commanding service base which //! also determines how many commands a CSB service can handle in one cycle -//! simulataneously. This will increase the required RAM for +//! simultaneously. This will increase the required RAM for //! each CSB service ! static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124; -static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 1500; +static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048; } diff --git a/tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in b/tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in new file mode 100644 index 00000000..5d8a9255 --- /dev/null +++ b/tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in @@ -0,0 +1,15 @@ +#ifndef CONFIG_TMTC_TMTCSIZE_H_ +#define CONFIG_TMTC_TMTCSIZE_H_ + +#include +#include + +#define OBSW_PRINT_MISSED_DEADLINES 0 +#define OBSW_VERBOSE_LEVEL 0 +#define OBSW_ADD_TEST_CODE 1 + +namespace config { +static constexpr uint32_t MAX_STORED_TELECOMMANDS = 2000; +} + +#endif /* CONFIG_TMTC_TMTCSIZE_H_ */ diff --git a/tests/user/testcfg/TestsConfig.h.in b/tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in similarity index 100% rename from tests/user/testcfg/TestsConfig.h.in rename to tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in diff --git a/tests/user/testcfg/devices/logicalAddresses.cpp b/tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp similarity index 100% rename from tests/user/testcfg/devices/logicalAddresses.cpp rename to tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp diff --git a/tests/user/testcfg/devices/logicalAddresses.h b/tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h similarity index 84% rename from tests/user/testcfg/devices/logicalAddresses.h rename to tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h index cdf87025..a0240037 100644 --- a/tests/user/testcfg/devices/logicalAddresses.h +++ b/tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h @@ -2,7 +2,8 @@ #define CONFIG_DEVICES_LOGICALADDRESSES_H_ #include -#include +#include "common/devices/commonAddresses.h" + #include namespace addresses { diff --git a/tests/user/testcfg/devices/powerSwitcherList.cpp b/tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp similarity index 100% rename from tests/user/testcfg/devices/powerSwitcherList.cpp rename to tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp diff --git a/tests/user/testcfg/devices/powerSwitcherList.h b/tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h similarity index 100% rename from tests/user/testcfg/devices/powerSwitcherList.h rename to tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h diff --git a/tests/user/testcfg/events/subsystemIdRanges.h b/tests/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h similarity index 64% rename from tests/user/testcfg/events/subsystemIdRanges.h rename to tests/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h index 24eee819..c9c7c20d 100644 --- a/tests/user/testcfg/events/subsystemIdRanges.h +++ b/tests/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h @@ -1,8 +1,10 @@ #ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#include "fsfw/events/fwSubsystemIdRanges.h" +#include "common/events/commonSubsystemIds.h" #include -#include + /** * @brief Custom subsystem IDs can be added here @@ -11,7 +13,8 @@ */ namespace SUBSYSTEM_ID { enum: uint8_t { - SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, + SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_RANGE, + SUBSYSTEM_ID_END // [EXPORT] : [END] }; } diff --git a/tests/src/fsfw_tests/unit/testcfg/events/translateEvents.cpp b/tests/src/fsfw_tests/unit/testcfg/events/translateEvents.cpp new file mode 100644 index 00000000..47186727 --- /dev/null +++ b/tests/src/fsfw_tests/unit/testcfg/events/translateEvents.cpp @@ -0,0 +1,15 @@ +/** + * @brief Auto-generated event translation file. Contains 81 translations. + * @details + * Generated on: 2021-05-18 16:28:16 + */ +#include "translateEvents.h" + + +const char * translateEvents(Event event) { + switch( (event & 0xffff) ) { + default: + return "UNKNOWN_EVENT"; + } + return 0; +} diff --git a/tests/src/fsfw_tests/unit/testcfg/events/translateEvents.h b/tests/src/fsfw_tests/unit/testcfg/events/translateEvents.h new file mode 100644 index 00000000..9034dcf2 --- /dev/null +++ b/tests/src/fsfw_tests/unit/testcfg/events/translateEvents.h @@ -0,0 +1,8 @@ +#ifndef FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ +#define FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ + +#include + +const char * translateEvents(Event event); + +#endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/tests/user/testcfg/ipc/MissionMessageTypes.cpp b/tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp similarity index 100% rename from tests/user/testcfg/ipc/MissionMessageTypes.cpp rename to tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp diff --git a/tests/user/testcfg/ipc/MissionMessageTypes.h b/tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h similarity index 100% rename from tests/user/testcfg/ipc/MissionMessageTypes.h rename to tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h diff --git a/tests/user/testcfg/objects/systemObjectList.h b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h similarity index 84% rename from tests/user/testcfg/objects/systemObjectList.h rename to tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h index efd21e0d..bd0daa62 100644 --- a/tests/user/testcfg/objects/systemObjectList.h +++ b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h @@ -1,8 +1,9 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ +#include "fsfw/objectmanager/frameworkObjects.h" +#include "common/objects/commonObjectsList.h" #include -#include // The objects will be instantiated in the ID order namespace objects { @@ -11,10 +12,6 @@ namespace objects { FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, FSFW_CONFIG_RESERVED_END = TM_STORE, - CCSDS_DISTRIBUTOR = 10, - PUS_DISTRIBUTOR = 11, - TM_FUNNEL = 12, - UDP_BRIDGE = 15, UDP_POLLING_TASK = 16, diff --git a/tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.cpp b/tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.cpp new file mode 100644 index 00000000..63636ced --- /dev/null +++ b/tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.cpp @@ -0,0 +1,19 @@ +/** + * @brief Auto-generated object translation file. + * @details + * Contains 69 translations. + * Generated on: 2021-05-18 16:37:37 + */ +#include "translateObjects.h" + +const char *NO_OBJECT_STRING = "NO_OBJECT"; + +const char* translateObject(object_id_t object) { + switch( (object & 0xFFFFFFFF) ) { + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; +} diff --git a/tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.h b/tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.h new file mode 100644 index 00000000..dbf5b468 --- /dev/null +++ b/tests/src/fsfw_tests/unit/testcfg/objects/translateObjects.h @@ -0,0 +1,8 @@ +#ifndef FSFWCONFIG_OBJECTS_TRANSLATEOBJECTS_H_ +#define FSFWCONFIG_OBJECTS_TRANSLATEOBJECTS_H_ + +#include + +const char* translateObject(object_id_t object); + +#endif /* FSFWCONFIG_OBJECTS_TRANSLATEOBJECTS_H_ */ diff --git a/tests/user/testcfg/pollingsequence/PollingSequenceFactory.cpp b/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp similarity index 97% rename from tests/user/testcfg/pollingsequence/PollingSequenceFactory.cpp rename to tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp index e3ee874a..1d29ef86 100644 --- a/tests/user/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -1,6 +1,6 @@ #include "PollingSequenceFactory.h" -#include +#include "tests/TestsConfig.h" #include #include diff --git a/tests/user/testcfg/pollingsequence/PollingSequenceFactory.h b/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h similarity index 100% rename from tests/user/testcfg/pollingsequence/PollingSequenceFactory.h rename to tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h diff --git a/tests/user/testcfg/returnvalues/classIds.h b/tests/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h similarity index 76% rename from tests/user/testcfg/returnvalues/classIds.h rename to tests/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h index 606cc60b..919b9628 100644 --- a/tests/user/testcfg/returnvalues/classIds.h +++ b/tests/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h @@ -1,7 +1,8 @@ #ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ #define CONFIG_RETURNVALUES_CLASSIDS_H_ -#include +#include "common/returnvalues/commonClassIds.h" +#include "fsfw/returnvalues/FwClassIds.h" /** * @brief CLASS_ID defintions which are required for custom returnvalues. diff --git a/tests/user/testcfg/tmtc/apid.h b/tests/src/fsfw_tests/unit/testcfg/tmtc/apid.h similarity index 90% rename from tests/user/testcfg/tmtc/apid.h rename to tests/src/fsfw_tests/unit/testcfg/tmtc/apid.h index c0231bca..0e633afb 100644 --- a/tests/user/testcfg/tmtc/apid.h +++ b/tests/src/fsfw_tests/unit/testcfg/tmtc/apid.h @@ -12,6 +12,7 @@ */ namespace apid { static const uint16_t DEFAULT_APID = 0x00; + static const uint16_t SOURCE_OBSW = 0x73; } diff --git a/tests/user/testcfg/tmtc/pusIds.h b/tests/src/fsfw_tests/unit/testcfg/tmtc/pusIds.h similarity index 100% rename from tests/user/testcfg/tmtc/pusIds.h rename to tests/src/fsfw_tests/unit/testcfg/tmtc/pusIds.h diff --git a/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt b/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt index 2c635711..6ce1c6c6 100644 --- a/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt @@ -1,3 +1,3 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE TestCountdown.cpp ) diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt b/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt index a1a4c1b6..36838b24 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt @@ -1,3 +1,3 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${FSFW_TEST_TGT} PRIVATE PusTmTest.cpp ) diff --git a/tests/user/README.md b/tests/user/README.md deleted file mode 100644 index d6a4bb85..00000000 --- a/tests/user/README.md +++ /dev/null @@ -1,19 +0,0 @@ -## FSFW Testing - -This folder contains testing and unit testing components. - -### Instructions - -The easiest way to run the unittest contained in this folder is to follow -the steps in the [test repository](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_tests). -This is recommended even if the goal is to set up a custom test repository to have -a starting point. - -To set up a custom test repository or project, following steps can be performed: - -1. Copy the user folder content into the project root. -2. Clone [Catch2](https://github.com/catchorg/Catch2) in the project root. -3. Use the `CMakeLists.txt` as a starting point to add tests and build the test - executable. - - diff --git a/tests/user/testcfg/CMakeLists.txt b/tests/user/testcfg/CMakeLists.txt deleted file mode 100644 index dbf0256f..00000000 --- a/tests/user/testcfg/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -target_sources(${TARGET_NAME} - PRIVATE - ipc/MissionMessageTypes.cpp - pollingsequence/PollingSequenceFactory.cpp -) - -# Add include paths for the executable -target_include_directories(${TARGET_NAME} - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) diff --git a/tests/user/testcfg/OBSWConfig.h.in b/tests/user/testcfg/OBSWConfig.h.in deleted file mode 100644 index 34eda31f..00000000 --- a/tests/user/testcfg/OBSWConfig.h.in +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef TESTCFG_OBSWCONFIG_H_ -#define TESTCFG_OBSWCONFIG_H_ - - - - - -#endif /* TESTCFG_OBSWCONFIG_H_ */