include fixes

This commit is contained in:
Robin Müller 2020-10-28 22:34:41 +01:00
parent 6325eb7647
commit b860d8bce7
16 changed files with 465 additions and 466 deletions

View File

@ -1,4 +1,4 @@
#include <fsfw/unittest/config/cdatapool/dataPoolInit.h> #include "dataPoolInit.h"
void datapool::dataPoolInit(std::map<uint32_t, PoolEntryIF*> * poolMap) { void datapool::dataPoolInit(std::map<uint32_t, PoolEntryIF*> * poolMap) {
uint8_t UINT8T_INIT[1] = {0}; uint8_t UINT8T_INIT[1] = {0};

View File

@ -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/datapool/DataPool.h> #include <fsfw/datapoolglob/GlobalDataPool.h>
#include <fsfw/datapool/PoolEntryIF.h> #include <fsfw/datapool/PoolEntryIF.h>
#include <map> #include <map>
#include <cstdint> #include <cstdint>

View File

@ -23,10 +23,7 @@ void Factory::produce(void) {
setStaticFrameworkObjectIds(); setStaticFrameworkObjectIds();
new EventManager(objects::EVENT_MANAGER); new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE); new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER, new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
datapool::INTERNAL_ERROR_FULL_MSG_QUEUES,
datapool::INTERNAL_ERROR_MISSED_LIVE_TM,
datapool::INTERNAL_ERROR_STORE_FULL);
} }

View File

@ -1,105 +1,106 @@
#include <fsfw/action/ActionHelper.h> //#include "TestActionHelper.h"
#include <fsfw/ipc/CommandMessage.h> //#include <fsfw/action/ActionHelper.h>
#include <fsfw/unittest/catch2/catch.hpp> //#include <fsfw/ipc/CommandMessage.h>
#include <fsfw/unittest/core/CatchDefinitions.h> //#include <catch2/catch.hpp>
#include <fsfw/unittest/tests/action/TestActionHelper.h> //#include "../../core/CatchDefinitions.h"
//
TEST_CASE( "Action Helper" , "[ActionHelper]") { //
ActionHelperOwnerMockBase testDhMock; //TEST_CASE( "Action Helper" , "[ActionHelper]") {
MessageQueueMockBase testMqMock; // ActionHelperOwnerMockBase testDhMock;
ActionHelper actionHelper = ActionHelper( // MessageQueueMockBase testMqMock;
&testDhMock, dynamic_cast<MessageQueueIF*>(&testMqMock)); // ActionHelper actionHelper = ActionHelper(
CommandMessage actionMessage; // &testDhMock, dynamic_cast<MessageQueueIF*>(&testMqMock));
ActionId_t testActionId = 777; // CommandMessage actionMessage;
std::array <uint8_t, 3> testParams {1, 2, 3}; // ActionId_t testActionId = 777;
store_address_t paramAddress; // std::array <uint8_t, 3> testParams {1, 2, 3};
StorageManagerIF *ipcStore = tglob::getIpcStoreHandle(); // store_address_t paramAddress;
ipcStore->addData(&paramAddress, testParams.data(), 3); // StorageManagerIF *ipcStore = tglob::getIpcStoreHandle();
REQUIRE(actionHelper.initialize() == retval::CATCH_OK); // ipcStore->addData(&paramAddress, 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"){
} //
} // }
//}

View File

