test update

This commit is contained in:
Robin Müller 2021-01-06 19:32:33 +01:00
parent 8807772d13
commit db7d28f852
12 changed files with 164 additions and 31 deletions

View File

@ -7,6 +7,7 @@
#include "../datapool/PoolVariableIF.h"
#include "../datapool/DataSetIF.h"
#include "../serviceinterface/ServiceInterface.h"
#include "../objectmanager/ObjectManagerIF.h"
#include "../serialize/SerializeAdapter.h"

View File

@ -35,8 +35,11 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVariable: Invalid read write "
"mode for read() call." << std::endl;
#endif
"mode for read call." << std::endl;
#else
fsfw::printWarning("LocalPoolVariable: Invalid read write "
"mode for read call.");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
@ -48,7 +51,11 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
<< std::hex << std::setw(8) << std::setfill('0')
<< hkManager->getOwner() << " and lp ID 0x" << localPoolId
<< std::dec << " failed." << std::setfill(' ') << std::endl;
#endif
#else
fsfw::printError("LocalPoolVariable: Read of local pool variable of "
"object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(),
localPoolId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return result;
}
this->value = *(poolEntry->address);
@ -69,7 +76,7 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVariable: Invalid read write "
"mode for commit() call." << std::endl;
#endif
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
@ -80,7 +87,11 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
<< "object " << std::hex << std::setw(8) << std::setfill('0')
<< hkManager->getOwner() << " and lp ID 0x" << localPoolId
<< std::dec << " failed." << std::endl;
#endif
#else
fsfw::printError("LocalPoolVariable: Read of local pool variable of "
"object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(),
localPoolId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return result;
}
*(poolEntry->address) = this->value;

View File

@ -5,6 +5,7 @@
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include <cstdint>
#include <cstddef>
#include <string>
namespace tv {
// POD test values

View File

@ -7,6 +7,8 @@
#include <catch2/catch_test_macros.hpp>
#include <array>
TEST_CASE( "Action Helper" , "[ActionHelper]") {
ActionHelperOwnerMockBase testDhMock;

View File

@ -90,7 +90,9 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
lp_var_t<uint32_t> uint32tVar = lp_var_t<uint32_t>(
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint32VarId);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "LocalPoolVariable printout: " <<uint32tVar << std::endl;
#endif
}
}

View File

