v1.10.0 #220

Merged
meierj merged 592 commits from develop into main 2022-04-22 07:42:20 +02:00
27 changed files with 482 additions and 130 deletions
Showing only changes of commit 63c4095d4d - Show all commits

View File

@ -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)
@ -52,6 +52,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)
@ -85,13 +86,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)
@ -135,10 +129,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)
@ -160,6 +150,9 @@ set(FSFW_ADDITIONAL_INC_PATHS
${CMAKE_CURRENT_BINARY_DIR}
)
# Check whether the user has already installed Catch2 first
find_package(Catch2 3)
################################################################################
# Executable and Sources
################################################################################
@ -173,7 +166,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
"-Wno-unused-parameter"
"-Wno-psabi"
)
# Remove unused sections.
add_compile_options(
"-ffunction-sections"
@ -189,11 +181,29 @@ 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})
# Add executable
# Add main executable
add_executable(${OBSW_NAME})
if(EIVE_CREATE_UNIQUE_OBSW_BIN)
set(OBSW_BIN_NAME ${CMAKE_PROJECT_NAME}-$ENV{USERNAME})
@ -208,11 +218,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()
@ -222,16 +236,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})
@ -243,10 +257,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
@ -272,6 +284,11 @@ if(TGT_BSP MATCHES "arm/q7s")
)
endif()
target_link_libraries(${UNITTEST_NAME} PRIVATE
Catch2
${LIB_EIVE_MISSION}
)
if(TGT_BSP MATCHES "arm/egse")
target_link_libraries(${OBSW_NAME} PRIVATE
${LIB_ARCSEC}
@ -297,12 +314,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}
)

View File

@ -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 libgps-dev
# Q7S root filesystem, required for cross-compilation.
RUN mkdir -p /usr/rootfs; \

View File

@ -1,51 +1,36 @@
pipeline {
agent any
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'
}
environment {
BUILDDIR_Q7 = 'build_q7'
BUILDDIR_LINUX = 'build_linux'
}
agent {
docker {
image 'eive-obsw-ci:d2'
args '--sysctl fs.mqueue.msg_max=100'
}
}
stages {
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 ..'
sh 'cmake --build . -t eive-unittest -j'
sh './eive-unittest'
}
}
}
}

View File

@ -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()

View File

@ -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
};
}

View File

@ -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]
};

View File

@ -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()

View File

@ -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]

View File

@ -1,3 +1,4 @@
add_subdirectory(controller)
add_subdirectory(core)
add_subdirectory(devices)
add_subdirectory(utility)

View File

@ -0,0 +1,3 @@
target_sources(${LIB_EIVE_MISSION} PRIVATE
ThermalController.cpp
)

View File

@ -1,42 +1,48 @@
#include "ThermalController.h"
#include <mission/devices/devicedefinitions/ThermalSensorPacket.h>
ThermalController::ThermalController(object_id_t objectId, object_id_t parentId)
: ExtendedControllerBase(objectId, parentId),
sensorTemperatures(this),
componentTemperatures(this) {}
ThermalController::ThermalController(object_id_t objectId)
: ExtendedControllerBase(objectId, objects::NO_OBJECT), thermalControllerSet(objectId) {}
ReturnValue_t ThermalController::initialize() { return ControllerBase::initialize(); }
ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) {
return RETURN_FAILED;
}
void ThermalController::performControlOperation() {
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();
}
void ThermalController::performControlOperation() {}
ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_RW, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_GPS, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(thermalControllerDefinitions::COMPONENT_RW, new PoolEntry<float>({0.0}));
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<HasLocalDataPoolIF>(
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;
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 HasReturnvaluesIF::RETURN_OK;
uint32_t* msToReachTheMode) {
if (submode != SUBMODE_NONE) {
return INVALID_SUBMODE;
}
if ((mode != MODE_OFF) && (mode != MODE_ON) && (mode != MODE_NORMAL)) {
return INVALID_MODE;
}
return RETURN_OK;
}

View File

@ -2,30 +2,28 @@
#define MISSION_CONTROLLER_THERMALCONTROLLER_H_
#include <fsfw/controller/ExtendedControllerBase.h>
#include "ctrldefinitions/ThermalCtrlPackets.h"
#include <mission/controller/controllerdefinitions/ThermalControllerDefinitions.h>
class ThermalController : public ExtendedControllerBase {
public:
ThermalController(object_id_t objectId);
ThermalController(object_id_t objectId, object_id_t parentId);
ReturnValue_t initialize() override;
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;
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;
thermalControllerDefinitions::SensorTemperatures sensorTemperatures;
thermalControllerDefinitions::ComponentTemperatures componentTemperatures;
};
#endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */

View File

