check that indication was called
This commit is contained in:
parent
7b97c8a182
commit
806ae9b41a
@ -78,7 +78,7 @@ struct TransactionId {
|
|||||||
TransactionId(EntityId entityId, TransactionSeqNum seqNum)
|
TransactionId(EntityId entityId, TransactionSeqNum seqNum)
|
||||||
: entityId(std::move(entityId)), seqNum(std::move(seqNum)) {}
|
: entityId(std::move(entityId)), seqNum(std::move(seqNum)) {}
|
||||||
|
|
||||||
bool operator==(const TransactionId &other) {
|
bool operator==(const TransactionId &other) const {
|
||||||
return entityId == other.entityId and seqNum == other.seqNum;
|
return entityId == other.entityId and seqNum == other.seqNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,3 +452,5 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::updateFsmRes(uint8_t erro
|
|||||||
}
|
}
|
||||||
return fsmRes;
|
return fsmRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cfdp::TransactionId& cfdp::DestHandler::getTransactionId() const { return tp.transactionId; }
|
||||||
|
@ -121,6 +121,7 @@ class DestHandler {
|
|||||||
|
|
||||||
[[nodiscard]] CfdpStates getCfdpState() const;
|
[[nodiscard]] CfdpStates getCfdpState() const;
|
||||||
[[nodiscard]] TransactionStep getTransactionStep() const;
|
[[nodiscard]] TransactionStep getTransactionStep() const;
|
||||||
|
const TransactionId& getTransactionId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TransactionParams {
|
struct TransactionParams {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "fsfw/cfdp.h"
|
#include "fsfw/cfdp.h"
|
||||||
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
|
|
||||||
#include "fsfw/cfdp/pdu/EofPduCreator.h"
|
#include "fsfw/cfdp/pdu/EofPduCreator.h"
|
||||||
|
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
|
||||||
#include "mocks/AcceptsTmMock.h"
|
#include "mocks/AcceptsTmMock.h"
|
||||||
#include "mocks/EventReportingProxyMock.h"
|
#include "mocks/EventReportingProxyMock.h"
|
||||||
#include "mocks/FilesystemMock.h"
|
#include "mocks/FilesystemMock.h"
|
||||||
@ -20,11 +20,11 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
MessageQueueMock mqMock(destQueueId);
|
MessageQueueMock mqMock(destQueueId);
|
||||||
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
|
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
|
||||||
EntityId remoteId = EntityId(UnsignedByteField<uint16_t>(3));
|
EntityId remoteId = EntityId(UnsignedByteField<uint16_t>(3));
|
||||||
auto fhMock = FaultHandlerMock();
|
FaultHandlerMock fhMock;
|
||||||
auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock);
|
LocalEntityCfg localEntityCfg(localId, IndicationCfg(), fhMock);
|
||||||
auto fsMock = FilesystemMock();
|
FilesystemMock fsMock;
|
||||||
auto userMock = UserMock(fsMock);
|
UserMock userMock(fsMock);
|
||||||
auto remoteCfgTableMock = RemoteConfigTableMock();
|
RemoteConfigTableMock remoteCfgTableMock;
|
||||||
PacketInfoList<64> packetInfoList;
|
PacketInfoList<64> packetInfoList;
|
||||||
LostSegmentsList<128> lostSegmentsList;
|
LostSegmentsList<128> lostSegmentsList;
|
||||||
DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList,
|
DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList,
|
||||||
@ -74,7 +74,8 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &ptr) == OK);
|
REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &ptr) == OK);
|
||||||
size_t serLen = 0;
|
size_t serLen = 0;
|
||||||
REQUIRE(metadataCreator.serialize(ptr, serLen, metadataCreator.getSerializedSize()) == OK);
|
REQUIRE(metadataCreator.serialize(ptr, serLen, metadataCreator.getSerializedSize()) == OK);
|
||||||
PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(), storeId);
|
PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(),
|
||||||
|
storeId);
|
||||||
packetInfoList.push_back(packetInfo);
|
packetInfoList.push_back(packetInfo);
|
||||||
destHandler.performStateMachine();
|
destHandler.performStateMachine();
|
||||||
REQUIRE(res.result == OK);
|
REQUIRE(res.result == OK);
|
||||||
@ -82,6 +83,13 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
// Assert that the packet was deleted after handling
|
// Assert that the packet was deleted after handling
|
||||||
REQUIRE(not tcStore.hasDataAtId(storeId));
|
REQUIRE(not tcStore.hasDataAtId(storeId));
|
||||||
destHandler.performStateMachine();
|
destHandler.performStateMachine();
|
||||||
|
REQUIRE(userMock.metadataRecvd.size() == 1);
|
||||||
|
MetadataRecvdParams& params = userMock.metadataRecvd.back();
|
||||||
|
REQUIRE(params.id == destHandler.getTransactionId());
|
||||||
|
REQUIRE(params.sourceId.getValue() == 3);
|
||||||
|
REQUIRE(params.fileSize == 0);
|
||||||
|
REQUIRE(strcmp(params.destFileName, "hello-cpy.txt") == 0);
|
||||||
|
REQUIRE(strcmp(params.sourceFileName, "hello.txt") == 0);
|
||||||
REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end());
|
REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end());
|
||||||
REQUIRE(res.result == OK);
|
REQUIRE(res.result == OK);
|
||||||
REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY);
|
REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY);
|
||||||
|
@ -10,7 +10,12 @@ void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode
|
|||||||
uint64_t progress) {}
|
uint64_t progress) {}
|
||||||
void UserMock::eofRecvIndication(const TransactionId& id) {}
|
void UserMock::eofRecvIndication(const TransactionId& id) {}
|
||||||
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {}
|
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {}
|
||||||
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {}
|
|
||||||
|
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {
|
||||||
|
MetadataRecvdParams copy = params;
|
||||||
|
metadataRecvd.push(copy);
|
||||||
|
}
|
||||||
|
|
||||||
void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {}
|
void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {}
|
||||||
void UserMock::reportIndication(const TransactionId& id, StatusReportIF& report) {}
|
void UserMock::reportIndication(const TransactionId& id, StatusReportIF& report) {}
|
||||||
void UserMock::suspendedIndication(const TransactionId& id, ConditionCode code) {}
|
void UserMock::suspendedIndication(const TransactionId& id, ConditionCode code) {}
|
||||||
@ -18,4 +23,9 @@ void UserMock::resumedIndication(const TransactionId& id, size_t progress) {}
|
|||||||
void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code, size_t progress) {
|
void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code, size_t progress) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserMock::reset() {
|
||||||
|
auto empty = std::queue<cfdp::MetadataRecvdParams>();
|
||||||
|
metadataRecvd.swap(empty);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#ifndef FSFW_TESTS_CFDP_USERMOCK_H
|
#ifndef FSFW_TESTS_CFDP_USERMOCK_H
|
||||||
#define FSFW_TESTS_CFDP_USERMOCK_H
|
#define FSFW_TESTS_CFDP_USERMOCK_H
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#include "fsfw/cfdp/handler/UserBase.h"
|
#include "fsfw/cfdp/handler/UserBase.h"
|
||||||
|
|
||||||
namespace cfdp {
|
namespace cfdp {
|
||||||
|
|
||||||
class UserMock : public UserBase {
|
class UserMock : public UserBase {
|
||||||
@ -19,6 +22,9 @@ class UserMock : public UserBase {
|
|||||||
void suspendedIndication(const TransactionId& id, ConditionCode code) override;
|
void suspendedIndication(const TransactionId& id, ConditionCode code) override;
|
||||||
void resumedIndication(const TransactionId& id, size_t progress) override;
|
void resumedIndication(const TransactionId& id, size_t progress) override;
|
||||||
void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override;
|
void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override;
|
||||||
|
|
||||||
|
std::queue<MetadataRecvdParams> metadataRecvd;
|
||||||
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
|
Loading…
Reference in New Issue
Block a user