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:
parent
0dd2b5ddd4
commit
d2c4d546c3
@ -416,3 +416,5 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() {
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const { return step; }
|
||||
|
@ -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) {}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ target_sources(
|
||||
CcsdsCheckerMock.cpp
|
||||
AcceptsTcMock.cpp
|
||||
StorageManagerMock.cpp
|
||||
FilesystemMock.cpp)
|
||||
FilesystemMock.cpp
|
||||
EventReportingProxyMock.cpp)
|
||||
|
||||
add_subdirectory(cfdp)
|
||||
|
6
unittests/mocks/EventReportingProxyMock.cpp
Normal file
6
unittests/mocks/EventReportingProxyMock.cpp
Normal 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);
|
||||
}
|
21
unittests/mocks/EventReportingProxyMock.h
Normal file
21
unittests/mocks/EventReportingProxyMock.h
Normal 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
|
Loading…
Reference in New Issue
Block a user