@ -0,0 +1,43 @@
#ifndef MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_
#define MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
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<float> rw = lp_var_t<float>(sid.objectId, PoolIds::SENSOR_RW, this);
lp_var_t<float> gps = lp_var_t<float>(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<float> rw = lp_var_t<float>(sid.objectId, PoolIds::COMPONENT_RW, this);
};
} // namespace thermalControllerDefinitions
#endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ */

View File

@ -3,8 +3,8 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h>
#include <fsfw_hal/common/gpio/GpioIF.h>
class GpioIF;
/**
* @brief This is the device handler class for radiation sensor on the OBC IF Board. The

View File

@ -1,5 +1,8 @@
add_subdirectory(testcfg)
add_subdirectory(controller)
add_subdirectory(mocks)
target_sources(${TARGET_NAME} PRIVATE
target_sources(${UNITTEST_NAME} PRIVATE
main.cpp
testEnvironment.cpp
printChar.cpp
)

View File

@ -0,0 +1,3 @@
target_sources(${UNITTEST_NAME} PRIVATE
testThermalController.cpp
)

View File

@ -0,0 +1,45 @@
#include <fsfw/ipc/QueueFactory.h>
#include <mission/controller/ThermalController.h>
#include <catch2/catch_test_macros.hpp>
#include "../testEnvironment.h"
TEST_CASE("Thermal Controller", "[ThermalController]") {
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT);
testEnvironment::initialize();
REQUIRE(controller.initializeAfterTaskCreation() == HasReturnvaluesIF::RETURN_OK);
testEnvironment::eventManager->clearEventList();
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);
REQUIRE(testEnvironment::eventManager->isEventInEventList(
THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, ControllerBase::MODE_NORMAL,
HasModesIF::SUBMODE_NONE) == true);
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);
componentTemperatures.read();
REQUIRE(componentTemperatures.rw == 0);
componentTemperatures.commit();
QueueFactory::instance()->deleteMessageQueue(commandQueue);
}

View File

@ -1,6 +1,13 @@
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw_tests/unit/CatchRunner.h"
#include <catch2/catch_session.hpp>
#include "testEnvironment.h"
int main(int argc, char* argv[]) {
// fsfwtest::customMain(argc, argv);
testEnvironment::setup();
// Catch internal function call
int result = Catch::Session().run(argc, argv);
// global clean-up
return result;
}

View File

@ -0,0 +1,4 @@
target_sources(${UNITTEST_NAME} PRIVATE
EventManagerMock.cpp
HouseKeepingMock.cpp
)

View File

@ -0,0 +1,63 @@
#include "EventManagerMock.h"
#include <fsfw/ipc/QueueFactory.h>
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);
eventList.emplace_back(message);
}
}
return HasReturnvaluesIF::RETURN_OK;
}
const std::list<EventMessage>* 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;
}

View File

@ -0,0 +1,27 @@
#ifndef EVENTMANAGERMOCK_H_
#define EVENTMANAGERMOCK_H_
#include <fsfw/events/EventManager.h>
#include <list>
class EventManagerMock : public EventManager {
public:
EventManagerMock();
virtual ReturnValue_t performOperation(uint8_t opCode) override;
const std::list<EventMessage>* 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<EventMessage> eventList;
};
#endif /* EVENTMANAGERMOCK_H_ */

View File

@ -0,0 +1,8 @@
#include "HouseKeepingMock.h"
#include <fsfw/objectmanager/frameworkObjects.h>
HouseKeepingMock::HouseKeepingMock() : SystemObject(objects::PUS_SERVICE_3_HOUSEKEEPING) {}
MessageQueueId_t HouseKeepingMock::getHkQueue() const { return MessageQueueIF::NO_QUEUE; }

View File

@ -0,0 +1,16 @@
#ifndef HOUSEKEEPINGMOCK_H_
#define HOUSEKEEPINGMOCK_H_
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/ipc/MessageQueueIF.h>
class HouseKeepingMock : public SystemObject, public AcceptsHkPacketsIF {
public:
HouseKeepingMock();
virtual MessageQueueId_t getHkQueue() const;
};
#endif /*HOUSEKEEPINGMOCK_H_*/

11
unittest/printChar.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "printChar.h"
#include <cstdio>
void printChar(const char* character, bool errStream) {
if (errStream) {
std::putc(*character, stderr);
return;
}
std::putc(*character, stdout);
}

6
unittest/printChar.h Normal file
View File

@ -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_ */

View File

@ -0,0 +1,59 @@
#include "testEnvironment.h"
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
#include <fsfw/internalerror/InternalErrorReporter.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/storagemanager/PoolManager.h>
#include <fsfw/timemanager/TimeStamper.h>
#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 <fsfw/ipc/CommandMessage.h>
#include <fsfw/ipc/FwMessageTypes.h>
namespace messagetypes {
enum MESSAGE_TYPE {
MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT,
};
void clearMissionMessage(CommandMessage* message);
} // namespace messagetypes
void messagetypes::clearMissionMessage(CommandMessage* message) {}

View File

@ -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_*/