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" #include "tmHelpers.h"
ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper, ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper, TmSendHelper &sendHelper,
TmSendHelper &sendHelper) { bool delOnFailure) {
storeHelper.addPacketToStore(); ReturnValue_t result = storeHelper.addPacketToStore();
ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr());
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
storeHelper.deletePacket(); return result;
}
result = sendHelper.sendPacket(storeHelper.getCurrentAddr());
if (result != HasReturnvaluesIF::RETURN_OK) {
if (delOnFailure) {
storeHelper.deletePacket();
}
} }
return result; return result;
} }

View File

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

View File

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

View File

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