Update FSFW from upstream #71

Closed
muellerr wants to merge 1112 commits from development into eive/develop
6 changed files with 112 additions and 13 deletions
Showing only changes of commit 36e3956efb - Show all commits

View File

@ -26,13 +26,19 @@ ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice,
return HasReturnvaluesIF::RETURN_OK;
}
StorageManagerIF* TmStoreHelper::getTmStore() { return tmStore; }
StorageManagerIF* TmStoreHelper::getTmStore() const { return tmStore; }
void TmStoreHelper::setTmStore(StorageManagerIF& store) { tmStore = &store; }
const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; }
ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); }
ReturnValue_t TmStoreHelper::deletePacket() {
ReturnValue_t result = tmStore->deleteData(currentAddr);
if(result == HasReturnvaluesIF::RETURN_OK) {
currentAddr = store_address_t::invalid();
}
return result;
}
ReturnValue_t TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) {
return creator.setRawUserData(data, len);
@ -62,3 +68,7 @@ void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) {
void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); }
PusTmCreator& TmStoreHelper::getCreatorRef() { return creator; }
TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); }
uint16_t TmStoreHelper::getApid() const { return creator.getApid(); }

View File

@ -16,13 +16,21 @@ class TmStoreHelper {
ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter);
PusTmCreator& getCreatorRef();
void setTimeStamper(TimeStamperIF& timeStamper);
[[nodiscard]] TimeStamperIF* getTimeStamper() const;
[[nodiscard]] StorageManagerIF* getTmStore() const;
void setTmStore(StorageManagerIF& store);
void setApid(uint16_t apid);
[[nodiscard]] uint16_t getApid() const;
[[nodiscard]] const store_address_t& getCurrentAddr() const;
ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len);
ReturnValue_t setSourceDataSerializable(SerializeIF& serializable);
void setApid(uint16_t apid);
StorageManagerIF* getTmStore();
void setTmStore(StorageManagerIF& store);
ReturnValue_t addPacketToStore();
ReturnValue_t deletePacket();

View File

