some more tests using TM send helper

This commit is contained in:
Robin Müller 2022-07-25 20:41:01 +02:00
parent 586993c081
commit c83f75c515
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 26 additions and 11 deletions

View File

@ -1,11 +1,16 @@
#include "tmHelpers.h"
ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper,
TmSendHelper &sendHelper) {
storeHelper.addPacketToStore();
ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr());
ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper, TmSendHelper &sendHelper,
bool delOnFailure) {
ReturnValue_t result = storeHelper.addPacketToStore();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = sendHelper.sendPacket(storeHelper.getCurrentAddr());
if (result != HasReturnvaluesIF::RETURN_OK) {
if (delOnFailure) {
storeHelper.deletePacket();
}
}
return result;
}

View File

@ -7,7 +7,8 @@
// I'd prefer to use tm, but there have been nameclashes with the tm struct
namespace telemetry {
ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper);
ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper,
bool delOnFailure = true);
class DataWithObjectIdPrefix : public SerializeIF {
public:

View File

@ -1,9 +1,9 @@
#include <catch2/catch_test_macros.hpp>
#include <iostream>
#include "fsfw/storagemanager/LocalPool.h"
#include "fsfw/tmtcservices/TmSendHelper.h"
#include "fsfw/tmtcservices/TmStoreHelper.h"
#include "fsfw/tmtcservices/tmHelpers.h"
#include "mocks/CdsShortTimestamperMock.h"
#include "mocks/InternalErrorReporterMock.h"
#include "mocks/MessageQueueMock.h"
@ -61,10 +61,18 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") {
REQUIRE(helper.getMsgQueue() == &msgQueue);
}
SECTION("Send") {
storeHelper.preparePacket(17, 2, 0);
REQUIRE(storeHelper.preparePacket(17, 2, 0) == HasReturnvaluesIF::RETURN_OK);
store_address_t storeId;
SECTION("Separate Helpers") {
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
store_address_t storeId = storeHelper.getCurrentAddr();
storeId = storeHelper.getCurrentAddr();
REQUIRE(sendHelper.sendPacket(storeId) == HasReturnvaluesIF::RETURN_OK);
}
SECTION("Helper Wrapper") {
REQUIRE(telemetry::storeAndSendTmPacket(storeHelper, sendHelper) ==
HasReturnvaluesIF::RETURN_OK);
storeId = storeHelper.getCurrentAddr();
}
REQUIRE(msgQueue.wasMessageSent());
REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1);
TmTcMessage msg;

View File

@ -2,6 +2,7 @@
#include "fsfw/storagemanager/LocalPool.h"
#include "fsfw/tmtcservices/TmStoreHelper.h"
#include "fsfw/tmtcservices/tmHelpers.h"
#include "mocks/CdsShortTimestamperMock.h"
#include "mocks/SimpleSerializable.h"