reworked test setup
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
parent
4ea8ff9876
commit
bcac56a65c
@ -3,6 +3,6 @@ add_subdirectory(mocks)
|
|||||||
|
|
||||||
target_sources(${UNITTEST_NAME} PRIVATE
|
target_sources(${UNITTEST_NAME} PRIVATE
|
||||||
main.cpp
|
main.cpp
|
||||||
initTests.cpp
|
testEnvironment.cpp
|
||||||
printChar.cpp
|
printChar.cpp
|
||||||
)
|
)
|
@ -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 <fsfw/ipc/QueueFactory.h>
|
||||||
#include <mission/controller/ThermalController.h>
|
#include <mission/controller/ThermalController.h>
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "../mocks/EventManagerMock.h"
|
#include "../testEnvironment.h"
|
||||||
|
|
||||||
TEST_CASE("Thermal Controller", "[ThermalController]") {
|
TEST_CASE("Thermal Controller", "[ThermalController]") {
|
||||||
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
|
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
|
||||||
|
|
||||||
ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT);
|
ThermalController controller(THERMAL_CONTROLLER_ID, objects::NO_OBJECT);
|
||||||
REQUIRE(controller.initialize() == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
testEnvironment::initialize();
|
||||||
|
|
||||||
REQUIRE(controller.initializeAfterTaskCreation() == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(controller.initializeAfterTaskCreation() == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
EventManagerMock* eventmanager =
|
testEnvironment::eventManager->clearEventList();
|
||||||
ObjectManager::instance()->get<EventManagerMock>(objects::EVENT_MANAGER);
|
|
||||||
REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO) == false);
|
|
||||||
|
|
||||||
MessageQueueId_t controllerQueue = controller.getCommandQueue();
|
MessageQueueId_t controllerQueue = controller.getCommandQueue();
|
||||||
|
|
||||||
@ -34,8 +30,8 @@ TEST_CASE("Thermal Controller", "[ThermalController]") {
|
|||||||
|
|
||||||
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO,
|
REQUIRE(testEnvironment::eventManager->isEventInEventList(
|
||||||
ControllerBase::MODE_NORMAL,
|
THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO, ControllerBase::MODE_NORMAL,
|
||||||
HasModesIF::SUBMODE_NONE) == true);
|
HasModesIF::SUBMODE_NONE) == true);
|
||||||
|
|
||||||
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);
|
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);
|
||||||
|
@ -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) {}
|
|
@ -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 <catch2/catch_session.hpp>
|
||||||
|
|
||||||
#include "mocks/EventManagerMock.h"
|
#include "testEnvironment.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ObjectManager::instance()->setObjectFactoryFunction(factory, nullptr);
|
testEnvironment::setup();
|
||||||
ObjectManager::instance()->initialize();
|
|
||||||
|
|
||||||
// Catch internal function call
|
// Catch internal function call
|
||||||
int result = Catch::Session().run(argc, argv);
|
int result = Catch::Session().run(argc, argv);
|
||||||
|
59
unittest/testEnvironment.cpp
Normal file
59
unittest/testEnvironment.cpp
Normal 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) {}
|
36
unittest/testEnvironment.h
Normal file
36
unittest/testEnvironment.h
Normal 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_*/
|
Loading…
Reference in New Issue
Block a user