@ -1,131 +1,131 @@
#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( MessageQueueMessage* message ) {
messageSent = true; // messageSent = true;
lastMessage = (*message); // lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK; // return HasReturnvaluesIF::RETURN_OK;
}; // };
virtual ReturnValue_t receiveMessage(MessageQueueMessage* message, // virtual ReturnValue_t receiveMessage(MessageQueueMessage* 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(MessageQueueMessage* message) {
(*message) = lastMessage; // (*message) = lastMessage;
lastMessage.clear(); // lastMessage.clear();
return HasReturnvaluesIF::RETURN_OK; // return HasReturnvaluesIF::RETURN_OK;
} // }
virtual ReturnValue_t flush(uint32_t* count) { // virtual ReturnValue_t flush(uint32_t* count) {
return HasReturnvaluesIF::RETURN_OK; // return HasReturnvaluesIF::RETURN_OK;
} // }
virtual MessageQueueId_t getLastPartner() const { // virtual MessageQueueId_t getLastPartner() const {
return tconst::testQueueId; // return tconst::testQueueId;
} // }
virtual MessageQueueId_t getId() const { // virtual MessageQueueId_t getId() const {
return tconst::testQueueId; // return tconst::testQueueId;
} // }
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo, // virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
MessageQueueMessage* message, MessageQueueId_t sentFrom, // MessageQueueMessage* message, MessageQueueId_t sentFrom,
bool ignoreFault = false ) { // bool ignoreFault = false ) {
messageSent = true; // messageSent = true;
lastMessage = (*message); // lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK; // return HasReturnvaluesIF::RETURN_OK;
} // }
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo, // virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
MessageQueueMessage* message, bool ignoreFault = false ) override { // MessageQueueMessage* message, bool ignoreFault = false ) override {
messageSent = true; // messageSent = true;
lastMessage = (*message); // lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK; // return HasReturnvaluesIF::RETURN_OK;
} // }
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message, // virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message,
MessageQueueId_t sentFrom, bool ignoreFault = false ) { // MessageQueueId_t sentFrom, bool ignoreFault = false ) {
messageSent = true; // messageSent = true;
lastMessage = (*message); // lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK; // return HasReturnvaluesIF::RETURN_OK;
} // }
virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) { // virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) {
messageSent = true; // messageSent = true;
lastMessage = (*message); // lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK; // return HasReturnvaluesIF::RETURN_OK;
} // }
virtual void setDefaultDestination(MessageQueueId_t defaultDestination) { // virtual void setDefaultDestination(MessageQueueId_t defaultDestination) {
myQueueId = defaultDestination; // myQueueId = defaultDestination;
defaultDestSet = true; // defaultDestSet = true;
} // }
//
virtual MessageQueueId_t getDefaultDestination() const { // virtual MessageQueueId_t getDefaultDestination() const {
return myQueueId; // return myQueueId;
} // }
virtual bool isDefaultDestinationSet() const { // virtual bool isDefaultDestinationSet() const {
return defaultDestSet; // return defaultDestSet;
} // }
private: //private:
MessageQueueMessage lastMessage; // MessageQueueMessage lastMessage;
//
}; //};
//
//
#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */ //#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */

View File

@ -1,6 +1,6 @@
#include <fsfw/container/SimpleRingBuffer.h> #include <fsfw/container/SimpleRingBuffer.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> #include "../../core/CatchDefinitions.h"
#include <cstring> #include <cstring>

View File

