From d9badee18f2b206f27c84146a8e927ea4676de98 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 10 Feb 2022 18:15:33 +0100 Subject: [PATCH 01/23] catch2 running --- CMakeLists.txt | 73 ++++++++++--------- unittest/CMakeLists.txt | 5 +- unittest/controller/CMakeLists.txt | 3 + unittest/controller/testThermalController.cpp | 7 ++ unittest/main.cpp | 14 +++- 5 files changed, 63 insertions(+), 39 deletions(-) create mode 100644 unittest/controller/CMakeLists.txt create mode 100644 unittest/controller/testThermalController.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a3dd1d7c..9144f27d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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,16 +213,16 @@ 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}) - endif() - add_subdirectory(${BSP_PATH}) - if(ADD_CSP_LIB) - add_subdirectory(${LIB_CSP_PATH}) - endif() + +if(EIVE_ADD_LINUX_FILES) + add_subdirectory(${LIB_ARCSEC_PATH}) + add_subdirectory(${LINUX_PATH}) endif() +add_subdirectory(${BSP_PATH}) +if(ADD_CSP_LIB) + add_subdirectory(${LIB_CSP_PATH}) +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() +add_subdirectory(${UNITTEST_PATH}) + ################################################################################ # 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} ) diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 0c799d45..b4c26ed6 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,5 +1,6 @@ -add_subdirectory(testcfg) +add_subdirectory(controller) -target_sources(${TARGET_NAME} PRIVATE + +target_sources(${UNITTEST_NAME} PRIVATE main.cpp ) \ No newline at end of file diff --git a/unittest/controller/CMakeLists.txt b/unittest/controller/CMakeLists.txt new file mode 100644 index 00000000..ee9b1a8b --- /dev/null +++ b/unittest/controller/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${UNITTEST_NAME} PRIVATE + testThermalController.cpp +) \ No newline at end of file diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp new file mode 100644 index 00000000..c7a5953f --- /dev/null +++ b/unittest/controller/testThermalController.cpp @@ -0,0 +1,7 @@ +#include + +TEST_CASE( "Thermal Controller" , "[ThermalController]") { + bool test = true; + REQUIRE( test == true); + +} \ No newline at end of file diff --git a/unittest/main.cpp b/unittest/main.cpp index 811df98e..fecfaf75 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -1,7 +1,15 @@ -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw_tests/unit/CatchRunner.h" +#include + +#include 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; } From f9721eb1ae821d9fcbb1ecee6c279688efea8c44 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 10 Feb 2022 18:29:28 +0100 Subject: [PATCH 02/23] unittesting a skeleton controller, still withouth fsfw --- CMakeLists.txt | 1 + mission/CMakeLists.txt | 1 + mission/controller/CMakeLists.txt | 3 ++ mission/controller/ThermalController.cpp | 43 ++----------------- mission/controller/ThermalController.h | 22 ++-------- unittest/controller/testThermalController.cpp | 6 +++ 6 files changed, 18 insertions(+), 58 deletions(-) create mode 100644 mission/controller/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 9144f27d..0c160fe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,6 +263,7 @@ endif() target_link_libraries(${UNITTEST_NAME} PRIVATE Catch2 + ${LIB_EIVE_MISSION} ) diff --git a/mission/CMakeLists.txt b/mission/CMakeLists.txt index b0fc4d00..7fa8fe56 100644 --- a/mission/CMakeLists.txt +++ b/mission/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(controller) add_subdirectory(core) add_subdirectory(devices) add_subdirectory(utility) diff --git a/mission/controller/CMakeLists.txt b/mission/controller/CMakeLists.txt new file mode 100644 index 00000000..2b0bac62 --- /dev/null +++ b/mission/controller/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${LIB_EIVE_MISSION} PRIVATE + ThermalController.cpp +) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index cd8c8b22..610cae0a 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,42 +1,7 @@ #include "ThermalController.h" -#include +ThermalController::ThermalController(object_id_t objectId) {} -ThermalController::ThermalController(object_id_t objectId) - : ExtendedControllerBase(objectId, objects::NO_OBJECT), thermalControllerSet(objectId) {} - -ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; -} - -void ThermalController::performControlOperation() {} - -void ThermalController::handleChangedDataset(sid_t sid, store_address_t storeId) { - if (sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, - TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { - sif::info << "Update registered!" << std::endl; - } -} - -ReturnValue_t ThermalController::initializeAfterTaskCreation() { - ReturnValue_t result = ExtendedControllerBase::initializeAfterTaskCreation(); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "ThermalController::initializeAfterTaskCreation: Base" - << " class initialization failed!" << std::endl; - } - HasLocalDataPoolIF *testHkbHandler = ObjectManager::instance()->get( - TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); - if (testHkbHandler == nullptr) { - sif::warning << "ThermalController::initializeAfterTaskCreation: Test" - << " HKB Handler invalid!" << std::endl; - } - // Test normal notifications without data packet first. - testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( - TSensorDefinitions::THERMAL_SENSOR_SET_ID, this->getObjectId(), commandQueue->getId(), false); - return result; -} - -ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t ThermalController::perform() { + return HasReturnvaluesIF::RETURN_FAILED; +} \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 2d76ce8d..52279261 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -3,29 +3,13 @@ #include -#include "ctrldefinitions/ThermalCtrlPackets.h" -class ThermalController : public ExtendedControllerBase { + +class ThermalController { public: ThermalController(object_id_t objectId); - private: - // TODO: Add stubs for thermal components. Each device / assembly with one - // or multiple redundant sensors will have a thermal component. - - /** ExtendedControllerBase overrides */ - virtual ReturnValue_t handleCommandMessage(CommandMessage *message) override; - - virtual void performControlOperation() override; - - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) override; - - ReturnValue_t initializeAfterTaskCreation() override; - - void handleChangedDataset(sid_t sid, store_address_t storeId) override; - - ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; + ReturnValue_t perform(); }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index c7a5953f..a5b23b26 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,7 +1,13 @@ #include +#include + TEST_CASE( "Thermal Controller" , "[ThermalController]") { bool test = true; REQUIRE( test == true); + ThermalController controller(123); + + REQUIRE(controller.perform() == HasReturnvaluesIF::RETURN_OK); + } \ No newline at end of file From f1249392cf9182cf1e8fcee154d7ab3f0520686d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 10 Feb 2022 18:54:09 +0100 Subject: [PATCH 03/23] skeleton controller now unittested including fsfw. Still dirty WIP --- mission/controller/ThermalController.cpp | 19 +++++++++-- mission/controller/ThermalController.h | 13 +++++++- unittest/CMakeLists.txt | 1 + unittest/controller/testThermalController.cpp | 32 +++++++++++++++++++ unittest/printChar.cpp | 11 +++++++ unittest/printChar.h | 6 ++++ 6 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 unittest/printChar.cpp create mode 100644 unittest/printChar.h diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 610cae0a..f0acc5fa 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,7 +1,20 @@ #include "ThermalController.h" -ThermalController::ThermalController(object_id_t objectId) {} +ThermalController::ThermalController(object_id_t objectId) :ExtendedControllerBase(objectId, 0) {} -ReturnValue_t ThermalController::perform() { - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t ThermalController::perform() { return HasReturnvaluesIF::RETURN_FAILED; } + +ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { + return RETURN_FAILED; +} +void ThermalController::performControlOperation() {} +ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return RETURN_OK; +} +LocalPoolDataSetBase* ThermalController::getDataSetHandle(sid_t sid) { return nullptr; } + +ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) { + return RETURN_FAILED; } \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 52279261..25c257b7 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -5,11 +5,22 @@ -class ThermalController { +class ThermalController : public ExtendedControllerBase { public: ThermalController(object_id_t objectId); ReturnValue_t perform(); + +protected: + virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override; + virtual void performControlOperation() override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + + // Mode abstract functions + virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index b4c26ed6..c2b09393 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -3,4 +3,5 @@ add_subdirectory(controller) target_sources(${UNITTEST_NAME} PRIVATE main.cpp + printChar.cpp ) \ No newline at end of file diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index a5b23b26..fed27834 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,6 +1,38 @@ #include #include +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" + +/* This is configured for linux without CR */ +#ifdef PLATFORM_UNIX +ServiceInterfaceStream sif::debug("DEBUG"); +ServiceInterfaceStream sif::info("INFO"); +ServiceInterfaceStream sif::warning("WARNING"); +ServiceInterfaceStream sif::error("ERROR"); +#else +ServiceInterfaceStream sif::debug("DEBUG", true); +ServiceInterfaceStream sif::info("INFO", true); +ServiceInterfaceStream sif::warning("WARNING", true); +ServiceInterfaceStream sif::error("ERROR", true, false, true); +#endif + +#include + +namespace messagetypes { +enum MESSAGE_TYPE { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, +}; + +void clearMissionMessage(CommandMessage* message); +} // namespace messagetypes + + +void messagetypes::clearMissionMessage(CommandMessage* message) { + +} + + + TEST_CASE( "Thermal Controller" , "[ThermalController]") { bool test = true; diff --git a/unittest/printChar.cpp b/unittest/printChar.cpp new file mode 100644 index 00000000..0e29fe2b --- /dev/null +++ b/unittest/printChar.cpp @@ -0,0 +1,11 @@ +#include "printChar.h" + +#include + +void printChar(const char* character, bool errStream) { + if (errStream) { + std::putc(*character, stderr); + return; + } + std::putc(*character, stdout); +} diff --git a/unittest/printChar.h b/unittest/printChar.h new file mode 100644 index 00000000..1991161f --- /dev/null +++ b/unittest/printChar.h @@ -0,0 +1,6 @@ +#ifndef FSFW_UNITTEST_CORE_PRINTCHAR_H_ +#define FSFW_UNITTEST_CORE_PRINTCHAR_H_ + +extern "C" void printChar(const char*, bool errStream); + +#endif /* FSFW_UNITTEST_CORE_PRINTCHAR_H_ */ From 587e9451ea3e3b688547bcb8235a3c22d4b93d45 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 11 Feb 2022 16:20:26 +0100 Subject: [PATCH 04/23] some more fsfw objects and stubs for unittesting --- mission/controller/ThermalController.cpp | 2 +- mission/controller/ThermalController.h | 2 +- unittest/CMakeLists.txt | 1 + unittest/controller/testThermalController.cpp | 62 +++++++++---------- unittest/initTests.cpp | 29 +++++++++ 5 files changed, 62 insertions(+), 34 deletions(-) create mode 100644 unittest/initTests.cpp diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index f0acc5fa..04ab8682 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,6 +1,6 @@ #include "ThermalController.h" -ThermalController::ThermalController(object_id_t objectId) :ExtendedControllerBase(objectId, 0) {} +ThermalController::ThermalController(object_id_t objectId, object_id_t parentId) :ExtendedControllerBase(objectId, parentId) {} ReturnValue_t ThermalController::perform() { return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 25c257b7..1faba29f 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -7,7 +7,7 @@ class ThermalController : public ExtendedControllerBase { public: - ThermalController(object_id_t objectId); + ThermalController(object_id_t objectId, object_id_t parentId); ReturnValue_t perform(); diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index c2b09393..6a0c55ed 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -3,5 +3,6 @@ add_subdirectory(controller) target_sources(${UNITTEST_NAME} PRIVATE main.cpp + initTests.cpp printChar.cpp ) \ No newline at end of file diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index fed27834..b3d74476 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,45 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include + #include -#include -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +class HkDummy : public SystemObject, public AcceptsHkPacketsIF { + public: + HkDummy() : SystemObject(objects::PUS_SERVICE_3_HOUSEKEEPING) {} -/* This is configured for linux without CR */ -#ifdef PLATFORM_UNIX -ServiceInterfaceStream sif::debug("DEBUG"); -ServiceInterfaceStream sif::info("INFO"); -ServiceInterfaceStream sif::warning("WARNING"); -ServiceInterfaceStream sif::error("ERROR"); -#else -ServiceInterfaceStream sif::debug("DEBUG", true); -ServiceInterfaceStream sif::info("INFO", true); -ServiceInterfaceStream sif::warning("WARNING", true); -ServiceInterfaceStream sif::error("ERROR", true, false, true); -#endif - -#include - -namespace messagetypes { -enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + virtual MessageQueueId_t getHkQueue() const { return MessageQueueIF::NO_QUEUE; } }; -void clearMissionMessage(CommandMessage* message); -} // namespace messagetypes +void factory(void* args) { + new HkDummy(); + new HealthTable(objects::HEALTH_TABLE); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new TimeStamper(objects::TIME_STAMPER); -void messagetypes::clearMissionMessage(CommandMessage* message) { - + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, + {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; + new PoolManager(objects::IPC_STORE, poolCfg); + } } +TEST_CASE("Thermal Controller", "[ThermalController]") { + bool test = true; + REQUIRE(test == true); + ThermalController controller(0x123, objects::NO_OBJECT); + ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr); + ObjectManager::instance()->initialize(); + ObjectManager::instance()->printList(); -TEST_CASE( "Thermal Controller" , "[ThermalController]") { - bool test = true; - REQUIRE( test == true); - - ThermalController controller(123); - - REQUIRE(controller.perform() == HasReturnvaluesIF::RETURN_OK); - + REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK); } \ No newline at end of file diff --git a/unittest/initTests.cpp b/unittest/initTests.cpp new file mode 100644 index 00000000..3821d893 --- /dev/null +++ b/unittest/initTests.cpp @@ -0,0 +1,29 @@ +#include + +#ifdef LINUX +ServiceInterfaceStream sif::debug("DEBUG"); +ServiceInterfaceStream sif::info("INFO"); +ServiceInterfaceStream sif::warning("WARNING"); +ServiceInterfaceStream sif::error("ERROR", false, false, true); +#else +ServiceInterfaceStream sif::debug("DEBUG", true); +ServiceInterfaceStream sif::info("INFO", true); +ServiceInterfaceStream sif::warning("WARNING", true); +ServiceInterfaceStream sif::error("ERROR", true, false, true); +#endif + +#include +#include + +namespace messagetypes { +enum MESSAGE_TYPE { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, +}; + +void clearMissionMessage(CommandMessage* message); +} // namespace messagetypes + + +void messagetypes::clearMissionMessage(CommandMessage* message) { + +} From 0f42790aa1f6717f992d691b58d270dca7e189bc Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 11 Feb 2022 17:49:28 +0100 Subject: [PATCH 05/23] more mocking an such in unittests --- unittest/controller/testThermalController.cpp | 4 +++ unittest/mocks/EventManagerMock.h | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 unittest/mocks/EventManagerMock.h diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index b3d74476..357cadd2 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -4,6 +4,10 @@ #include #include #include +#include + + + #include #include diff --git a/unittest/mocks/EventManagerMock.h b/unittest/mocks/EventManagerMock.h new file mode 100644 index 00000000..1e33598b --- /dev/null +++ b/unittest/mocks/EventManagerMock.h @@ -0,0 +1,27 @@ +#ifndef EVENTMANAGERMOCK_H_ +#define EVENTMANAGERMOCK_H_ + +#include + +class EventManagerMock { + public: + virtual MessageQueueId_t getEventReportQueue() override; + + virtual ReturnValue_t registerListener(MessageQueueId_t listener, + bool forwardAllButSelected = false) override; + virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) override; + virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, + object_id_t object) override; + virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, + EventId_t idTo = 0, bool idInverted = false, + object_id_t reporterFrom = 0, + object_id_t reporterTo = 0, + bool reporterInverted = false) override; + virtual ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, + EventId_t idTo = 0, bool idInverted = false, + object_id_t reporterFrom = 0, + object_id_t reporterTo = 0, + bool reporterInverted = false) override; +}; + +#endif /* EVENTMANAGERMOCK_H_ */ \ No newline at end of file From e95647c572aa4f2769f99840263145c61c657108 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 14 Feb 2022 13:49:12 +0100 Subject: [PATCH 06/23] working on thermal controller unit test. --- mission/controller/ThermalController.cpp | 36 ++++++++++++++-- mission/controller/ThermalController.h | 9 ++-- .../ThermalControllerDefinitions.h | 43 +++++++++++++++++++ unittest/controller/testThermalController.cpp | 36 +++++++++++++--- unittest/main.cpp | 4 -- 5 files changed, 111 insertions(+), 17 deletions(-) create mode 100644 mission/controller/controllerdefinitions/ThermalControllerDefinitions.h diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 04ab8682..8ca86b7e 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,20 +1,50 @@ #include "ThermalController.h" -ThermalController::ThermalController(object_id_t objectId, object_id_t parentId) :ExtendedControllerBase(objectId, parentId) {} +ThermalController::ThermalController(object_id_t objectId, object_id_t parentId) + : ExtendedControllerBase(objectId, parentId), + sensorTemperatures(this), + componentTemperatures(this) {} ReturnValue_t ThermalController::perform() { return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { return RETURN_FAILED; } -void ThermalController::performControlOperation() {} +void ThermalController::performControlOperation() { + sif::info << "tc performOperation()" << std::endl; + + ReturnValue_t result = sensorTemperatures.read(); + if (result != RETURN_OK) { + return; + } + result = componentTemperatures.read(); + if (result != RETURN_OK) { + return; + } + + componentTemperatures.rw = (sensorTemperatures.rw.value + sensorTemperatures.gps.value) / 2; + + sensorTemperatures.commit(); + componentTemperatures.commit(); +} + ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_RW, new PoolEntry({0.0})); + localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_GPS, new PoolEntry({0.0})); + localDataPoolMap.emplace(thermalControllerDefinitions::COMPONENT_RW, new PoolEntry({0.0})); + return RETURN_OK; } LocalPoolDataSetBase* ThermalController::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) { - return RETURN_FAILED; + if (submode != SUBMODE_NONE) { + return INVALID_SUBMODE; + } + if ((mode != MODE_OFF) && (mode != MODE_ON) && (mode != MODE_NORMAL)) { + return INVALID_MODE; + } + return RETURN_OK; } \ No newline at end of file diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 1faba29f..58e147e3 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -2,8 +2,7 @@ #define MISSION_CONTROLLER_THERMALCONTROLLER_H_ #include - - +#include class ThermalController : public ExtendedControllerBase { public: @@ -11,7 +10,7 @@ class ThermalController : public ExtendedControllerBase { ReturnValue_t perform(); -protected: + protected: virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override; virtual void performControlOperation() override; virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -21,6 +20,10 @@ protected: // Mode abstract functions virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; + + private: + thermalControllerDefinitions::SensorTemperatures sensorTemperatures; + thermalControllerDefinitions::ComponentTemperatures componentTemperatures; }; #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h new file mode 100644 index 00000000..48853778 --- /dev/null +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -0,0 +1,43 @@ +#ifndef MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ +#define MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ + +#include +#include + +namespace thermalControllerDefinitions { + +enum SetIds : uint32_t { SENSOR_TEMPERATURES, COMPONENT_TEMPERATURES }; + +enum PoolIds : lp_id_t { SENSOR_RW, SENSOR_GPS, COMPONENT_RW }; + +/** + * @brief This dataset can be used to store the collected temperatures of all temperature sensors + */ +class SensorTemperatures : public StaticLocalDataSet<2> { + public: + SensorTemperatures(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SENSOR_TEMPERATURES) {} + + SensorTemperatures(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, SENSOR_TEMPERATURES)) {} + + lp_var_t rw = lp_var_t(sid.objectId, PoolIds::SENSOR_RW, this); + lp_var_t gps = lp_var_t(sid.objectId, PoolIds::SENSOR_GPS, this); +}; + +/** + * @brief This dataset can be used to store the collected temperatures of all components + */ +class ComponentTemperatures : public StaticLocalDataSet<2> { + public: + ComponentTemperatures(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, SENSOR_TEMPERATURES) {} + + ComponentTemperatures(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, SENSOR_TEMPERATURES)) {} + + lp_var_t rw = lp_var_t(sid.objectId, PoolIds::COMPONENT_RW, this); +}; + +} // namespace thermalControllerDefinitions + +#endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ */ \ No newline at end of file diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 357cadd2..9c2b227a 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,13 +1,11 @@ +#include #include #include #include +#include #include #include #include -#include - - - #include #include @@ -34,14 +32,38 @@ void factory(void* args) { } TEST_CASE("Thermal Controller", "[ThermalController]") { - bool test = true; - REQUIRE(test == true); + + const object_id_t THERMAL_CONTROLLER_ID = 0x123; - ThermalController controller(0x123, objects::NO_OBJECT); + + ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT); ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr); ObjectManager::instance()->initialize(); ObjectManager::instance()->printList(); + controller.initializeAfterTaskCreation(); + + MessageQueueId_t controllerQueue = controller.getCommandQueue(); + + CommandMessage modeMessage; + + ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, + ControllerBase::MODE_NORMAL, HasModesIF::SUBMODE_NONE); + + MessageQueueIF* commandQueue = QueueFactory::instance()->createMessageQueue( + 5, MessageQueueMessage::MAX_MESSAGE_SIZE); + + commandQueue->sendMessage(controllerQueue,&modeMessage); + REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK); + + thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID); + + componentTemperatures.read(); + REQUIRE(componentTemperatures.rw == 0); + + componentTemperatures.commit(); + + QueueFactory::instance()->deleteMessageQueue(commandQueue); } \ No newline at end of file diff --git a/unittest/main.cpp b/unittest/main.cpp index fecfaf75..2d65ccb4 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -1,10 +1,6 @@ -#include - #include int main(int argc, char* argv[]) { - puts("unittests"); - // Catch internal function call int result = Catch::Session().run(argc, argv); From 3400c538b36459f9196c5072c88881f005d58a5d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 16 Feb 2022 18:15:06 +0100 Subject: [PATCH 07/23] added EventManagerMock, to be extended and moved into fsfw some day --- bsp_hosted/fsfwconfig/CMakeLists.txt | 6 ++++ linux/fsfwconfig/CMakeLists.txt | 6 ++++ unittest/CMakeLists.txt | 2 +- unittest/controller/testThermalController.cpp | 32 +++-------------- unittest/main.cpp | 36 ++++++++++++++++--- unittest/mocks/CMakeLists.txt | 4 +++ unittest/mocks/EventManagerMock.cpp | 18 ++++++++++ unittest/mocks/EventManagerMock.h | 22 +++--------- unittest/mocks/HouseKeepingMock.cpp | 8 +++++ unittest/mocks/HouseKeepingMock.h | 16 +++++++++ 10 files changed, 98 insertions(+), 52 deletions(-) create mode 100644 unittest/mocks/CMakeLists.txt create mode 100644 unittest/mocks/EventManagerMock.cpp create mode 100644 unittest/mocks/HouseKeepingMock.cpp create mode 100644 unittest/mocks/HouseKeepingMock.h diff --git a/bsp_hosted/fsfwconfig/CMakeLists.txt b/bsp_hosted/fsfwconfig/CMakeLists.txt index 04a8907e..4a483eb7 100644 --- a/bsp_hosted/fsfwconfig/CMakeLists.txt +++ b/bsp_hosted/fsfwconfig/CMakeLists.txt @@ -11,6 +11,9 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") target_sources(${OBSW_NAME} PRIVATE objects/translateObjects.cpp ) + target_sources(${UNITTEST_NAME} PRIVATE + objects/translateObjects.cpp + ) endif() # If a special translation file for events exists, compile it. @@ -18,4 +21,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") target_sources(${OBSW_NAME} PRIVATE events/translateEvents.cpp ) + target_sources(${UNITTEST_NAME} PRIVATE + events/translateEvents.cpp + ) endif() diff --git a/linux/fsfwconfig/CMakeLists.txt b/linux/fsfwconfig/CMakeLists.txt index ea8375fa..8d13e67b 100644 --- a/linux/fsfwconfig/CMakeLists.txt +++ b/linux/fsfwconfig/CMakeLists.txt @@ -12,6 +12,9 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") target_sources(${OBSW_NAME} PRIVATE objects/translateObjects.cpp ) + target_sources(${UNITTEST_NAME} PRIVATE + objects/translateObjects.cpp + ) endif() # If a special translation file for events exists, compile it. @@ -19,4 +22,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") target_sources(${OBSW_NAME} PRIVATE events/translateEvents.cpp ) + target_sources(${UNITTEST_NAME} PRIVATE + events/translateEvents.cpp + ) endif() diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 6a0c55ed..39f3b66e 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(controller) - +add_subdirectory(mocks) target_sources(${UNITTEST_NAME} PRIVATE main.cpp diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 9c2b227a..468d8e2e 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -3,45 +3,17 @@ #include #include #include -#include -#include -#include #include #include -class HkDummy : public SystemObject, public AcceptsHkPacketsIF { - public: - HkDummy() : SystemObject(objects::PUS_SERVICE_3_HOUSEKEEPING) {} - virtual MessageQueueId_t getHkQueue() const { return MessageQueueIF::NO_QUEUE; } -}; - -void factory(void* args) { - new HkDummy(); - - new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - new TimeStamper(objects::TIME_STAMPER); - - { - PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, - {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; - new PoolManager(objects::IPC_STORE, poolCfg); - } -} TEST_CASE("Thermal Controller", "[ThermalController]") { - const object_id_t THERMAL_CONTROLLER_ID = 0x123; - ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT); - ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr); - ObjectManager::instance()->initialize(); - ObjectManager::instance()->printList(); - controller.initializeAfterTaskCreation(); MessageQueueId_t controllerQueue = controller.getCommandQueue(); @@ -65,5 +37,9 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { componentTemperatures.commit(); + ExecutableObjectIF *eventmanager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + eventmanager->performOperation(); + + QueueFactory::instance()->deleteMessageQueue(commandQueue); } \ No newline at end of file diff --git a/unittest/main.cpp b/unittest/main.cpp index 2d65ccb4..ca2d7420 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -1,11 +1,37 @@ +#include +#include +#include +#include +#include +#include +#include + #include -int main(int argc, char* argv[]) { +#include "mocks/EventManagerMock.h" +#include "mocks/HouseKeepingMock.h" - // Catch internal function call - int result = Catch::Session().run(argc, argv); +void factory(void* args) { + new HouseKeepingMock(); + new EventManagerMock(); + new HealthTable(objects::HEALTH_TABLE); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new TimeStamper(objects::TIME_STAMPER); - // global clean-up - return result; + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, + {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; + new PoolManager(objects::IPC_STORE, poolCfg); + } } +int main(int argc, char* argv[]) { + ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr); + ObjectManager::instance()->initialize(); + + // Catch internal function call + int result = Catch::Session().run(argc, argv); + + // global clean-up + return result; +} diff --git a/unittest/mocks/CMakeLists.txt b/unittest/mocks/CMakeLists.txt new file mode 100644 index 00000000..8f4a09ca --- /dev/null +++ b/unittest/mocks/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(${UNITTEST_NAME} PRIVATE + EventManagerMock.cpp + HouseKeepingMock.cpp +) \ No newline at end of file diff --git a/unittest/mocks/EventManagerMock.cpp b/unittest/mocks/EventManagerMock.cpp new file mode 100644 index 00000000..d3b88a9b --- /dev/null +++ b/unittest/mocks/EventManagerMock.cpp @@ -0,0 +1,18 @@ +#include "EventManagerMock.h" + +#include + +EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER) {} + + +ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while (result == HasReturnvaluesIF::RETURN_OK) { + EventMessage message; + result = eventReportQueue->receiveMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + notifyListeners(&message); + } + } + return HasReturnvaluesIF::RETURN_OK; +} \ No newline at end of file diff --git a/unittest/mocks/EventManagerMock.h b/unittest/mocks/EventManagerMock.h index 1e33598b..3add4e89 100644 --- a/unittest/mocks/EventManagerMock.h +++ b/unittest/mocks/EventManagerMock.h @@ -1,27 +1,13 @@ #ifndef EVENTMANAGERMOCK_H_ #define EVENTMANAGERMOCK_H_ -#include +#include -class EventManagerMock { +class EventManagerMock : public EventManager { public: - virtual MessageQueueId_t getEventReportQueue() override; + EventManagerMock(); - virtual ReturnValue_t registerListener(MessageQueueId_t listener, - bool forwardAllButSelected = false) override; - virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) override; - virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, - object_id_t object) override; - virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, - EventId_t idTo = 0, bool idInverted = false, - object_id_t reporterFrom = 0, - object_id_t reporterTo = 0, - bool reporterInverted = false) override; - virtual ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, - EventId_t idTo = 0, bool idInverted = false, - object_id_t reporterFrom = 0, - object_id_t reporterTo = 0, - bool reporterInverted = false) override; + virtual ReturnValue_t performOperation(uint8_t opCode) override; }; #endif /* EVENTMANAGERMOCK_H_ */ \ No newline at end of file diff --git a/unittest/mocks/HouseKeepingMock.cpp b/unittest/mocks/HouseKeepingMock.cpp new file mode 100644 index 00000000..d2592c93 --- /dev/null +++ b/unittest/mocks/HouseKeepingMock.cpp @@ -0,0 +1,8 @@ +#include "HouseKeepingMock.h" + +#include + + +HouseKeepingMock::HouseKeepingMock() : SystemObject(objects::PUS_SERVICE_3_HOUSEKEEPING) {} + +MessageQueueId_t HouseKeepingMock::getHkQueue() const { return MessageQueueIF::NO_QUEUE; } \ No newline at end of file diff --git a/unittest/mocks/HouseKeepingMock.h b/unittest/mocks/HouseKeepingMock.h new file mode 100644 index 00000000..9cc933ed --- /dev/null +++ b/unittest/mocks/HouseKeepingMock.h @@ -0,0 +1,16 @@ +#ifndef HOUSEKEEPINGMOCK_H_ +#define HOUSEKEEPINGMOCK_H_ + +#include +#include +#include + +class HouseKeepingMock : public SystemObject, public AcceptsHkPacketsIF { + public: + HouseKeepingMock(); + + virtual MessageQueueId_t getHkQueue() const; +}; + + +#endif /*HOUSEKEEPINGMOCK_H_*/ \ No newline at end of file From 334ba6d4bfafb5dc38e01474f3d8c9e996d3f58b Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 17 Feb 2022 15:49:39 +0100 Subject: [PATCH 08/23] continued work on event manager mock, slightly usable now --- unittest/controller/testThermalController.cpp | 22 +++++---- unittest/mocks/EventManagerMock.cpp | 47 ++++++++++++++++++- unittest/mocks/EventManagerMock.h | 14 ++++++ 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 468d8e2e..47826cb1 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -7,7 +7,7 @@ #include - +#include "../mocks/EventManagerMock.h" TEST_CASE("Thermal Controller", "[ThermalController]") { const object_id_t THERMAL_CONTROLLER_ID = 0x123; @@ -16,6 +16,10 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { controller.initializeAfterTaskCreation(); + EventManagerMock* eventmanager = + ObjectManager::instance()->get(objects::EVENT_MANAGER); + REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO) == false); + MessageQueueId_t controllerQueue = controller.getCommandQueue(); CommandMessage modeMessage; @@ -23,23 +27,21 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, ControllerBase::MODE_NORMAL, HasModesIF::SUBMODE_NONE); - MessageQueueIF* commandQueue = QueueFactory::instance()->createMessageQueue( - 5, MessageQueueMessage::MAX_MESSAGE_SIZE); - - commandQueue->sendMessage(controllerQueue,&modeMessage); + MessageQueueIF* commandQueue = + QueueFactory::instance()->createMessageQueue(5, MessageQueueMessage::MAX_MESSAGE_SIZE); + + commandQueue->sendMessage(controllerQueue, &modeMessage); REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK); + eventmanager->clearEventList(); + thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID); componentTemperatures.read(); REQUIRE(componentTemperatures.rw == 0); - + componentTemperatures.commit(); - ExecutableObjectIF *eventmanager = ObjectManager::instance()->get(objects::EVENT_MANAGER); - eventmanager->performOperation(); - - QueueFactory::instance()->deleteMessageQueue(commandQueue); } \ No newline at end of file diff --git a/unittest/mocks/EventManagerMock.cpp b/unittest/mocks/EventManagerMock.cpp index d3b88a9b..6956c516 100644 --- a/unittest/mocks/EventManagerMock.cpp +++ b/unittest/mocks/EventManagerMock.cpp @@ -4,7 +4,6 @@ EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER) {} - ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; while (result == HasReturnvaluesIF::RETURN_OK) { @@ -12,7 +11,53 @@ ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) { result = eventReportQueue->receiveMessage(&message); if (result == HasReturnvaluesIF::RETURN_OK) { notifyListeners(&message); + eventList.emplace_back(message); } } return HasReturnvaluesIF::RETURN_OK; +} + +const std::list* EventManagerMock::getEventList() { + // call performOperation() to get all events still in the message Queue into the list + this->performOperation(0); + return &eventList; +} + +void EventManagerMock::clearEventList() { // call performOperation() to get all events still in the + // message Queue into the list + this->performOperation(0); + eventList.clear(); +} + +bool EventManagerMock::isEventInEventList(object_id_t object, Event event) { + return isEventInEventList(object, event::getEventId(event)); +} + +bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId) { + // call performOperation() to get all events still in the message Queue into the list + this->performOperation(0); + for (auto iter = eventList.begin(); iter != eventList.end(); iter++) { + if ((iter->getReporter() == object) && (iter->getEventId() == eventId)) { + return true; + } + } + return false; +} + +bool EventManagerMock::isEventInEventList(object_id_t object, Event event, uint32_t parameter1, + uint32_t parameter2) { + return isEventInEventList(object, event::getEventId(event), parameter1, parameter2); +} + +bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId, + uint32_t parameter1, uint32_t parameter2) { + // call performOperation() to get all events still in the message Queue into the list + this->performOperation(0); + for (auto iter = eventList.begin(); iter != eventList.end(); iter++) { + if ((iter->getReporter() == object) && (iter->getEventId() == eventId) && + (iter->getParameter1() == parameter1) && (iter->getParameter2() == parameter2)) { + return true; + } + } + return false; } \ No newline at end of file diff --git a/unittest/mocks/EventManagerMock.h b/unittest/mocks/EventManagerMock.h index 3add4e89..84588a97 100644 --- a/unittest/mocks/EventManagerMock.h +++ b/unittest/mocks/EventManagerMock.h @@ -3,11 +3,25 @@ #include +#include + class EventManagerMock : public EventManager { public: EventManagerMock(); virtual ReturnValue_t performOperation(uint8_t opCode) override; + + const std::list* getEventList(); + void clearEventList(); + + bool isEventInEventList(object_id_t object, Event event); + bool isEventInEventList(object_id_t object, Event event, uint32_t parameter1, uint32_t parameter2); + + bool isEventInEventList(object_id_t object, EventId_t eventId); + bool isEventInEventList(object_id_t object, EventId_t eventId, uint32_t parameter1, uint32_t parameter2); + + private: + std::list eventList; }; #endif /* EVENTMANAGERMOCK_H_ */ \ No newline at end of file From 090979e5a9fd15ebed13e0fc0e701eb30d5fb680 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 17 Feb 2022 16:27:59 +0100 Subject: [PATCH 09/23] I like my debug output really pretty --- unittest/initTests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unittest/initTests.cpp b/unittest/initTests.cpp index 3821d893..f3a069ac 100644 --- a/unittest/initTests.cpp +++ b/unittest/initTests.cpp @@ -1,10 +1,10 @@ #include #ifdef LINUX -ServiceInterfaceStream sif::debug("DEBUG"); -ServiceInterfaceStream sif::info("INFO"); +ServiceInterfaceStream sif::debug("DEBUG "); +ServiceInterfaceStream sif::info("INFO "); ServiceInterfaceStream sif::warning("WARNING"); -ServiceInterfaceStream sif::error("ERROR", false, false, true); +ServiceInterfaceStream sif::error("ERROR ", false, true, true); #else ServiceInterfaceStream sif::debug("DEBUG", true); ServiceInterfaceStream sif::info("INFO", true); From 4ea8ff9876bbbbaf8a411c72508dd247905441ed Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 17 Feb 2022 16:29:22 +0100 Subject: [PATCH 10/23] cleanup --- mission/controller/ThermalController.cpp | 4 +--- mission/controller/ThermalController.h | 2 +- unittest/controller/testThermalController.cpp | 8 +++++--- unittest/initTests.cpp | 5 +---- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 8ca86b7e..2b6f704f 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -5,14 +5,12 @@ ThermalController::ThermalController(object_id_t objectId, object_id_t parentId) sensorTemperatures(this), componentTemperatures(this) {} -ReturnValue_t ThermalController::perform() { return HasReturnvaluesIF::RETURN_FAILED; } +ReturnValue_t ThermalController::initialize() { return ControllerBase::initialize(); } ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { return RETURN_FAILED; } void ThermalController::performControlOperation() { - sif::info << "tc performOperation()" << std::endl; - ReturnValue_t result = sensorTemperatures.read(); if (result != RETURN_OK) { return; diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 58e147e3..b52796d6 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -8,7 +8,7 @@ class ThermalController : public ExtendedControllerBase { public: ThermalController(object_id_t objectId, object_id_t parentId); - ReturnValue_t perform(); + ReturnValue_t initialize() override; protected: virtual ReturnValue_t handleCommandMessage(CommandMessage* message) override; diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 47826cb1..6d599475 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -13,8 +13,8 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { const object_id_t THERMAL_CONTROLLER_ID = 0x123; ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT); - - controller.initializeAfterTaskCreation(); + REQUIRE(controller.initialize() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(controller.initializeAfterTaskCreation() == HasReturnvaluesIF::RETURN_OK); EventManagerMock* eventmanager = ObjectManager::instance()->get(objects::EVENT_MANAGER); @@ -34,7 +34,9 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK); - eventmanager->clearEventList(); + REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, + ControllerBase::MODE_NORMAL, + HasModesIF::SUBMODE_NONE) == true); thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID); diff --git a/unittest/initTests.cpp b/unittest/initTests.cpp index f3a069ac..5d30bdca 100644 --- a/unittest/initTests.cpp +++ b/unittest/initTests.cpp @@ -23,7 +23,4 @@ enum MESSAGE_TYPE { void clearMissionMessage(CommandMessage* message); } // namespace messagetypes - -void messagetypes::clearMissionMessage(CommandMessage* message) { - -} +void messagetypes::clearMissionMessage(CommandMessage* message) {} From bcac56a65c2ca0aa449e9d79b9528c2f960b63db Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 17 Feb 2022 17:48:32 +0100 Subject: [PATCH 11/23] reworked test setup --- unittest/CMakeLists.txt | 2 +- unittest/controller/testThermalController.cpp | 20 +++---- unittest/initTests.cpp | 26 -------- unittest/main.cpp | 28 +-------- unittest/testEnvironment.cpp | 59 +++++++++++++++++++ unittest/testEnvironment.h | 36 +++++++++++ 6 files changed, 106 insertions(+), 65 deletions(-) delete mode 100644 unittest/initTests.cpp create mode 100644 unittest/testEnvironment.cpp create mode 100644 unittest/testEnvironment.h diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 39f3b66e..1786b71e 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -3,6 +3,6 @@ add_subdirectory(mocks) target_sources(${UNITTEST_NAME} PRIVATE main.cpp - initTests.cpp + testEnvironment.cpp printChar.cpp ) \ No newline at end of file diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 6d599475..a0e96d68 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -1,24 +1,20 @@ -#include -#include -#include -#include #include #include #include -#include "../mocks/EventManagerMock.h" +#include "../testEnvironment.h" TEST_CASE("Thermal Controller", "[ThermalController]") { const object_id_t THERMAL_CONTROLLER_ID = 0x123; ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT); - REQUIRE(controller.initialize() == HasReturnvaluesIF::RETURN_OK); + + testEnvironment::initialize(); + REQUIRE(controller.initializeAfterTaskCreation() == HasReturnvaluesIF::RETURN_OK); - EventManagerMock* eventmanager = - ObjectManager::instance()->get(objects::EVENT_MANAGER); - REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO) == false); + testEnvironment::eventManager->clearEventList(); MessageQueueId_t controllerQueue = controller.getCommandQueue(); @@ -34,9 +30,9 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, - ControllerBase::MODE_NORMAL, - HasModesIF::SUBMODE_NONE) == true); + REQUIRE(testEnvironment::eventManager->isEventInEventList( + THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, ControllerBase::MODE_NORMAL, + HasModesIF::SUBMODE_NONE) == true); thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID); diff --git a/unittest/initTests.cpp b/unittest/initTests.cpp deleted file mode 100644 index 5d30bdca..00000000 --- a/unittest/initTests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include - -#ifdef LINUX -ServiceInterfaceStream sif::debug("DEBUG "); -ServiceInterfaceStream sif::info("INFO "); -ServiceInterfaceStream sif::warning("WARNING"); -ServiceInterfaceStream sif::error("ERROR ", false, true, true); -#else -ServiceInterfaceStream sif::debug("DEBUG", true); -ServiceInterfaceStream sif::info("INFO", true); -ServiceInterfaceStream sif::warning("WARNING", true); -ServiceInterfaceStream sif::error("ERROR", true, false, true); -#endif - -#include -#include - -namespace messagetypes { -enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, -}; - -void clearMissionMessage(CommandMessage* message); -} // namespace messagetypes - -void messagetypes::clearMissionMessage(CommandMessage* message) {} diff --git a/unittest/main.cpp b/unittest/main.cpp index ca2d7420..6438577c 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -1,33 +1,9 @@ -#include -#include -#include -#include -#include -#include -#include - #include -#include "mocks/EventManagerMock.h" -#include "mocks/HouseKeepingMock.h" - -void factory(void* args) { - new HouseKeepingMock(); - new EventManagerMock(); - new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - new TimeStamper(objects::TIME_STAMPER); - - { - PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, - {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; - new PoolManager(objects::IPC_STORE, poolCfg); - } -} +#include "testEnvironment.h" int main(int argc, char* argv[]) { - ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr); - ObjectManager::instance()->initialize(); + testEnvironment::setup(); // Catch internal function call int result = Catch::Session().run(argc, argv); diff --git a/unittest/testEnvironment.cpp b/unittest/testEnvironment.cpp new file mode 100644 index 00000000..e4d5bed2 --- /dev/null +++ b/unittest/testEnvironment.cpp @@ -0,0 +1,59 @@ +#include "testEnvironment.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef LINUX +ServiceInterfaceStream sif::debug("DEBUG "); +ServiceInterfaceStream sif::info("INFO "); +ServiceInterfaceStream sif::warning("WARNING"); +ServiceInterfaceStream sif::error("ERROR ", false, true, true); +#else +ServiceInterfaceStream sif::debug("DEBUG", true); +ServiceInterfaceStream sif::info("INFO", true); +ServiceInterfaceStream sif::warning("WARNING", true); +ServiceInterfaceStream sif::error("ERROR", true, false, true); +#endif + +namespace testEnvironment { + +void factory(void* args) { + new HouseKeepingMock(); + eventManager = new EventManagerMock(); + new HealthTable(objects::HEALTH_TABLE); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new TimeStamper(objects::TIME_STAMPER); + + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, + {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; + new PoolManager(objects::IPC_STORE, poolCfg); + } +} + +void setup() { ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr); } + +void initialize() { ObjectManager::instance()->initialize(); } + +} // namespace testEnvironment + +EventManagerMock* testEnvironment::eventManager = nullptr; + +#include +#include + +namespace messagetypes { +enum MESSAGE_TYPE { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, +}; + +void clearMissionMessage(CommandMessage* message); +} // namespace messagetypes + +void messagetypes::clearMissionMessage(CommandMessage* message) {} diff --git a/unittest/testEnvironment.h b/unittest/testEnvironment.h new file mode 100644 index 00000000..79ff8544 --- /dev/null +++ b/unittest/testEnvironment.h @@ -0,0 +1,36 @@ +#ifndef UNITTEST_TESTENVIRONMENT_H_ +#define UNITTEST_TESTENVIRONMENT_H_ + +#include "mocks/EventManagerMock.h" +#include "mocks/HouseKeepingMock.h" + +/* + * This namespace sets up a general environment for unittests + * + * Only objects generally used in all unittest are created here. Objects needed for + * individual tests are to be contstructed in the individual tests. + * + * The object manager can be initialized by the initialize() call + * + * It also caches pointers to generally useful objects so they do + * not need to be gotten from the object manager each time + */ +namespace testEnvironment { + +/* + * Setup code goes here, called by main() befor any tests + */ +void setup(); + +/* + * Initializes the object manager, to be called at the start of each test, after test specific + * objects are constructed + * + * All objects defined in the factory method are created here + */ +void initialize(); + +extern EventManagerMock* eventManager; +} // namespace testEnvironment + +#endif /*UNITTEST_TESTENVIRONMENT_H_*/ \ No newline at end of file From 57280167a20fb74f67201cd89f26ffc86babc310 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 17 Feb 2022 18:31:21 +0100 Subject: [PATCH 12/23] Updated Dockerfile and Jenkinsfile --- automation/{Dockerfile-q7s => Dockerfile} | 6 ++- automation/Jenkinsfile | 53 ++++++++--------------- 2 files changed, 22 insertions(+), 37 deletions(-) rename automation/{Dockerfile-q7s => Dockerfile} (75%) diff --git a/automation/Dockerfile-q7s b/automation/Dockerfile similarity index 75% rename from automation/Dockerfile-q7s rename to automation/Dockerfile index 207afa04..0c99750c 100644 --- a/automation/Dockerfile-q7s +++ b/automation/Dockerfile @@ -2,7 +2,9 @@ FROM ubuntu:focal RUN apt-get update RUN apt-get --yes upgrade -RUN apt-get --yes install cmake libgpiod-dev xz-utils nano curl +#tzdata is a dependency, won't install otherwise +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get --yes install cmake libgpiod-dev xz-utils nano curl git gcc g++ lcov valgrind # Q7S root filesystem, required for cross-compilation. RUN mkdir -p /usr/rootfs; \ @@ -15,4 +17,4 @@ curl https://buggy.irs.uni-stuttgart.de/eive/tools/gcc-arm-8.3-2019.03-x86_64-ar | tar -xz -C /usr/tools ENV Q7S_SYSROOT="/usr/rootfs/cortexa9hf-neon-xiphos-linux-gnueabi" -ENV PATH=$PATH:"/usr/tools/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" +ENV PATH=$PATH:"/usr/tools/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" \ No newline at end of file diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8d45b2d7..5e8be0c7 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,51 +1,34 @@ pipeline { - agent any + environment { + BUILDDIR_Q7 = 'build_q7', + BUILDDIR_LINUX = 'build_linux' + } + agent { + docker { image 'eive-obsw:d2'} + } stages { - stage('Build Container') { - when { - anyOf { - changeset "automation/Dockerfile-q7s" - branch 'develop'; - changelog 'cleanDocker' - } - } - steps { - sh 'docker build -t eive-fsw-build-q7s:gcc8 - < automation/Dockerfile-q7s' - - } - } stage('Clean') { - when { - anyOf { - changelog 'cleanCI' - changeset '*.cmake' - changeset 'CMakeLists.txt' - } - } steps { - sh 'rm -rf build-q7s-debug' + sh 'rm -rf $BUILDDIR_Q7' + sh 'rm -rf $BUILDDIR_LINUX' } } stage('Build Q7S') { - agent { - docker { - image 'eive-fsw-build-q7s:gcc8' - reuseNode true - } - } steps { - dir('build-q7s-debug') { - sh 'cmake -DTGT_BSP="arm/q7s" -DCMAKE_BUILD_TYPE=Debug -DFSFW_OSAL=linux ..' + dir(BUILDDIR_Q7) { + sh 'cmake -DTGT_BSP="arm/q7s" -DCMAKE_BUILD_TYPE=Debug ..' sh 'cmake --build . -j' } } } - stage('Deploy') { - when { - tag 'v*.*.*' - } + stage('Unittests') { steps { - sh 'echo Deploying' + dir(BUILDDIR_LINUX) { + sh 'cmake ..' + //to be used when unittests are merged... + //sh 'cmake --build -t eive-unittests . -j' + //sh './eive-unittests' + } } } } From 29efde6cbb41b421e95a083a9d7bed6219b8831c Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 17 Feb 2022 18:37:00 +0100 Subject: [PATCH 13/23] what kind of language is this? --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 5e8be0c7..bd5320f1 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { environment { - BUILDDIR_Q7 = 'build_q7', + BUILDDIR_Q7 = 'build_q7' BUILDDIR_LINUX = 'build_linux' } agent { From 52e420b0be29a170cb8a4bfc1693c543b293f525 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 18 Feb 2022 11:37:32 +0100 Subject: [PATCH 14/23] tweaked build of catch2 -only built when needed -no more warnings as catch2 is compiled with default compiler flags --- CMakeLists.txt | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c160fe5..32bf2324 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,20 +139,6 @@ set(FSFW_ADDITIONAL_INC_PATHS # 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 @@ -182,6 +168,24 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(COMPILER_FLAGS "/permissive-") endif() +# 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 "") + set_target_properties(Catch2 PROPERTIES EXCLUDE_FROM_ALL "true") + set_target_properties(Catch2WithMain PROPERTIES EXCLUDE_FROM_ALL "true") +endif() + + add_library(${LIB_EIVE_MISSION}) From 54e3b9970895d00f2fd94dd23af54aa10eb73825 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 18 Feb 2022 11:38:23 +0100 Subject: [PATCH 15/23] enable unittests in Jenkinsfile --- automation/Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index bd5320f1..ba7a2da4 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -25,9 +25,8 @@ pipeline { steps { dir(BUILDDIR_LINUX) { sh 'cmake ..' - //to be used when unittests are merged... - //sh 'cmake --build -t eive-unittests . -j' - //sh './eive-unittests' + sh 'cmake --build -t eive-unittests . -j' + sh './eive-unittests' } } } From 6a8c9e14e95fb8b1e24e71b0ec15677d225ea384 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 18 Feb 2022 11:39:03 +0100 Subject: [PATCH 16/23] added libgps to docker to be able to build for linux --- automation/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 0c99750c..9042cf13 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update RUN apt-get --yes upgrade #tzdata is a dependency, won't install otherwise ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get --yes install cmake libgpiod-dev xz-utils nano curl git gcc g++ lcov valgrind +RUN apt-get --yes install cmake libgpiod-dev xz-utils nano curl git gcc g++ lcov valgrind libgps-dev # Q7S root filesystem, required for cross-compilation. RUN mkdir -p /usr/rootfs; \ From 15bab6ae337184c939ff719aacaee5f16f719957 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 18 Feb 2022 11:44:05 +0100 Subject: [PATCH 17/23] c'mon... --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index ba7a2da4..535d5777 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -25,7 +25,7 @@ pipeline { steps { dir(BUILDDIR_LINUX) { sh 'cmake ..' - sh 'cmake --build -t eive-unittests . -j' + sh 'cmake --build . -t eive-unittests -j' sh './eive-unittests' } } From c37e7022d16abf51fbad24e60a0f6c922a730b73 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 18 Feb 2022 11:47:42 +0100 Subject: [PATCH 18/23] argh --- automation/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 535d5777..401a346f 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -25,8 +25,8 @@ pipeline { steps { dir(BUILDDIR_LINUX) { sh 'cmake ..' - sh 'cmake --build . -t eive-unittests -j' - sh './eive-unittests' + sh 'cmake --build . -t eive-unittest -j' + sh './eive-unittest' } } } From 606da48861c8ed6eb133a36c8cb5d706c24dfdee Mon Sep 17 00:00:00 2001 From: Uli Date: Wed, 2 Mar 2022 16:02:23 +0100 Subject: [PATCH 19/23] changing fs.mqueue.msg_max for docker to be able to run unit tests --- automation/Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 401a346f..8f274640 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -4,7 +4,10 @@ pipeline { BUILDDIR_LINUX = 'build_linux' } agent { - docker { image 'eive-obsw:d2'} + docker { + image 'eive-obsw:d2' + args '--sysctl fs.mqueue.msg_max=100' + } } stages { stage('Clean') { From 182b90ee6dbb232875acb3b60fd02bcac2ce0339 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 2 Mar 2022 17:04:58 +0100 Subject: [PATCH 20/23] small fixes --- bsp_hosted/fsfwconfig/devices/gpioIds.h | 5 ++++- common/config/commonClassIds.h | 1 + mission/devices/RadiationSensorHandler.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index 1ede0571..0c426ccd 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -47,7 +47,10 @@ enum gpioId_t { SPI_MUX_BIT_3, SPI_MUX_BIT_4, SPI_MUX_BIT_5, - SPI_MUX_BIT_6 + SPI_MUX_BIT_6, + + CS_RAD_SENSOR, + ENABLE_RADFET }; } diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index ab8e06d5..01f186a4 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -27,6 +27,7 @@ enum commonClassIds: uint8_t { RATE_SETTER, //RS ARCSEC_JSON_BASE, //JSONBASE NVM_PARAM_BASE, //NVMB + SA_DEPL_HANDLER, //SADPL COMMON_CLASS_ID_END // [EXPORT] : [END] }; diff --git a/mission/devices/RadiationSensorHandler.h b/mission/devices/RadiationSensorHandler.h index 5aeb4add..cc5f4d4f 100644 --- a/mission/devices/RadiationSensorHandler.h +++ b/mission/devices/RadiationSensorHandler.h @@ -3,8 +3,8 @@ #include #include +#include -class GpioIF; /** * @brief This is the device handler class for radiation sensor on the OBC IF Board. The From 05bd1cc8c60e58f079f90cbef850029b19016d9d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 2 Mar 2022 17:47:48 +0100 Subject: [PATCH 21/23] forgot one --- linux/fsfwconfig/returnvalues/classIds.h | 1 - 1 file changed, 1 deletion(-) diff --git a/linux/fsfwconfig/returnvalues/classIds.h b/linux/fsfwconfig/returnvalues/classIds.h index 86edb85f..ecfc8ca9 100644 --- a/linux/fsfwconfig/returnvalues/classIds.h +++ b/linux/fsfwconfig/returnvalues/classIds.h @@ -12,7 +12,6 @@ namespace CLASS_ID { enum { CLASS_ID_START = COMMON_CLASS_ID_END, - SA_DEPL_HANDLER, // SADPL SD_CARD_MANAGER, // SDMA SCRATCH_BUFFER, // SCBU CLASS_ID_END // [EXPORT] : [END] From 221d7b408a09d9943b38170a8c7a9916a1a99eb8 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 2 Mar 2022 17:55:12 +0100 Subject: [PATCH 22/23] using new docker container name --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8f274640..300a7749 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { } agent { docker { - image 'eive-obsw:d2' + image 'eive-obsw-ci:d2' args '--sysctl fs.mqueue.msg_max=100' } } From 458b33e5fd5a251ad751643bc11b8eb0f81e4c7d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Mar 2022 10:34:49 +0100 Subject: [PATCH 23/23] submodule updates --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 6e0b9069..75c56280 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 6e0b90696da2dfd2ec4749dfdb73950be2283c25 +Subproject commit 75c56280ad139640d2c12ac4ab78ce66c25fb495 diff --git a/tmtc b/tmtc index 9efb347a..37c1a68d 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9efb347aa241e5fb7a864540edbd87908110339c +Subproject commit 37c1a68da1b465514e84403b06ce40d035e4ad88