v1.9.0 #175

Merged
muellerr merged 623 commits from develop into main 2022-03-08 10:32:41 +01:00
6 changed files with 106 additions and 65 deletions
Showing only changes of commit bcac56a65c - Show all commits

View File

@ -3,6 +3,6 @@ add_subdirectory(mocks)
target_sources(${UNITTEST_NAME} PRIVATE
main.cpp
initTests.cpp
testEnvironment.cpp
printChar.cpp
)

View File

@ -1,24 +1,20 @@
#include <fsfw/events/EventManagerIF.h>
#include <fsfw/health/HealthTable.h>
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
#include <fsfw/internalerror/InternalErrorReporter.h>
#include <fsfw/ipc/QueueFactory.h>
#include <mission/controller/ThermalController.h>
#include <catch2/catch_test_macros.hpp>
#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<EventManagerMock>(objects::EVENT_MANAGER);
REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO) == false);
testEnvironment::eventManager->clearEventList();
MessageQueueId_t controllerQueue = controller.getCommandQueue();
@ -34,8 +30,8 @@ TEST_CASE("Thermal Controller", "[ThermalController]") {
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO,
ControllerBase::MODE_NORMAL,
REQUIRE(testEnvironment::eventManager->isEventInEventList(
THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, ControllerBase::MODE_NORMAL,
HasModesIF::SUBMODE_NONE) == true);
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);

View File

@ -1,26 +0,0 @@
#include <fsfw/serviceinterface/ServiceInterfaceStream.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
#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

@ -1,33 +1,9 @@
#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/storagemanager/PoolManager.h>
#include <fsfw/timemanager/TimeStamper.h>
#include <catch2/catch_session.hpp>
#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);

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