@ -18,11 +18,11 @@ class MessageQueueMockBase : public MessageQueueBase {
uint8_t messageSentCounter = 0;
bool messageSent = false;
bool wasMessageSent(uint8_t* messageSentCounter = nullptr, bool resetCounter = true) {
bool wasMessageSent(uint8_t* messageSentCounter_ = nullptr, bool resetCounter = true) {
bool tempMessageSent = messageSent;
messageSent = false;
if (messageSentCounter != nullptr) {
*messageSentCounter = this->messageSentCounter;
if (messageSentCounter_ != nullptr) {
*messageSentCounter_ = this->messageSentCounter;
}
if (resetCounter) {
this->messageSentCounter = 0;
@ -40,7 +40,7 @@ class MessageQueueMockBase : public MessageQueueBase {
return receiveMessage(&message);
}
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override {
ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override {
if (messagesSentQueue.empty()) {
return MessageQueueIF::EMPTY;
}
@ -50,8 +50,8 @@ class MessageQueueMockBase : public MessageQueueBase {
messagesSentQueue.pop();
return HasReturnvaluesIF::RETURN_OK;
}
virtual ReturnValue_t flush(uint32_t* count) { return HasReturnvaluesIF::RETURN_OK; }
virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
ReturnValue_t flush(uint32_t* count) override { return HasReturnvaluesIF::RETURN_OK; }
ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
MessageQueueId_t sentFrom,
bool ignoreFault = false) override {
messageSent = true;
@ -61,7 +61,7 @@ class MessageQueueMockBase : public MessageQueueBase {
return HasReturnvaluesIF::RETURN_OK;
}
virtual ReturnValue_t reply(MessageQueueMessageIF* message) override {
ReturnValue_t reply(MessageQueueMessageIF* message) override {
return sendMessageFrom(MessageQueueIF::NO_QUEUE, message, this->getId(), false);
}

View File

@ -1,3 +1,4 @@
target_sources(${FSFW_TEST_TGT} PRIVATE
testStoreHelper.cpp
testSendHelper.cpp
)

View File

@ -0,0 +1,5 @@
#include <catch2/catch_test_macros.hpp>
TEST_CASE("TM Send Helper", "[tm-send-helper]") {
}

View File

@ -3,15 +3,17 @@
#include "fsfw/storagemanager/LocalPool.h"
#include "fsfw/tmtcservices/TmStoreHelper.h"
#include "mocks/CdsShortTimestamperMock.h"
#include "mocks/SimpleSerializable.h"
TEST_CASE("TM Store Helper", "[tm-store-helper]") {
auto timeStamper = CdsShortTimestamperMock();
LocalPool::LocalPoolConfig cfg = {{10, 32}, {5, 64}};
LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}};
LocalPool pool(objects::NO_OBJECT, cfg);
auto storeHelper = TmStoreHelper(2, pool, timeStamper);
SECTION("State") {
REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid());
REQUIRE(storeHelper.getTimeStamper() == &timeStamper);
REQUIRE(storeHelper.getTmStore() == &pool);
REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK);
auto& creator = storeHelper.getCreatorRef();
@ -22,6 +24,25 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") {
REQUIRE(creator.getMessageTypeCounter() == 1);
}
SECTION("Timestamper Setter") {
auto timeStamper2 = CdsShortTimestamperMock();
storeHelper.setTimeStamper(timeStamper2);
REQUIRE(storeHelper.getTimeStamper() == &timeStamper2);
}
SECTION("Pool Setter") {
LocalPool::LocalPoolConfig cfg2 = {{10, 32}, {5, 64}};
LocalPool pool2(objects::NO_OBJECT, cfg);
storeHelper.setTmStore(pool2);
REQUIRE(storeHelper.getTmStore() == &pool2);
}
SECTION("APID Setter") {
storeHelper.setApid(3);
auto& creator = storeHelper.getCreatorRef();
REQUIRE(creator.getApid() == 3);
}
SECTION("Basic") {
REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
@ -31,4 +52,58 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") {
// Not going to verify individual fields, the creator was unittested separately
REQUIRE(accessor.second.size() == 22);
}
SECTION("Deletion") {
REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid());
{
auto accessor = pool.getData(storeHelper.getCurrentAddr());
REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK);
REQUIRE(accessor.second.size() == 22);
accessor.second.release();
}
REQUIRE(storeHelper.deletePacket() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid());
auto accessor = pool.getData(storeHelper.getCurrentAddr());
REQUIRE(accessor.first != HasReturnvaluesIF::RETURN_OK);
}
SECTION("With App Data Raw") {
REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK);
std::array<uint8_t, 3> data = {1, 2, 3};
REQUIRE(storeHelper.setSourceDataRaw(data.data(), data.size()) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid());
auto accessor = pool.getData(storeHelper.getCurrentAddr());
REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK);
// Not going to verify individual fields, the creator was unittested separately
REQUIRE(accessor.second.size() == 25);
}
SECTION("With App Data Serializable") {
REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK);
auto serializable = SimpleSerializable();
REQUIRE(storeHelper.setSourceDataSerializable(serializable) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid());
auto accessor = pool.getData(storeHelper.getCurrentAddr());
REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK);
// Not going to verify individual fields, the creator was unittested separately
REQUIRE(accessor.second.size() == 25);
}
SECTION("APID Only CTOR") {
auto storeHelperApidOnly = TmStoreHelper(2);
REQUIRE(storeHelperApidOnly.getApid() == 2);
REQUIRE(storeHelperApidOnly.getTmStore() == nullptr);
REQUIRE(storeHelperApidOnly.getTimeStamper() == nullptr);
}
SECTION("APID and TM Store Only CTOR") {
auto storeHelperApidOnly = TmStoreHelper(2, pool);
REQUIRE(storeHelperApidOnly.getApid() == 2);
REQUIRE(storeHelperApidOnly.getTmStore() == &pool);
REQUIRE(storeHelperApidOnly.getTimeStamper() == nullptr);
}
}