catch2 running
This commit is contained in:
parent
50cf01376f
commit
d9badee18f
@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
option(EIVE_BUILD_UNITTESTS "Build Catch2 unittests" OFF)
|
||||
|
||||
option(EIVE_ADD_ETL_LIB "Add ETL library" ON)
|
||||
option(EIVE_ADD_JSON_LIB "Add JSON library" ON)
|
||||
option(EIVE_SYSROOT_MAGIC "Perform sysroot magic which might not be necessary" OFF)
|
||||
@ -45,6 +45,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(OBSW_NAME ${CMAKE_PROJECT_NAME})
|
||||
set(WATCHDOG_NAME eive-watchdog)
|
||||
set(SIMPLE_OBSW_NAME eive-simple)
|
||||
set(UNITTEST_NAME eive-unittest)
|
||||
set(LIB_FSFW_NAME fsfw)
|
||||
set(LIB_EIVE_MISSION eive-mission)
|
||||
set(LIB_ETL_NAME etl)
|
||||
@ -78,13 +79,6 @@ set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json)
|
||||
set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF)
|
||||
set(EIVE_ADD_LINUX_FILES False)
|
||||
|
||||
if(EIVE_BUILD_UNITTESTS)
|
||||
endif()
|
||||
|
||||
if(FSFW_ADD_UNITTESTS)
|
||||
set(CATCH2_TARGET Catch2)
|
||||
endif()
|
||||
|
||||
# Analyse different OS and architecture/target options, determine BSP_PATH,
|
||||
# display information about compiler etc.
|
||||
include (${CMAKE_SCRIPT_PATH}/HardwareOsPreConfig.cmake)
|
||||
@ -122,10 +116,6 @@ else()
|
||||
set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig")
|
||||
endif()
|
||||
|
||||
if(EIVE_BUILD_UNITTESTS)
|
||||
# configure_file(${UNITTEST_CFG_PATH}/TestsConfig.h.in TestsConfig.h)
|
||||
# set(FSFW_CONFIG_PATH ${UNITTEST_CFG_PATH})
|
||||
endif()
|
||||
|
||||
# Configuration files
|
||||
configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h)
|
||||
@ -147,6 +137,23 @@ set(FSFW_ADDITIONAL_INC_PATHS
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
# 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-preview4
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
#fixes regression -preview4, to be confirmed in later releases
|
||||
set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# Executable and Sources
|
||||
################################################################################
|
||||
@ -160,7 +167,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
"-Wno-unused-parameter"
|
||||
"-Wno-psabi"
|
||||
)
|
||||
message(STATUS "goes here")
|
||||
# Remove unused sections.
|
||||
add_compile_options(
|
||||
"-ffunction-sections"
|
||||
@ -180,7 +186,7 @@ endif()
|
||||
add_library(${LIB_EIVE_MISSION})
|
||||
|
||||
|
||||
# Add executable
|
||||
# Add main executable
|
||||
add_executable(${OBSW_NAME})
|
||||
|
||||
#watchdog
|
||||
@ -189,11 +195,15 @@ add_subdirectory(${WATCHDOG_PATH})
|
||||
target_link_libraries(${WATCHDOG_NAME} PUBLIC
|
||||
${LIB_CXX_FS}
|
||||
)
|
||||
|
||||
target_include_directories(${WATCHDOG_NAME} PUBLIC
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
#unittests
|
||||
add_executable(${UNITTEST_NAME} EXCLUDE_FROM_ALL)
|
||||
|
||||
|
||||
|
||||
if(EIVE_ADD_ETL_LIB)
|
||||
add_subdirectory(${LIB_ETL_PATH})
|
||||
endif()
|
||||
@ -203,7 +213,7 @@ if(EIVE_ADD_JSON_LIB)
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT EIVE_BUILD_UNITTESTS)
|
||||
|
||||
if(EIVE_ADD_LINUX_FILES)
|
||||
add_subdirectory(${LIB_ARCSEC_PATH})
|
||||
add_subdirectory(${LINUX_PATH})
|
||||
@ -212,7 +222,7 @@ if(NOT EIVE_BUILD_UNITTESTS)
|
||||
if(ADD_CSP_LIB)
|
||||
add_subdirectory(${LIB_CSP_PATH})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
add_subdirectory(${COMMON_PATH})
|
||||
|
||||
@ -224,10 +234,8 @@ add_subdirectory(${LIB_EIVE_MISSION_PATH})
|
||||
add_subdirectory(${TEST_PATH})
|
||||
|
||||
|
||||
if(EIVE_BUILD_UNITTESTS)
|
||||
# add_subdirectory(${LIB_CATCH2_PATH})
|
||||
add_subdirectory(${UNITTEST_PATH})
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
# Post-Sources preparation
|
||||
@ -253,6 +261,9 @@ if(TGT_BSP MATCHES "arm/q7s")
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${UNITTEST_NAME} PRIVATE
|
||||
Catch2
|
||||
)
|
||||
|
||||
|
||||
if(ADD_CSP_LIB)
|
||||
@ -274,12 +285,6 @@ if(EIVE_ADD_JSON_LIB)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(EIVE_BUILD_UNITTESTS)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE
|
||||
${CATCH2_TARGET}
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${LIB_EIVE_MISSION} PUBLIC
|
||||
${LIB_CXX_FS}
|
||||
)
|
||||
|
@ -1,5 +1,6 @@
|
||||
add_subdirectory(testcfg)
|
||||
add_subdirectory(controller)
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
|
||||
target_sources(${UNITTEST_NAME} PRIVATE
|
||||
main.cpp
|
||||
)
|
3
unittest/controller/CMakeLists.txt
Normal file
3
unittest/controller/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${UNITTEST_NAME} PRIVATE
|
||||
testThermalController.cpp
|
||||
)
|
7
unittest/controller/testThermalController.cpp
Normal file
7
unittest/controller/testThermalController.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE( "Thermal Controller" , "[ThermalController]") {
|
||||
bool test = true;
|
||||
REQUIRE( test == true);
|
||||
|
||||
}
|
@ -1,7 +1,15 @@
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "fsfw_tests/unit/CatchRunner.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <catch2/catch_session.hpp>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// fsfwtest::customMain(argc, argv);
|
||||
puts("unittests");
|
||||
|
||||
|
||||
// Catch internal function call
|
||||
int result = Catch::Session().run(argc, argv);
|
||||
|
||||
// global clean-up
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user