@ -13,7 +13,19 @@ cmake_minimum_required(VERSION 3.13)
# set(CMAKE_VERBOSE TRUE)
set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildsystem/cmake")
set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(TMTC_TEST "Build binary for manual or automatic TMTC tests" FALSE)
option(GENERATE_COVERAGE
"Specify whether coverage data is generated with GCOV"
TRUE
)
if(TMTC_TEST)
set(LINK_CATCH2 FALSE)
else()
set(LINK_CATCH2 TRUE)
endif()
# Tests can be built with the Host OSAL or with the Linux OSAL.
if(NOT OS_FSFW)
@ -53,6 +65,7 @@ set(FSFW_PATH fsfw)
set(CATCH2_PATH Catch2)
set(FSFW_TESTS_PATH fsfw/unittest)
set(TEST_SETUP_PATH unittest)
set(TMTC_TEST_PATH tests)
# Analyse different OS and architecture/target options and
# determine BSP_PATH
@ -71,6 +84,15 @@ else()
endif()
endif()
if(GENERATE_COVERAGE)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/cmake-modules)
if(CMAKE_COMPILER_IS_GNUCXX)
include(CodeCoverage)
# Add compile options on target base, we don't want coverage for Catch2
# append_coverage_compiler_flags()
endif()
endif()
set(FSFW_CONFIG_PATH testcfg)
################################################################################
@ -82,10 +104,16 @@ add_executable(${TARGET_NAME})
# Add subdirectories
add_subdirectory(${FSFW_PATH})
add_subdirectory(${CATCH2_PATH})
add_subdirectory(${FSFW_CONFIG_PATH})
if(LINK_CATCH2)
add_subdirectory(${CATCH2_PATH})
add_subdirectory(${FSFW_TESTS_PATH})
add_subdirectory(${TEST_SETUP_PATH})
else()
add_subdirectory(${TMTC_TEST_PATH})
endif()
################################################################################
# Post-Sources preparation
@ -94,8 +122,73 @@ add_subdirectory(${TEST_SETUP_PATH})
# Add libraries for all sources.
target_link_libraries(${TARGET_NAME} PRIVATE
${LIB_FSFW_NAME}
)
if(LINK_CATCH2)
target_link_libraries(${TARGET_NAME} PRIVATE
${CATCH2_TARGET}
)
endif()
if(GENERATE_COVERAGE)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CODE_COVERAGE_VERBOSE TRUE)
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(${TARGET_NAME} PRIVATE
"${COVERAGE_COMPILER_FLAGS}"
)
target_compile_options(${LIB_FSFW_NAME} PRIVATE
"${COVERAGE_COMPILER_FLAGS}"
)
# Exclude internal unittest from coverage for now.
if(WIN32)
set(GCOVR_ADDITIONAL_ARGS
"--exclude-throw-branches"
"--exclude-unreachable-branches"
)
set(COVERAGE_EXCLUDES
"/c/msys64/mingw64/*" "Catch2"
"${CMAKE_CURRENT_SOURCE_DIR}/fsfw/unittest/internal"
)
elseif(UNIX)
set(COVERAGE_EXCLUDES
"/usr/include/*" "/usr/bin/*" "Catch2/*"
"fsfw/unittest/internal/*"
)
endif()
target_link_options(${TARGET_NAME} 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 ${TARGET_NAME}_coverage
EXECUTABLE ${TARGET_NAME}
DEPENDENCIES ${TARGET_NAME}
)
else()
setup_target_for_coverage_lcov(
NAME ${TARGET_NAME}_coverage
EXECUTABLE ${TARGET_NAME}
DEPENDENCIES ${TARGET_NAME}
)
endif()
endif()
endif()
# Add include paths for all sources.
target_include_directories(${TARGET_NAME} PRIVATE
@ -147,8 +240,7 @@ if(NOT CMAKE_SIZE)
endif()
endif()
add_custom_command(
TARGET ${TARGET_NAME}
add_custom_command(TARGET ${TARGET_NAME}
POST_BUILD
COMMAND echo "Build directory: ${CMAKE_BINARY_DIR}"
COMMAND echo "Target OSAL: ${OS_FSFW}"
@ -156,7 +248,7 @@ add_custom_command(
COMMAND ${CMAKE_SIZE} ${TARGET_NAME}${FILE_SUFFIX}
)
include (${CMAKE_CURRENT_SOURCE_DIR}/buildsystem/cmake/BuildType.cmake)
include (${CMAKE_SCRIPT_PATH}/BuildType.cmake)
set_build_type()

View File

@ -5,3 +5,9 @@ target_sources(${TARGET_NAME} PRIVATE
CatchSetup.cpp
printChar.cpp
)
if(CUSTOM_UNITTEST_RUNNER)
target_sources(${TARGET_NAME} PRIVATE
CatchRunner.cpp
)
endif()

View File

@ -1,4 +1,5 @@
#include "CatchDefinitions.h"
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/objectmanager/ObjectManagerIF.h>
StorageManagerIF* tglob::getIpcStoreHandle() {
@ -7,6 +8,8 @@ StorageManagerIF* tglob::getIpcStoreHandle() {
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Global object manager uninitialized" << std::endl;
#else
fsfw::printError("Global object manager uninitialized");
#endif
return nullptr;
}

View File

@ -1,11 +1,15 @@
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include "CatchFactory.h"
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
#include <fsfw/internalError/InternalErrorReporter.h>
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw/storagemanager/PoolManager.h>
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
#include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcservices/PusServiceBase.h>
/**
* @brief Produces system objects.
@ -50,7 +54,23 @@ void Factory::produce(void) {
}
void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::NO_OBJECT;
PusServiceBase::packetDestination = objects::NO_OBJECT;
CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS;
LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT;
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
TmPacketStored::timeStamperId = objects::NO_OBJECT;
}

View File

@ -1,17 +1,16 @@
/**
* @file CatchSource.cpp
* @file CatchRunner.cpp
* @brief Source file to compile catch framework.
* @details All tests should be written in other files.
* For eclipse console output, install ANSI Escape in Console
* from the eclipse market place to get colored characters.
*/
#ifndef NO_UNIT_TEST_FRAMEWORK
#include <TestsConfig.h>
#define CATCH_CONFIG_RUNNER
#include <catch2/catch.hpp>
#define CATCH_CONFIG_COLOUR_WINDOWS
#if CUSTOM_UNITTEST_RUNNER == 0
#include <catch2/catch_session.hpp>
extern int customSetup();
@ -25,7 +24,3 @@ int main( int argc, char* argv[] ) {
return result;
}
#endif
#endif

View File

@ -1,21 +1,20 @@
#include <fsfw/unittest/core/CatchFactory.h>
#include "CatchFactory.h"
#include "CatchDefinitions.h"
#include <testcfg/cdatapool/dataPoolInit.h>
#ifdef GCOV
#include <gcov.h>
#endif
#include "../../objectmanager/ObjectManager.h"
#include "../../objectmanager/ObjectManagerIF.h"
#include "../../storagemanager/StorageManagerIF.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/objectmanager/ObjectManagerIF.h>
#include <fsfw/storagemanager/StorageManagerIF.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
/* Global instantiations normally done in main.cpp */
/* Initialize Data Pool */
#if FSFW_CPP_OSTREAM_ENABLED == 1
namespace sif {
/* Set up output streams */
ServiceInterfaceStream debug("DEBUG");
@ -23,6 +22,7 @@ ServiceInterfaceStream info("INFO");
ServiceInterfaceStream error("ERROR");
ServiceInterfaceStream warning("WARNING");
}
#endif
/* Global object manager */
ObjectManagerIF *objectManager;

View File

@ -1,4 +1,4 @@
#include <fsfw/unittest/core/printChar.h>
#include "printChar.h"
#include <cstdio>
void printChar(const char* character, bool errStream) {