@ -1,7 +1,7 @@
#include <fsfw/container/ArrayList.h> #include <fsfw/container/ArrayList.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> #include "../../core/CatchDefinitions.h"
/** /**
* @brief Array List test * @brief Array List test

View File

@ -3,8 +3,8 @@
#include <fsfw/container/FIFO.h> #include <fsfw/container/FIFO.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> #include "../../core/CatchDefinitions.h"
TEST_CASE( "Static Fifo Tests", "[TestFifo]") { TEST_CASE( "Static Fifo Tests", "[TestFifo]") {
INFO("Fifo Tests"); INFO("Fifo Tests");

View File

@ -1,8 +1,9 @@
#include "../../core/CatchDefinitions.h"
#include <fsfw/container/FixedArrayList.h> #include <fsfw/container/FixedArrayList.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
TEST_CASE( "FixedArrayList Tests", "[TestFixedArrayList]") { TEST_CASE( "FixedArrayList Tests", "[TestFixedArrayList]") {

View File

@ -1,8 +1,8 @@
#include <fsfw/container/FixedMap.h> #include <fsfw/container/FixedMap.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> #include "../../core/CatchDefinitions.h"
template class FixedMap<unsigned int, unsigned short>; template class FixedMap<unsigned int, unsigned short>;

View File

@ -1,8 +1,8 @@
#include <fsfw/container/FixedOrderedMultimap.h> #include <fsfw/container/FixedOrderedMultimap.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> #include "../../core/CatchDefinitions.h"
TEST_CASE( "FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { TEST_CASE( "FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") {
INFO("FixedOrderedMultimap Tests"); INFO("FixedOrderedMultimap Tests");

View File

@ -1,45 +1,45 @@
#include <fsfw/container/PlacementFactory.h> //#include <fsfw/container/PlacementFactory.h>
#include <fsfw/storagemanager/LocalPool.h> //#include <fsfw/storagemanager/LocalPool.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> //#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/container/ArrayList.h> //#include <fsfw/container/ArrayList.h>
//
#include <fsfw/unittest/catch2/catch.hpp> //#include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> //#include "../../core/CatchDefinitions.h"
//
TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") { //TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") {
INFO("PlacementFactory Tests"); // INFO("PlacementFactory Tests");
//
const uint16_t element_sizes[3] = {sizeof(uint16_t), sizeof(uint32_t), sizeof(uint64_t)}; // const uint16_t element_sizes[3] = {sizeof(uint16_t), sizeof(uint32_t), sizeof(uint64_t)};
const uint16_t n_elements[3] = {1, 1, 1}; // const uint16_t n_elements[3] = {1, 1, 1};
LocalPool<3> storagePool(0x1, element_sizes, n_elements, false, true); // LocalPool<3> storagePool(0x1, element_sizes, n_elements, false, true);
PlacementFactory factory(&storagePool); // PlacementFactory factory(&storagePool);
//
SECTION("Pool overload"){ // SECTION("Pool overload"){
store_address_t address; // store_address_t address;
uint8_t* ptr = nullptr; // uint8_t* ptr = nullptr;
REQUIRE(storagePool.getFreeElement(&address, sizeof(ArrayList<uint32_t, uint16_t>), &ptr) // REQUIRE(storagePool.getFreeElement(&address, sizeof(ArrayList<uint32_t, uint16_t>), &ptr)
== static_cast<int>(StorageManagerIF::DATA_TOO_LARGE)); // == static_cast<int>(StorageManagerIF::DATA_TOO_LARGE));
ArrayList<uint32_t, uint16_t>* list2 = factory.generate<ArrayList<uint32_t, uint16_t> >(80); // ArrayList<uint32_t, uint16_t>* list2 = factory.generate<ArrayList<uint32_t, uint16_t> >(80);
REQUIRE(list2 == nullptr); // REQUIRE(list2 == nullptr);
} // }
//
SECTION("Test generate and destroy"){ // SECTION("Test generate and destroy"){
uint64_t* number = factory.generate<uint64_t>(32000); // uint64_t* number = factory.generate<uint64_t>(32000);
REQUIRE(number != nullptr); // REQUIRE(number != nullptr);
REQUIRE(*number == 32000); // REQUIRE(*number == 32000);
store_address_t address; // store_address_t address;
uint8_t* ptr = nullptr; // uint8_t* ptr = nullptr;
REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) // REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr)
== static_cast<int>(StorageManagerIF::DATA_TOO_LARGE)); // == static_cast<int>(StorageManagerIF::DATA_TOO_LARGE));
uint64_t* number2 = factory.generate<uint64_t>(12345); // uint64_t* number2 = factory.generate<uint64_t>(12345);
REQUIRE(number2 == nullptr); // REQUIRE(number2 == nullptr);
REQUIRE(factory.destroy(number) == static_cast<int>(HasReturnvaluesIF::RETURN_OK)); // REQUIRE(factory.destroy(number) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) // REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr)
== static_cast<int>(HasReturnvaluesIF::RETURN_OK)); // == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(storagePool.deleteData(address) == static_cast<int>(HasReturnvaluesIF::RETURN_OK)); // REQUIRE(storagePool.deleteData(address) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
//
//Check that PlacementFactory checks for nullptr // //Check that PlacementFactory checks for nullptr
ptr = nullptr; // ptr = nullptr;
REQUIRE(factory.destroy(ptr) == static_cast<int>(HasReturnvaluesIF::RETURN_FAILED)); // REQUIRE(factory.destroy(ptr) == static_cast<int>(HasReturnvaluesIF::RETURN_FAILED));
} // }
} //}

View File

@ -1,7 +1,7 @@
#include <fsfw/serialize/SerialBufferAdapter.h> #include <fsfw/serialize/SerialBufferAdapter.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> #include "../../core/CatchDefinitions.h"
static bool test_value_bool = true; static bool test_value_bool = true;

View File

@ -1,8 +1,8 @@
#include <fsfw/globalfunctions/arrayprinter.h> #include <fsfw/globalfunctions/arrayprinter.h>
#include <fsfw/unittest/catch2/catch.hpp> #include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> #include "../../core/CatchDefinitions.h"
#include <fsfw/unittest/tests/serialize/TestSerialLinkedPacket.h> #include "TestSerialLinkedPacket.h"
TEST_CASE("Serial Linked Packet" , "[SerLinkPacket]") { TEST_CASE("Serial Linked Packet" , "[SerLinkPacket]") {

View File

@ -2,7 +2,7 @@
#include "catch.hpp" #include "catch.hpp"
#include <array> #include <array>
#include "core/CatchDefinitions.h" #include "../../core/CatchDefinitions.h"
static bool test_value_bool = true; static bool test_value_bool = true;
static uint8_t tv_uint8 {5}; static uint8_t tv_uint8 {5};

View File

@ -1,161 +1,161 @@
#include <fsfw/storagemanager/LocalPool.h> //#include <fsfw/storagemanager/LocalPool.h>
#include <fsfw/unittest/catch2/catch.hpp> //#include <catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h> //#include "../../core/CatchDefinitions.h"
#include <array> //#include <array>
//
TEST_CASE( "New Accessor" , "[NewAccessor]") { //TEST_CASE( "New Accessor" , "[NewAccessor]") {
uint16_t numberOfElements[1] = {1}; // uint16_t numberOfElements[1] = {1};
uint16_t sizeofElements[1] = {10}; // uint16_t sizeofElements[1] = {10};
LocalPool<1> SimplePool = LocalPool<1>(0, sizeofElements, numberOfElements); // LocalPool<1> SimplePool = LocalPool<1>(0, sizeofElements, numberOfElements);
std::array<uint8_t, 20> testDataArray; // std::array<uint8_t, 20> testDataArray;
std::array<uint8_t, 20> receptionArray; // std::array<uint8_t, 20> receptionArray;
store_address_t testStoreId; // store_address_t testStoreId;
ReturnValue_t result = retval::CATCH_FAILED; // ReturnValue_t result = retval::CATCH_FAILED;
//
for(size_t i = 0; i < testDataArray.size(); i++) { // for(size_t i = 0; i < testDataArray.size(); i++) {
testDataArray[i] = i; // testDataArray[i] = i;
} // }
size_t size = 10; // size_t size = 10;
//
SECTION ("Simple tests getter functions") { // SECTION ("Simple tests getter functions") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size); // result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
auto resultPair = SimplePool.getData(testStoreId); // auto resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK); // REQUIRE(resultPair.first == retval::CATCH_OK);
resultPair.second.getDataCopy(receptionArray.data(), 20); // resultPair.second.getDataCopy(receptionArray.data(), 20);
CHECK(resultPair.second.getId() == testStoreId); // CHECK(resultPair.second.getId() == testStoreId);
CHECK(resultPair.second.size() == 10); // CHECK(resultPair.second.size() == 10);
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
//
std::copy(resultPair.second.data(), resultPair.second.data() + // std::copy(resultPair.second.data(), resultPair.second.data() +
resultPair.second.size(), receptionArray.data()); // resultPair.second.size(), receptionArray.data());
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
//
{ // {
auto resultPairLoc = SimplePool.getData(testStoreId); // auto resultPairLoc = SimplePool.getData(testStoreId);
REQUIRE(resultPairLoc.first == retval::CATCH_OK); // REQUIRE(resultPairLoc.first == retval::CATCH_OK);
// data should be deleted when accessor goes out of scope. // // data should be deleted when accessor goes out of scope.
} // }
resultPair = SimplePool.getData(testStoreId); // resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); // REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
//
result = SimplePool.addData(&testStoreId, testDataArray.data(), size); // result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
{ // {
ConstStorageAccessor constAccessor(testStoreId); // ConstStorageAccessor constAccessor(testStoreId);
result = SimplePool.getData(testStoreId, constAccessor); // result = SimplePool.getData(testStoreId, constAccessor);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
constAccessor.getDataCopy(receptionArray.data(), 20); // constAccessor.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
// likewise, data should be deleted when accessor gets out of scope. // // likewise, data should be deleted when accessor gets out of scope.
} // }
resultPair = SimplePool.getData(testStoreId); // resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); // REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
//
result = SimplePool.addData(&testStoreId, testDataArray.data(), size); // result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
{ // {
resultPair = SimplePool.getData(testStoreId); // resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK); // REQUIRE(resultPair.first == retval::CATCH_OK);
resultPair.second.release(); // resultPair.second.release();
// now data should not be deleted anymore // // now data should not be deleted anymore
} // }
resultPair = SimplePool.getData(testStoreId); // resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK); // REQUIRE(resultPair.first == retval::CATCH_OK);
resultPair.second.getDataCopy(receptionArray.data(), 20); // resultPair.second.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
} // }
//
//
SECTION("Simple tests modify functions") { // SECTION("Simple tests modify functions") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size); // result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
{ // {
StorageAccessor accessor(testStoreId); // StorageAccessor accessor(testStoreId);
result = SimplePool.modifyData(testStoreId, accessor); // result = SimplePool.modifyData(testStoreId, accessor);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
CHECK(accessor.getId() == testStoreId); // CHECK(accessor.getId() == testStoreId);
CHECK(accessor.size() == 10); // CHECK(accessor.size() == 10);
accessor.getDataCopy(receptionArray.data(), 20); // accessor.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
std::copy(accessor.data(), accessor.data() + // std::copy(accessor.data(), accessor.data() +
accessor.size(), receptionArray.data()); // accessor.size(), receptionArray.data());
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
// data should be deleted when accessor goes out of scope // // data should be deleted when accessor goes out of scope
} // }
auto resultPair = SimplePool.getData(testStoreId); // auto resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); // REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
//
result = SimplePool.addData(&testStoreId, testDataArray.data(), size); // result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
{ // {
auto resultPairLoc = SimplePool.modifyData(testStoreId); // auto resultPairLoc = SimplePool.modifyData(testStoreId);
REQUIRE(resultPairLoc.first == retval::CATCH_OK); // REQUIRE(resultPairLoc.first == retval::CATCH_OK);
CHECK(resultPairLoc.second.getId() == testStoreId); // CHECK(resultPairLoc.second.getId() == testStoreId);
CHECK(resultPairLoc.second.size() == 10); // CHECK(resultPairLoc.second.size() == 10);
resultPairLoc.second.getDataCopy(receptionArray.data(), 20); // resultPairLoc.second.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
std::copy(resultPairLoc.second.data(), resultPairLoc.second.data() + // std::copy(resultPairLoc.second.data(), resultPairLoc.second.data() +
resultPairLoc.second.size(), receptionArray.data()); // resultPairLoc.second.size(), receptionArray.data());
for(size_t i = 0; i < size; i++) { // for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
resultPairLoc.second.release(); // resultPairLoc.second.release();
// data should not be deleted when accessor goes out of scope // // data should not be deleted when accessor goes out of scope
} // }
resultPair = SimplePool.getData(testStoreId); // resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK); // REQUIRE(resultPair.first == retval::CATCH_OK);
} // }
//
//
SECTION("Write tests") { // SECTION("Write tests") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size); // result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
{ // {
auto resultPair = SimplePool.modifyData(testStoreId); // auto resultPair = SimplePool.modifyData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK); // REQUIRE(resultPair.first == retval::CATCH_OK);
testDataArray[9] = 42; // testDataArray[9] = 42;
resultPair.second.write(testDataArray.data(), 10, 0); // resultPair.second.write(testDataArray.data(), 10, 0);
// now data should not be deleted // // now data should not be deleted
resultPair.second.release(); // resultPair.second.release();
} // }
auto resultConstPair = SimplePool.getData(testStoreId); // auto resultConstPair = SimplePool.getData(testStoreId);
REQUIRE(resultConstPair.first == retval::CATCH_OK); // REQUIRE(resultConstPair.first == retval::CATCH_OK);
//
resultConstPair.second.getDataCopy(receptionArray.data(), 10); // resultConstPair.second.getDataCopy(receptionArray.data(), 10);
for(size_t i = 0; i < size-1; i++) { // for(size_t i = 0; i < size-1; i++) {
CHECK(receptionArray[i] == i ); // CHECK(receptionArray[i] == i );
} // }
CHECK(receptionArray[9] == 42 ); // CHECK(receptionArray[9] == 42 );
//
auto resultPair = SimplePool.modifyData(testStoreId); // auto resultPair = SimplePool.modifyData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK); // REQUIRE(resultPair.first == retval::CATCH_OK);
result = resultPair.second.write(testDataArray.data(), 20, 0); // result = resultPair.second.write(testDataArray.data(), 20, 0);
REQUIRE(result == retval::CATCH_FAILED); // REQUIRE(result == retval::CATCH_FAILED);
result = resultPair.second.write(testDataArray.data(), 10, 5); // result = resultPair.second.write(testDataArray.data(), 10, 5);
REQUIRE(result == retval::CATCH_FAILED); // REQUIRE(result == retval::CATCH_FAILED);
//
memset(testDataArray.data(), 42, 5); // memset(testDataArray.data(), 42, 5);
result = resultPair.second.write(testDataArray.data(), 5, 5); // result = resultPair.second.write(testDataArray.data(), 5, 5);
REQUIRE(result == retval::CATCH_OK); // REQUIRE(result == retval::CATCH_OK);
resultConstPair = SimplePool.getData(testStoreId); // resultConstPair = SimplePool.getData(testStoreId);
resultPair.second.getDataCopy(receptionArray.data(), 20); // resultPair.second.getDataCopy(receptionArray.data(), 20);
for(size_t i = 5; i < 10; i++) { // for(size_t i = 5; i < 10; i++) {
CHECK(receptionArray[i] == 42 ); // CHECK(receptionArray[i] == 42 );
} // }
//
} // }
} //}