From 1bef032260bfbdb658079b454090c85edbf3ce1d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 19:43:44 +0200 Subject: [PATCH] unittests were refactored --- .gitmodules | 3 - CMakeLists.txt | 12 +-- fsfw | 2 +- thirdparty/Catch2 | 1 - unittest/main.cpp | 2 +- unittest/testcfg/CMakeLists.txt | 9 --- unittest/testcfg/FSFWConfig.h.in | 81 ------------------- unittest/testcfg/OBSWConfig.h.in | 8 -- unittest/testcfg/TestsConfig.h.in | 21 ----- unittest/testcfg/devices/logicalAddresses.cpp | 5 -- unittest/testcfg/devices/logicalAddresses.h | 15 ---- .../testcfg/devices/powerSwitcherList.cpp | 4 - unittest/testcfg/devices/powerSwitcherList.h | 12 --- unittest/testcfg/events/subsystemIdRanges.h | 19 ----- unittest/testcfg/ipc/MissionMessageTypes.cpp | 12 --- unittest/testcfg/ipc/MissionMessageTypes.h | 22 ----- unittest/testcfg/objects/systemObjectList.h | 33 -------- .../PollingSequenceFactory.cpp | 39 --------- .../pollingsequence/PollingSequenceFactory.h | 32 -------- unittest/testcfg/returnvalues/classIds.h | 17 ---- unittest/testcfg/tmtc/apid.h | 18 ----- unittest/testcfg/tmtc/pusIds.h | 25 ------ 22 files changed, 5 insertions(+), 387 deletions(-) delete mode 160000 thirdparty/Catch2 delete mode 100644 unittest/testcfg/CMakeLists.txt delete mode 100644 unittest/testcfg/FSFWConfig.h.in delete mode 100644 unittest/testcfg/OBSWConfig.h.in delete mode 100644 unittest/testcfg/TestsConfig.h.in delete mode 100644 unittest/testcfg/devices/logicalAddresses.cpp delete mode 100644 unittest/testcfg/devices/logicalAddresses.h delete mode 100644 unittest/testcfg/devices/powerSwitcherList.cpp delete mode 100644 unittest/testcfg/devices/powerSwitcherList.h delete mode 100644 unittest/testcfg/events/subsystemIdRanges.h delete mode 100644 unittest/testcfg/ipc/MissionMessageTypes.cpp delete mode 100644 unittest/testcfg/ipc/MissionMessageTypes.h delete mode 100644 unittest/testcfg/objects/systemObjectList.h delete mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp delete mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.h delete mode 100644 unittest/testcfg/returnvalues/classIds.h delete mode 100644 unittest/testcfg/tmtc/apid.h delete mode 100644 unittest/testcfg/tmtc/pusIds.h diff --git a/.gitmodules b/.gitmodules index 1ca8bec5..1f3dc6ec 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,6 +22,3 @@ [submodule "thirdparty/json"] path = thirdparty/json url = https://github.com/nlohmann/json.git -[submodule "thirdparty/Catch2"] - path = thirdparty/Catch2 - url = https://github.com/catchorg/Catch2.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 656ee3ee..fb944393 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,15 +90,10 @@ set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(EIVE_ADD_LINUX_FILES False) if(EIVE_BUILD_UNITTESTS) - option(FSFW_ADD_UNITTESTS "Build the FSFW unittests as well" ON) - # Use FSFW custom main for unittests - set(FSFW_CUSTOM_UNITTEST_RUNNER ON) endif() -if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) +if(FSFW_ADD_UNITTESTS) set(CATCH2_TARGET Catch2) -else() - set(CATCH2_TARGET Catch2WithMain) endif() # Analyse different OS and architecture/target options, determine BSP_PATH, @@ -139,8 +134,8 @@ else() endif() if(EIVE_BUILD_UNITTESTS) - configure_file(${UNITTEST_CFG_PATH}/TestsConfig.h.in TestsConfig.h) - set(FSFW_CONFIG_PATH ${UNITTEST_CFG_PATH}) + # configure_file(${UNITTEST_CFG_PATH}/TestsConfig.h.in TestsConfig.h) + # set(FSFW_CONFIG_PATH ${UNITTEST_CFG_PATH}) endif() # Configuration files @@ -156,7 +151,6 @@ if(NOT EIVE_BUILD_WATCHDOG) endif() - configure_file(${WATCHDOG_PATH}/watchdogConf.h.in watchdogConf.h) # Set common config path for FSFW diff --git a/fsfw b/fsfw index ad68802f..4130dd9e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit ad68802fe4af9af554bd8221c607ba1f4d87185b +Subproject commit 4130dd9e32eb1d4a5b0e993408ae614952bdd005 diff --git a/thirdparty/Catch2 b/thirdparty/Catch2 deleted file mode 160000 index 42695403..00000000 --- a/thirdparty/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 426954032f263754d2fff4cffce8552e7371965e diff --git a/unittest/main.cpp b/unittest/main.cpp index cd4f4b77..811df98e 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -2,6 +2,6 @@ #include "fsfw_tests/unit/CatchRunner.h" int main(int argc, char* argv[]) { - fsfwtest::customMain(argc, argv); + // fsfwtest::customMain(argc, argv); } diff --git a/unittest/testcfg/CMakeLists.txt b/unittest/testcfg/CMakeLists.txt deleted file mode 100644 index 50d13663..00000000 --- a/unittest/testcfg/CMakeLists.txt +++ /dev/null @@ -1,9 +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/unittest/testcfg/FSFWConfig.h.in b/unittest/testcfg/FSFWConfig.h.in deleted file mode 100644 index d2ed901d..00000000 --- a/unittest/testcfg/FSFWConfig.h.in +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef CONFIG_FSFWCONFIG_H_ -#define CONFIG_FSFWCONFIG_H_ - -#include -#include - -//! 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 1 - -//! More FSFW related printouts. Useful for development. -#define FSFW_ENHANCED_PRINTOUT 0 - -//! 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 -#endif - -#define FSFW_USE_PUS_C_TELEMETRY 1 -#define FSFW_USE_PUS_C_TELECOMMANDS 1 - -//! Can be used to enable additional debugging printouts for developing the FSFW -#define FSFW_PRINT_VERBOSITY_LEVEL 0 - -//! Can be used to disable the ANSI color sequences for C stdio. -#define FSFW_COLORED_OUTPUT 0 - -//! 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 - -#if FSFW_OBJ_EVENT_TRANSLATION == 1 -//! Specify whether info events are printed too. -#define FSFW_DEBUG_INFO 1 -#include "objects/translateObjects.h" -#include "events/translateEvents.h" -#else -#endif - -//! 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 - -//! Specify whether a special mode store is used for Subsystem components. -#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 - -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; - -//! Configure the allocated pool sizes for the event manager. -static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; -static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; -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 -//! 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; - -} - -#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/unittest/testcfg/OBSWConfig.h.in b/unittest/testcfg/OBSWConfig.h.in deleted file mode 100644 index 34eda31f..00000000 --- a/unittest/testcfg/OBSWConfig.h.in +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef TESTCFG_OBSWCONFIG_H_ -#define TESTCFG_OBSWCONFIG_H_ - - - - - -#endif /* TESTCFG_OBSWCONFIG_H_ */ diff --git a/unittest/testcfg/TestsConfig.h.in b/unittest/testcfg/TestsConfig.h.in deleted file mode 100644 index 7d950070..00000000 --- a/unittest/testcfg/TestsConfig.h.in +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ -#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ - -#define FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS 1 - -#ifdef __cplusplus - -#include "objects/systemObjectList.h" -#include "events/subsystemIdRanges.h" -#include "returnvalues/classIds.h" - -namespace config { -#endif - -/* Add mission configuration flags here */ - -#ifdef __cplusplus -} -#endif - -#endif /* FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ */ diff --git a/unittest/testcfg/devices/logicalAddresses.cpp b/unittest/testcfg/devices/logicalAddresses.cpp deleted file mode 100644 index c7ce314d..00000000 --- a/unittest/testcfg/devices/logicalAddresses.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "logicalAddresses.h" - - - - diff --git a/unittest/testcfg/devices/logicalAddresses.h b/unittest/testcfg/devices/logicalAddresses.h deleted file mode 100644 index cdf87025..00000000 --- a/unittest/testcfg/devices/logicalAddresses.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_ -#define CONFIG_DEVICES_LOGICALADDRESSES_H_ - -#include -#include -#include - -namespace addresses { - /* Logical addresses have uint32_t datatype */ - enum logicalAddresses: address_t { - }; -} - - -#endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */ diff --git a/unittest/testcfg/devices/powerSwitcherList.cpp b/unittest/testcfg/devices/powerSwitcherList.cpp deleted file mode 100644 index 343f78d0..00000000 --- a/unittest/testcfg/devices/powerSwitcherList.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "powerSwitcherList.h" - - - diff --git a/unittest/testcfg/devices/powerSwitcherList.h b/unittest/testcfg/devices/powerSwitcherList.h deleted file mode 100644 index 86ddea57..00000000 --- a/unittest/testcfg/devices/powerSwitcherList.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CONFIG_DEVICES_POWERSWITCHERLIST_H_ -#define CONFIG_DEVICES_POWERSWITCHERLIST_H_ - -namespace switches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum switcherList { - }; - -} - - -#endif /* CONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/unittest/testcfg/events/subsystemIdRanges.h b/unittest/testcfg/events/subsystemIdRanges.h deleted file mode 100644 index 26af041e..00000000 --- a/unittest/testcfg/events/subsystemIdRanges.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ -#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ - -#include -#include "commonSubsystemIds.h" -#include - -/** - * @brief Custom subsystem IDs can be added here - * @details - * Subsystem IDs are used to create unique events. - */ -namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, -}; -} - -#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/unittest/testcfg/ipc/MissionMessageTypes.cpp b/unittest/testcfg/ipc/MissionMessageTypes.cpp deleted file mode 100644 index d68cb58c..00000000 --- a/unittest/testcfg/ipc/MissionMessageTypes.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "MissionMessageTypes.h" - -#include - -void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } -} - - diff --git a/unittest/testcfg/ipc/MissionMessageTypes.h b/unittest/testcfg/ipc/MissionMessageTypes.h deleted file mode 100644 index 832d8e58..00000000 --- a/unittest/testcfg/ipc/MissionMessageTypes.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CONFIG_IPC_MISSIONMESSAGETYPES_H_ -#define CONFIG_IPC_MISSIONMESSAGETYPES_H_ - -#include - -class CommandMessage; - -/** - * Custom command messages are specified here. - * Most messages needed to use FSFW are already located in - * - * @param message Generic Command Message - */ -namespace messagetypes{ -enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, -}; - -void clearMissionMessage(CommandMessage* message); -} - -#endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/unittest/testcfg/objects/systemObjectList.h b/unittest/testcfg/objects/systemObjectList.h deleted file mode 100644 index 9ed43873..00000000 --- a/unittest/testcfg/objects/systemObjectList.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ - -#include -#include "commonObjects.h" -#include - -// The objects will be instantiated in the ID order -namespace objects { - enum sourceObjects: uint32_t { - /* All addresses between start and end are reserved for the FSFW */ - 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, - - TEST_ECHO_COM_IF = 20, - TEST_DEVICE = 21, - - HK_RECEIVER_MOCK = 22, - TEST_LOCAL_POOL_OWNER_BASE = 25, - - SHARED_SET_ID = 26 - - }; -} - -#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp deleted file mode 100644 index e3ee874a..00000000 --- a/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "PollingSequenceFactory.h" - -#include - -#include -#include -#include - -ReturnValue_t pst::pollingSequenceInitDefault( - FixedTimeslotTaskIF *thisSequence) { - /* Length of a communication cycle */ - uint32_t length = thisSequence->getPeriodMs(); - - /* Add polling sequence table here */ - thisSequence->addSlot(objects::TEST_DEVICE, 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TEST_DEVICE, 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TEST_DEVICE, 0.45 * length, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TEST_DEVICE, 0.6 * length, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TEST_DEVICE, 0.8 * length, - DeviceHandlerIF::GET_READ); - - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; - } - else { -#if FSFW_CPP_OSTREAM_ENABLED - sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" - << std::endl; -#else - sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); -#endif - return HasReturnvaluesIF::RETURN_FAILED; - } -} - diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.h b/unittest/testcfg/pollingsequence/PollingSequenceFactory.h deleted file mode 100644 index c5d41b7d..00000000 --- a/unittest/testcfg/pollingsequence/PollingSequenceFactory.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef POLLINGSEQUENCEFACTORY_H_ -#define POLLINGSEQUENCEFACTORY_H_ - -#include - -class FixedTimeslotTaskIF; - -/** - * All device handlers are scheduled by adding them into Polling Sequence Tables (PST) - * to satisfy stricter timing requirements of device communication, - * A device handler has four different communication steps: - * 1. DeviceHandlerIF::SEND_WRITE -> Send write via interface - * 2. DeviceHandlerIF::GET_WRITE -> Get confirmation for write - * 3. DeviceHandlerIF::SEND_READ -> Send read request - * 4. DeviceHandlerIF::GET_READ -> Read from interface - * The PST specifies precisely when the respective ComIF functions are called - * during the communication cycle time. - * The task is created using the FixedTimeslotTaskIF, - * which utilises the underlying Operating System Abstraction Layer (OSAL) - * - * @param thisSequence FixedTimeslotTaskIF * object is passed inside the Factory class when creating the PST - * @return - */ -namespace pst { - -/* Default PST */ -ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); - - -} - -#endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/unittest/testcfg/returnvalues/classIds.h b/unittest/testcfg/returnvalues/classIds.h deleted file mode 100644 index 7a292708..00000000 --- a/unittest/testcfg/returnvalues/classIds.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ -#define CONFIG_RETURNVALUES_CLASSIDS_H_ - -#include "commonClassIds.h" -#include - -/** - * @brief CLASS_ID defintions which are required for custom returnvalues. - */ -namespace CLASS_ID { -enum { - MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT, -}; -} - - -#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/unittest/testcfg/tmtc/apid.h b/unittest/testcfg/tmtc/apid.h deleted file mode 100644 index 0172f6e3..00000000 --- a/unittest/testcfg/tmtc/apid.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CONFIG_TMTC_APID_H_ -#define CONFIG_TMTC_APID_H_ - -#include - -/** - * Application Process Definition: entity, uniquely identified by an - * application process ID (APID), capable of generating telemetry source - * packets and receiving telecommand packets. - * - * Chose APID(s) for mission and define it here. - */ -namespace apid { - static const uint16_t EIVE_OBSW = 0x65; -} - - -#endif /* CONFIG_TMTC_APID_H_ */ diff --git a/unittest/testcfg/tmtc/pusIds.h b/unittest/testcfg/tmtc/pusIds.h deleted file mode 100644 index 821a9982..00000000 --- a/unittest/testcfg/tmtc/pusIds.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CONFIG_TMTC_PUSIDS_HPP_ -#define CONFIG_TMTC_PUSIDS_HPP_ - -#include - -namespace pus { -enum Ids: uint8_t { - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_11 = 11, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, -}; -}; - -#endif /* CONFIG_TMTC_PUSIDS_HPP_ */