first dest handler unittests

- Add new mock class for event reporting proxies
- Add basic setup for unittesting the CFDP destination handler
This commit is contained in:
Robin Müller 2022-09-05 11:37:41 +02:00
parent 0dd2b5ddd4
commit d2c4d546c3
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
6 changed files with 56 additions and 12 deletions

View File

@ -416,3 +416,5 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() {
}
return OK;
}
cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const { return step; }

View File

@ -72,6 +72,14 @@ struct FsfwParams {
class DestHandler {
public:
enum class TransactionStep {
IDLE = 0,
TRANSACTION_START = 1,
RECEIVING_FILE_DATA_PDUS = 2,
SENDING_ACK_PDU = 3,
TRANSFER_COMPLETION = 4,
SENDING_FINISHED_PDU = 5
};
/**
* Will be returned if it is advisable to call the state machine operation call again
*/
@ -91,16 +99,9 @@ class DestHandler {
ReturnValue_t initialize();
[[nodiscard]] CfdpStates getCfdpState() const;
[[nodiscard]] TransactionStep getTransactionStep() const;
private:
enum class TransactionStep {
IDLE = 0,
TRANSACTION_START = 1,
RECEIVING_FILE_DATA_PDUS = 2,
SENDING_ACK_PDU = 3,
TRANSFER_COMPLETION = 4,
SENDING_FINISHED_PDU = 5
};
struct TransactionParams {
explicit TransactionParams(size_t maxFileNameLen)
: sourceName(maxFileNameLen), destName(maxFileNameLen) {}

View File

@ -2,14 +2,17 @@
#include "fsfw/cfdp.h"
#include "mocks/AcceptsTmMock.h"
#include "mocks/EventReportingProxyMock.h"
#include "mocks/FilesystemMock.h"
#include "mocks/MessageQueueMock.h"
#include "mocks/StorageManagerMock.h"
#include "mocks/cfdp/FaultHandlerMock.h"
#include "mocks/cfdp/RemoteConfigTableMock.h"
#include "mocks/cfdp/UserMock.h"
TEST_CASE("CFDP Dest Handler", "[cfdp]") {
using namespace cfdp;
using namespace returnvalue;
MessageQueueId_t destQueueId = 2;
AcceptsTmMock tmReceiver(destQueueId);
MessageQueueMock mqMock(destQueueId);
@ -23,8 +26,18 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
LostSegmentsList<128> lostSegmentsList;
DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList,
lostSegmentsList);
// FsfwParams fp(destQueueId, mqMock);
// auto destHandler = DestHandler();
EventReportingProxyMock eventReporterMock;
LocalPool::LocalPoolConfig storeCfg = {{10, 32}, {10, 64}, {10, 128}, {10, 1024}};
StorageManagerMock tcStore(2, storeCfg);
StorageManagerMock tmStore(3, storeCfg);
FsfwParams fp(tmReceiver, mqMock, eventReporterMock);
fp.tcStore = &tcStore;
fp.tmStore = &tmStore;
auto destHandler = DestHandler(dp, fp);
CHECK(destHandler.initialize() == OK);
SECTION("State") {}
SECTION("State") {
CHECK(destHandler.getCfdpState() == CfdpStates::IDLE);
CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE);
}
}

View File

@ -15,6 +15,7 @@ target_sources(
CcsdsCheckerMock.cpp
AcceptsTcMock.cpp
StorageManagerMock.cpp
FilesystemMock.cpp)
FilesystemMock.cpp
EventReportingProxyMock.cpp)
add_subdirectory(cfdp)

View File

@ -0,0 +1,6 @@
#include "EventReportingProxyMock.h"
void EventReportingProxyMock::forwardEvent(Event event, uint32_t parameter1,
uint32_t parameter2) const {
eventQueue.emplace(event, parameter1, parameter2);
}

View File

@ -0,0 +1,21 @@
#ifndef FSFW_TESTS_EVENTREPORTPROXYMOCK_H
#define FSFW_TESTS_EVENTREPORTPROXYMOCK_H
#include <queue>
#include "fsfw/events/EventReportingProxyIF.h"
class EventReportingProxyMock : public EventReportingProxyIF {
public:
void forwardEvent(Event event, uint32_t parameter1, uint32_t parameter2) const override;
struct EventInfo {
EventInfo(Event event, uint32_t p1, uint32_t p2) : event(event), p1(p1), p2(p2) {}
Event event;
uint32_t p1;
uint32_t p2;
};
mutable std::queue<EventInfo> eventQueue;
};
#endif // FSFW_TESTS_EVENTREPORTPROXYMOCK_H