taken over unnittest folder from upstream
This commit is contained in:
parent
0b056720ba
commit
7c390c07ee
@ -1,8 +1,7 @@
|
|||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
#include "CatchFactory.h"
|
||||||
|
|
||||||
#include <testcfg/cdatapool/dataPoolInit.h>
|
#include <testcfg/cdatapool/dataPoolInit.h>
|
||||||
#include <testcfg/objects/Factory.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GCOV
|
#ifdef GCOV
|
||||||
#include <gcov.h>
|
#include <gcov.h>
|
||||||
@ -11,15 +10,15 @@
|
|||||||
#include "../../objectmanager/ObjectManager.h"
|
#include "../../objectmanager/ObjectManager.h"
|
||||||
#include "../../objectmanager/ObjectManagerIF.h"
|
#include "../../objectmanager/ObjectManagerIF.h"
|
||||||
#include "../../storagemanager/StorageManagerIF.h"
|
#include "../../storagemanager/StorageManagerIF.h"
|
||||||
#include "../../datapoolglob/GlobalDataPool.h"
|
#include "../../datapool/DataPool.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
|
|
||||||
/* Global instantiations normally done in main.cpp */
|
/* Global instantiations normally done in main.cpp */
|
||||||
/* Initialize Data Pool */
|
/* Initialize Data Pool */
|
||||||
namespace glob {
|
//namespace glob {
|
||||||
GlobalDataPool dataPool(datapool::dataPoolInit);
|
DataPool dataPool(datapool::dataPoolInit);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
namespace sif {
|
namespace sif {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define FRAMEWORK_TEST_UNITTESTCLASS_H_
|
#define FRAMEWORK_TEST_UNITTESTCLASS_H_
|
||||||
|
|
||||||
#include "UnittDefinitions.h"
|
#include "UnittDefinitions.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Can be used for internal testing, for example for hardware specific
|
* @brief Can be used for internal testing, for example for hardware specific
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <fsfw/unittest/internal/UnittDefinitions.h>
|
#include "UnittDefinitions.h"
|
||||||
|
|
||||||
ReturnValue_t unitt::put_error(std::string errorId) {
|
ReturnValue_t unitt::put_error(std::string errorId) {
|
||||||
sif::error << "Unit Tester error: Failed at test ID "
|
sif::error << "Unit Tester error: Failed at test ID "
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
#include "IntTestMq.h"
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
#include "../UnittDefinitions.h"
|
||||||
#include <fsfw/unittest/internal/osal/IntTestMq.h>
|
|
||||||
#include <fsfw/unittest/internal/UnittDefinitions.h>
|
#include "../../ipc/MessageQueueIF.h"
|
||||||
|
#include "../../ipc/QueueFactory.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include "IntTestMutex.h"
|
#include "IntTestMutex.h"
|
||||||
|
|
||||||
#include <fsfw/ipc/MutexFactory.h>
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include <unittest/internal/UnittDefinitions.h>
|
#include "../UnittDefinitions.h"
|
||||||
|
|
||||||
#if defined(hosted)
|
#if defined(hosted)
|
||||||
#include <fsfw/osal/hosted/Mutex.h>
|
#include "../../osal/hosted/Mutex.h"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <future>
|
#include <future>
|
||||||
#endif
|
#endif
|
||||||
@ -20,7 +20,7 @@ void testmutex::testMutex() {
|
|||||||
// timed_mutex from the C++ library specifies undefined behaviour if
|
// timed_mutex from the C++ library specifies undefined behaviour if
|
||||||
// the timed mutex is locked twice from the same thread.
|
// the timed mutex is locked twice from the same thread.
|
||||||
#if defined(hosted)
|
#if defined(hosted)
|
||||||
// hold on, this actually worked ? :-D This calls the function from
|
// This calls the function from
|
||||||
// another thread and stores the returnvalue in a future.
|
// another thread and stores the returnvalue in a future.
|
||||||
auto future = std::async(&MutexIF::lockMutex, mutex, 1);
|
auto future = std::async(&MutexIF::lockMutex, mutex, 1);
|
||||||
result = future.get();
|
result = future.get();
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include "IntTestSemaphore.h"
|
#include "IntTestSemaphore.h"
|
||||||
#include <fsfw/tasks/SemaphoreFactory.h>
|
#include "../UnittDefinitions.h"
|
||||||
#include <unittest/internal/UnittDefinitions.h>
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
#include "../../tasks/SemaphoreFactory.h"
|
||||||
#include <fsfw/timemanager/Stopwatch.h>
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
#include "../../timemanager/Stopwatch.h"
|
||||||
|
|
||||||
|
|
||||||
void testsemaph::testBinSemaph() {
|
void testsemaph::testBinSemaph() {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include "IntTestSerialization.h"
|
#include "IntTestSerialization.h"
|
||||||
#include <fsfw/serialize/SerializeElement.h>
|
#include "../UnittDefinitions.h"
|
||||||
#include <fsfw/serialize/SerialBufferAdapter.h>
|
#include "../../serialize/SerializeElement.h"
|
||||||
#include <unittest/internal/UnittDefinitions.h>
|
#include "../../serialize/SerialBufferAdapter.h"
|
||||||
#include <fsfw/serialize/SerializeIF.h>
|
#include "../../serialize/SerializeIF.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
using retval = HasReturnvaluesIF;
|
using retval = HasReturnvaluesIF;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_
|
#ifndef FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_
|
||||||
#define UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_
|
#define FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
|
||||||
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace testserialize {
|
namespace testserialize {
|
||||||
@ -12,4 +13,4 @@ ReturnValue_t test_serial_buffer_adapter();
|
|||||||
extern std::array<uint8_t, 512> test_array;
|
extern std::array<uint8_t, 512> test_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ */
|
#endif /* FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ */
|
||||||
|
60
unittest/testcfg/CatchFactory.cpp
Normal file
60
unittest/testcfg/CatchFactory.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#include "CatchFactory.h"
|
||||||
|
|
||||||
|
#include <fsfw/events/EventManager.h>
|
||||||
|
#include <fsfw/health/HealthTable.h>
|
||||||
|
|
||||||
|
#include <fsfw/internalError/InternalErrorReporter.h>
|
||||||
|
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||||
|
#include <fsfw/storagemanager/PoolManager.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Produces system objects.
|
||||||
|
* @details
|
||||||
|
* Build tasks by using SystemObject Interface (Interface).
|
||||||
|
* Header files of all tasks must be included
|
||||||
|
* Please note that an object has to implement the system object interface
|
||||||
|
* if the interface validity is checked or retrieved later by using the
|
||||||
|
* get<TargetInterface>(object_id) function from the ObjectManagerIF.
|
||||||
|
*
|
||||||
|
* Framework objects are created first.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
void Factory::produce(void) {
|
||||||
|
setStaticFrameworkObjectIds();
|
||||||
|
new EventManager(objects::EVENT_MANAGER);
|
||||||
|
new HealthTable(objects::HEALTH_TABLE);
|
||||||
|
//new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
|
||||||
|
|
||||||
|
{
|
||||||
|
static constexpr uint8_t NUMBER_OF_POOLS = 5;
|
||||||
|
const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024};
|
||||||
|
const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5};
|
||||||
|
new PoolManager<NUMBER_OF_POOLS>(objects::TC_STORE, element_sizes,
|
||||||
|
n_elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static constexpr uint8_t NUMBER_OF_POOLS = 5;
|
||||||
|
const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024};
|
||||||
|
const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5};
|
||||||
|
new PoolManager<NUMBER_OF_POOLS>(objects::TM_STORE, element_sizes,
|
||||||
|
n_elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static constexpr uint8_t NUMBER_OF_POOLS = 6;
|
||||||
|
const uint16_t element_sizes[NUMBER_OF_POOLS] = {32, 64, 512,
|
||||||
|
1024, 2048, 4096};
|
||||||
|
const uint16_t n_elements[NUMBER_OF_POOLS] = {200, 100, 50, 25, 15, 5};
|
||||||
|
new PoolManager<NUMBER_OF_POOLS>(objects::IPC_STORE, element_sizes,
|
||||||
|
n_elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Factory::setStaticFrameworkObjectIds() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
16
unittest/testcfg/CatchFactory.h
Normal file
16
unittest/testcfg/CatchFactory.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef FACTORY_H_
|
||||||
|
#define FACTORY_H_
|
||||||
|
|
||||||
|
#include <fsfw/objectmanager/SystemObjectIF.h>
|
||||||
|
|
||||||
|
namespace Factory {
|
||||||
|
/**
|
||||||
|
* @brief Creates all SystemObject elements which are persistent
|
||||||
|
* during execution.
|
||||||
|
*/
|
||||||
|
void produce();
|
||||||
|
void setStaticFrameworkObjectIds();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FACTORY_H_ */
|
@ -12,7 +12,7 @@
|
|||||||
#define FSFW_REDUCED_PRINTOUT 0
|
#define FSFW_REDUCED_PRINTOUT 0
|
||||||
|
|
||||||
//! Can be used to enable debugging printouts for developing the FSFW
|
//! Can be used to enable debugging printouts for developing the FSFW
|
||||||
#define FSFW_VERBOSE_PRINTOUT 0
|
#define FSFW_DEBUGGING 0
|
||||||
|
|
||||||
//! Defines the FIFO depth of each commanding service base which
|
//! Defines the FIFO depth of each commanding service base which
|
||||||
//! also determines how many commands a CSB service can handle in one cycle
|
//! also determines how many commands a CSB service can handle in one cycle
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
|
#ifndef HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
|
||||||
#define HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
|
#define HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
|
||||||
|
|
||||||
#include <fsfw/datapoolglob/GlobalDataPool.h>
|
#include <fsfw/datapool/DataPool.h>
|
||||||
#include <fsfw/datapool/PoolEntryIF.h>
|
#include <fsfw/datapool/PoolEntryIF.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -3,6 +3,7 @@ CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp)
|
|||||||
CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp)
|
CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp)
|
||||||
CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp)
|
CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp)
|
||||||
CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp)
|
CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp)
|
||||||
|
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)
|
||||||
|
|
||||||
INCLUDES += $(CURRENTPATH)
|
INCLUDES += $(CURRENTPATH)
|
||||||
INCLUDES += $(CURRENTPATH)/objects
|
INCLUDES += $(CURRENTPATH)/objects
|
||||||
|
@ -1,106 +1,107 @@
|
|||||||
//#include "TestActionHelper.h"
|
#include "TestActionHelper.h"
|
||||||
//#include <fsfw/action/ActionHelper.h>
|
#include <fsfw/action/ActionHelper.h>
|
||||||
//#include <fsfw/ipc/CommandMessage.h>
|
#include <fsfw/ipc/CommandMessage.h>
|
||||||
//#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
//#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
//
|
|
||||||
//
|
|
||||||
//TEST_CASE( "Action Helper" , "[ActionHelper]") {
|
TEST_CASE( "Action Helper" , "[ActionHelper]") {
|
||||||
// ActionHelperOwnerMockBase testDhMock;
|
ActionHelperOwnerMockBase testDhMock;
|
||||||
// MessageQueueMockBase testMqMock;
|
MessageQueueMockBase testMqMock;
|
||||||
// ActionHelper actionHelper = ActionHelper(
|
ActionHelper actionHelper = ActionHelper(
|
||||||
// &testDhMock, dynamic_cast<MessageQueueIF*>(&testMqMock));
|
&testDhMock, dynamic_cast<MessageQueueIF*>(&testMqMock));
|
||||||
// CommandMessage actionMessage;
|
CommandMessage actionMessage;
|
||||||
// ActionId_t testActionId = 777;
|
ActionId_t testActionId = 777;
|
||||||
// std::array <uint8_t, 3> testParams {1, 2, 3};
|
std::array <uint8_t, 3> testParams {1, 2, 3};
|
||||||
// store_address_t paramAddress;
|
store_address_t paramAddress;
|
||||||
// StorageManagerIF *ipcStore = tglob::getIpcStoreHandle();
|
StorageManagerIF *ipcStore = tglob::getIpcStoreHandle();
|
||||||
// ipcStore->addData(¶mAddress, testParams.data(), 3);
|
REQUIRE(ipcStore != nullptr);
|
||||||
// REQUIRE(actionHelper.initialize() == retval::CATCH_OK);
|
ipcStore->addData(¶mAddress, testParams.data(), 3);
|
||||||
//
|
REQUIRE(actionHelper.initialize() == retval::CATCH_OK);
|
||||||
// SECTION ("Simple tests") {
|
|
||||||
// ActionMessage::setCommand(&actionMessage, testActionId, paramAddress);
|
SECTION ("Simple tests") {
|
||||||
// CHECK(not testDhMock.executeActionCalled);
|
ActionMessage::setCommand(&actionMessage, testActionId, paramAddress);
|
||||||
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
|
CHECK(not testDhMock.executeActionCalled);
|
||||||
// CHECK(testDhMock.executeActionCalled);
|
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
|
||||||
// // No message is sent if everything is alright.
|
CHECK(testDhMock.executeActionCalled);
|
||||||
// CHECK(not testMqMock.wasMessageSent());
|
// No message is sent if everything is alright.
|
||||||
// store_address_t invalidAddress;
|
CHECK(not testMqMock.wasMessageSent());
|
||||||
// ActionMessage::setCommand(&actionMessage, testActionId, invalidAddress);
|
store_address_t invalidAddress;
|
||||||
// actionHelper.handleActionMessage(&actionMessage);
|
ActionMessage::setCommand(&actionMessage, testActionId, invalidAddress);
|
||||||
// CHECK(testMqMock.wasMessageSent());
|
actionHelper.handleActionMessage(&actionMessage);
|
||||||
// const uint8_t* ptr = nullptr;
|
CHECK(testMqMock.wasMessageSent());
|
||||||
// size_t size = 0;
|
const uint8_t* ptr = nullptr;
|
||||||
// REQUIRE(ipcStore->getData(paramAddress, &ptr, &size) == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
|
size_t size = 0;
|
||||||
// REQUIRE(ptr == nullptr);
|
REQUIRE(ipcStore->getData(paramAddress, &ptr, &size) == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
|
||||||
// REQUIRE(size == 0);
|
REQUIRE(ptr == nullptr);
|
||||||
// testDhMock.getBuffer(&ptr, &size);
|
REQUIRE(size == 0);
|
||||||
// REQUIRE(size == 3);
|
testDhMock.getBuffer(&ptr, &size);
|
||||||
// for(uint8_t i = 0; i<3;i++){
|
REQUIRE(size == 3);
|
||||||
// REQUIRE(ptr[i] == (i+1));
|
for(uint8_t i = 0; i<3;i++){
|
||||||
// }
|
REQUIRE(ptr[i] == (i+1));
|
||||||
// testDhMock.clearBuffer();
|
}
|
||||||
// }
|
testDhMock.clearBuffer();
|
||||||
//
|
}
|
||||||
// SECTION("Handle failures"){
|
|
||||||
// actionMessage.setCommand(1234);
|
SECTION("Handle failures"){
|
||||||
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == static_cast<uint32_t>(CommandMessage::UNKNOWN_COMMAND));
|
actionMessage.setCommand(1234);
|
||||||
// CHECK(not testMqMock.wasMessageSent());
|
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == static_cast<uint32_t>(CommandMessage::UNKNOWN_COMMAND));
|
||||||
// uint16_t step = 5;
|
CHECK(not testMqMock.wasMessageSent());
|
||||||
// ReturnValue_t status = 0x1234;
|
uint16_t step = 5;
|
||||||
// actionHelper.step(step, testMqMock.getId(), testActionId, status);
|
ReturnValue_t status = 0x1234;
|
||||||
// step += 1;
|
actionHelper.step(step, testMqMock.getId(), testActionId, status);
|
||||||
// CHECK(testMqMock.wasMessageSent());
|
step += 1;
|
||||||
// CommandMessage testMessage;
|
CHECK(testMqMock.wasMessageSent());
|
||||||
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
CommandMessage testMessage;
|
||||||
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
|
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
||||||
// REQUIRE(testMessage.getParameter() == static_cast<uint32_t>(testActionId));
|
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
|
||||||
// uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status;
|
REQUIRE(testMessage.getParameter() == static_cast<uint32_t>(testActionId));
|
||||||
// REQUIRE(testMessage.getParameter2() == parameter2);
|
uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status;
|
||||||
// REQUIRE(ActionMessage::getStep(&testMessage) == step);
|
REQUIRE(testMessage.getParameter2() == parameter2);
|
||||||
// }
|
REQUIRE(ActionMessage::getStep(&testMessage) == step);
|
||||||
//
|
}
|
||||||
// SECTION("Handle finish"){
|
|
||||||
// CHECK(not testMqMock.wasMessageSent());
|
SECTION("Handle finish"){
|
||||||
// ReturnValue_t status = 0x9876;
|
CHECK(not testMqMock.wasMessageSent());
|
||||||
// actionHelper.finish(testMqMock.getId(), testActionId, status);
|
ReturnValue_t status = 0x9876;
|
||||||
// CHECK(testMqMock.wasMessageSent());
|
actionHelper.finish(testMqMock.getId(), testActionId, status);
|
||||||
// CommandMessage testMessage;
|
CHECK(testMqMock.wasMessageSent());
|
||||||
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
CommandMessage testMessage;
|
||||||
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::COMPLETION_FAILED));
|
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
||||||
// REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
|
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::COMPLETION_FAILED));
|
||||||
// REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(status));
|
REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
|
||||||
// }
|
REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(status));
|
||||||
//
|
}
|
||||||
// SECTION("Handle failed"){
|
|
||||||
// store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS;
|
SECTION("Handle failed"){
|
||||||
// std::array<uint8_t, 5> toLongData = {5, 4, 3, 2, 1};
|
store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS;
|
||||||
// REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == retval::CATCH_OK);
|
std::array<uint8_t, 5> toLongData = {5, 4, 3, 2, 1};
|
||||||
// ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress);
|
REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == retval::CATCH_OK);
|
||||||
// CHECK(not testDhMock.executeActionCalled);
|
ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress);
|
||||||
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
|
CHECK(not testDhMock.executeActionCalled);
|
||||||
// REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
|
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
|
||||||
// CommandMessage testMessage;
|
REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
|
||||||
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
CommandMessage testMessage;
|
||||||
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
|
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
||||||
// REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE);
|
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
|
||||||
// REQUIRE(ActionMessage::getStep(&testMessage) == 0);
|
REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE);
|
||||||
// REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
|
REQUIRE(ActionMessage::getStep(&testMessage) == 0);
|
||||||
// }
|
REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
|
||||||
//
|
}
|
||||||
// SECTION("Missing IPC Data"){
|
|
||||||
// ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS);
|
SECTION("Missing IPC Data"){
|
||||||
// CHECK(not testDhMock.executeActionCalled);
|
ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS);
|
||||||
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
|
CHECK(not testDhMock.executeActionCalled);
|
||||||
// CommandMessage testMessage;
|
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
|
||||||
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
CommandMessage testMessage;
|
||||||
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
|
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
|
||||||
// REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(StorageManagerIF::ILLEGAL_STORAGE_ID));
|
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
|
||||||
// REQUIRE(ActionMessage::getStep(&testMessage) == 0);
|
REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(StorageManagerIF::ILLEGAL_STORAGE_ID));
|
||||||
// }
|
REQUIRE(ActionMessage::getStep(&testMessage) == 0);
|
||||||
//
|
}
|
||||||
//
|
|
||||||
// SECTION("Data Reply"){
|
|
||||||
//
|
SECTION("Data Reply"){
|
||||||
// }
|
|
||||||
//}
|
}
|
||||||
|
}
|
||||||
|
@ -1,131 +1,132 @@
|
|||||||
//#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
||||||
//#define UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
#define UNITTEST_HOSTED_TESTACTIONHELPER_H_
|
||||||
//
|
|
||||||
//#include <fsfw/action/HasActionsIF.h>
|
#include <fsfw/action/HasActionsIF.h>
|
||||||
//#include <fsfw/ipc/MessageQueueIF.h>
|
#include <fsfw/ipc/MessageQueueIF.h>
|
||||||
//#include <fsfw/unittest/core/CatchDefinitions.h>
|
#include <fsfw/unittest/core/CatchDefinitions.h>
|
||||||
//#include <cstring>
|
#include <cstring>
|
||||||
//
|
|
||||||
//
|
|
||||||
//class ActionHelperOwnerMockBase: public HasActionsIF {
|
class ActionHelperOwnerMockBase: public HasActionsIF {
|
||||||
//public:
|
public:
|
||||||
// bool getCommandQueueCalled = false;
|
bool getCommandQueueCalled = false;
|
||||||
// bool executeActionCalled = false;
|
bool executeActionCalled = false;
|
||||||
// static const size_t MAX_SIZE = 3;
|
static const size_t MAX_SIZE = 3;
|
||||||
// uint8_t buffer[MAX_SIZE] = {0, 0, 0};
|
uint8_t buffer[MAX_SIZE] = {0, 0, 0};
|
||||||
// size_t size = 0;
|
size_t size = 0;
|
||||||
//
|
|
||||||
// MessageQueueId_t getCommandQueue() const override {
|
MessageQueueId_t getCommandQueue() const override {
|
||||||
// return tconst::testQueueId;
|
return tconst::testQueueId;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||||
// const uint8_t* data, size_t size) override {
|
const uint8_t* data, size_t size) override {
|
||||||
// executeActionCalled = true;
|
executeActionCalled = true;
|
||||||
// if(size > MAX_SIZE){
|
if(size > MAX_SIZE){
|
||||||
// return 0xAFFE;
|
return 0xAFFE;
|
||||||
// }
|
}
|
||||||
// this->size = size;
|
this->size = size;
|
||||||
// memcpy(buffer, data, size);
|
memcpy(buffer, data, size);
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// void clearBuffer(){
|
void clearBuffer(){
|
||||||
// this->size = 0;
|
this->size = 0;
|
||||||
// for(size_t i = 0; i<MAX_SIZE; i++){
|
for(size_t i = 0; i<MAX_SIZE; i++){
|
||||||
// buffer[i] = 0;
|
buffer[i] = 0;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// void getBuffer(const uint8_t** ptr, size_t* size){
|
void getBuffer(const uint8_t** ptr, size_t* size){
|
||||||
// if(size != nullptr){
|
if(size != nullptr){
|
||||||
// *size = this->size;
|
*size = this->size;
|
||||||
// }
|
}
|
||||||
// if(ptr != nullptr){
|
if(ptr != nullptr){
|
||||||
// *ptr = buffer;
|
*ptr = buffer;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//};
|
};
|
||||||
//
|
|
||||||
//
|
|
||||||
//class MessageQueueMockBase: public MessageQueueIF {
|
class MessageQueueMockBase: public MessageQueueIF {
|
||||||
//public:
|
public:
|
||||||
// MessageQueueId_t myQueueId = 0;
|
MessageQueueId_t myQueueId = 0;
|
||||||
// bool defaultDestSet = false;
|
bool defaultDestSet = false;
|
||||||
// bool messageSent = false;
|
bool messageSent = false;
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// bool wasMessageSent() {
|
bool wasMessageSent() {
|
||||||
// bool tempMessageSent = messageSent;
|
bool tempMessageSent = messageSent;
|
||||||
// messageSent = false;
|
messageSent = false;
|
||||||
// return tempMessageSent;
|
return tempMessageSent;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// virtual ReturnValue_t reply( MessageQueueMessage* message ) {
|
virtual ReturnValue_t reply( MessageQueueMessageIF* message ) {
|
||||||
// messageSent = true;
|
messageSent = true;
|
||||||
// lastMessage = (*message);
|
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// };
|
};
|
||||||
// virtual ReturnValue_t receiveMessage(MessageQueueMessage* message,
|
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
|
||||||
// MessageQueueId_t *receivedFrom) {
|
MessageQueueId_t *receivedFrom) {
|
||||||
// (*message) = lastMessage;
|
(*message) = lastMessage;
|
||||||
// lastMessage.clear();
|
lastMessage.clear();
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// }
|
}
|
||||||
// virtual ReturnValue_t receiveMessage(MessageQueueMessage* message) {
|
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) {
|
||||||
// (*message) = lastMessage;
|
memcpy(message->getBuffer(), lastMessage.getBuffer(),
|
||||||
// lastMessage.clear();
|
message->getMessageSize());
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
lastMessage.clear();
|
||||||
// }
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// virtual ReturnValue_t flush(uint32_t* count) {
|
}
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
virtual ReturnValue_t flush(uint32_t* count) {
|
||||||
// }
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// virtual MessageQueueId_t getLastPartner() const {
|
}
|
||||||
// return tconst::testQueueId;
|
virtual MessageQueueId_t getLastPartner() const {
|
||||||
// }
|
return tconst::testQueueId;
|
||||||
// virtual MessageQueueId_t getId() const {
|
}
|
||||||
// return tconst::testQueueId;
|
virtual MessageQueueId_t getId() const {
|
||||||
// }
|
return tconst::testQueueId;
|
||||||
// virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
|
}
|
||||||
// MessageQueueMessage* message, MessageQueueId_t sentFrom,
|
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
|
||||||
// bool ignoreFault = false ) {
|
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||||
// messageSent = true;
|
bool ignoreFault = false ) {
|
||||||
// lastMessage = (*message);
|
messageSent = true;
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||||
// }
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
|
}
|
||||||
// MessageQueueMessage* message, bool ignoreFault = false ) override {
|
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
|
||||||
// messageSent = true;
|
MessageQueueMessageIF* message, bool ignoreFault = false ) override {
|
||||||
// lastMessage = (*message);
|
messageSent = true;
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||||
// }
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message,
|
}
|
||||||
// MessageQueueId_t sentFrom, bool ignoreFault = false ) {
|
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message,
|
||||||
// messageSent = true;
|
MessageQueueId_t sentFrom, bool ignoreFault = false ) {
|
||||||
// lastMessage = (*message);
|
messageSent = true;
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||||
// }
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) {
|
}
|
||||||
// messageSent = true;
|
virtual ReturnValue_t sendToDefault( MessageQueueMessageIF* message ) {
|
||||||
// lastMessage = (*message);
|
messageSent = true;
|
||||||
// return HasReturnvaluesIF::RETURN_OK;
|
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||||
// }
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
// virtual void setDefaultDestination(MessageQueueId_t defaultDestination) {
|
}
|
||||||
// myQueueId = defaultDestination;
|
virtual void setDefaultDestination(MessageQueueId_t defaultDestination) {
|
||||||
// defaultDestSet = true;
|
myQueueId = defaultDestination;
|
||||||
// }
|
defaultDestSet = true;
|
||||||
//
|
}
|
||||||
// virtual MessageQueueId_t getDefaultDestination() const {
|
|
||||||
// return myQueueId;
|
virtual MessageQueueId_t getDefaultDestination() const {
|
||||||
// }
|
return myQueueId;
|
||||||
// virtual bool isDefaultDestinationSet() const {
|
}
|
||||||
// return defaultDestSet;
|
virtual bool isDefaultDestinationSet() const {
|
||||||
// }
|
return defaultDestSet;
|
||||||
//private:
|
}
|
||||||
// MessageQueueMessage lastMessage;
|
private:
|
||||||
//
|
MessageQueueMessage lastMessage;
|
||||||
//};
|
|
||||||
//
|
};
|
||||||
//
|
|
||||||
//#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */
|
|
||||||
|
#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <fsfw/container/SimpleRingBuffer.h>
|
|
||||||
#include <catch2/catch.hpp>
|
|
||||||
#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
#include "../../container/SimpleRingBuffer.h"
|
||||||
|
|
||||||
|
#include <catch2/catch.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
TEST_CASE("Ring Buffer Test" , "[RingBufferTest]") {
|
TEST_CASE("Ring Buffer Test" , "[RingBufferTest]") {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <fsfw/container/ArrayList.h>
|
#include "../../container/ArrayList.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include <fsfw/container/DynamicFIFO.h>
|
#include "../../container/DynamicFIFO.h"
|
||||||
#include <fsfw/container/FIFO.h>
|
#include "../../container/FIFO.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
#include <catch.hpp>
|
#include <catch.hpp>
|
||||||
#include <CatchDefinitions.h>
|
#include <CatchDefinitions.h>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include <fsfw/container/DynamicFIFO.h>
|
#include "../../container/DynamicFIFO.h"
|
||||||
#include <fsfw/container/FIFO.h>
|
#include "../../container/FIFO.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/container/FixedArrayList.h>
|
#include "../../container/FixedArrayList.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <fsfw/container/FixedMap.h>
|
#include "../../container/FixedMap.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <fsfw/container/FixedOrderedMultimap.h>
|
#include "../../container/FixedOrderedMultimap.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
#include "../../ipc/MessageQueueIF.h"
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
#include "../../ipc/QueueFactory.h"
|
||||||
#include "catch.hpp"
|
#include <catch.hpp>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
|
||||||
TEST_CASE("MessageQueue Basic Test","[TestMq]") {
|
TEST_CASE("MessageQueue Basic Test","[TestMq]") {
|
||||||
MessageQueueIF* testSenderMq =
|
MessageQueueIF* testSenderMq =
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <fsfw/serialize/SerialBufferAdapter.h>
|
#include "../../serialize/SerialBufferAdapter.h"
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#include "../../core/CatchDefinitions.h"
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
#include "TestSerialLinkedPacket.h"
|
||||||
|
#include "../../core/CatchDefinitions.h"
|
||||||
|
|
||||||
|
#include "../../globalfunctions/arrayprinter.h"
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#include "../../core/CatchDefinitions.h"
|
|
||||||
#include "TestSerialLinkedPacket.h"
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Serial Linked Packet" , "[SerLinkPacket]") {
|
TEST_CASE("Serial Linked Packet" , "[SerLinkPacket]") {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <fsfw/serialize/SerializeAdapter.h>
|
#include "../../serialize/SerializeAdapter.h"
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
Loading…
Reference in New Issue
Block a user