some bugfixes

This commit is contained in:
Robin Müller 2022-08-09 15:09:43 +02:00
parent dba3f9960e
commit 7f9401cf63
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
8 changed files with 48 additions and 9 deletions

View File

@ -23,7 +23,7 @@ bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHand
return true; return true;
} }
bool FaultHandlerBase::faultCallback(cfdp::ConditionCode code) { bool FaultHandlerBase::reportFault(cfdp::ConditionCode code) {
if (not faultHandlerMap.contains(code)) { if (not faultHandlerMap.contains(code)) {
return false; return false;
} }

View File

@ -25,7 +25,7 @@ class FaultHandlerBase {
bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler); bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler);
bool faultCallback(cfdp::ConditionCode code); bool reportFault(cfdp::ConditionCode code);
virtual void noticeOfSuspensionCb(cfdp::ConditionCode code) = 0; virtual void noticeOfSuspensionCb(cfdp::ConditionCode code) = 0;
virtual void noticeOfCancellationCb(cfdp::ConditionCode code) = 0; virtual void noticeOfCancellationCb(cfdp::ConditionCode code) = 0;
@ -33,7 +33,7 @@ class FaultHandlerBase {
virtual void ignoreCb(cfdp::ConditionCode code) = 0; virtual void ignoreCb(cfdp::ConditionCode code) = 0;
private: private:
etl::flat_map<cfdp::ConditionCode, cfdp::FaultHandlerCodes, 9> faultHandlerMap = { etl::flat_map<cfdp::ConditionCode, cfdp::FaultHandlerCodes, 10> faultHandlerMap = {
etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED, etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR}, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED, etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
@ -45,7 +45,9 @@ class FaultHandlerBase {
etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE,
cfdp::FaultHandlerCodes::IGNORE_ERROR}}; cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}};
}; };
} // namespace cfdp } // namespace cfdp

View File

@ -1,5 +1,4 @@
target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testTlvsLvs.cpp target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testTlvsLvs.cpp)
testSourceHandler.cpp)
add_subdirectory(handler) add_subdirectory(handler)
add_subdirectory(pdu) add_subdirectory(pdu)

View File

@ -1 +1,3 @@
target_sources(${FSFW_TEST_TGT} PRIVATE testDistributor.cpp testDestHandler.cpp) target_sources(
${FSFW_TEST_TGT} PRIVATE testDistributor.cpp testDestHandler.cpp
testSourceHandler.cpp testFaultHandler.cpp)

View File

@ -0,0 +1,36 @@
#include <catch2/catch_test_macros.hpp>
#include "mocks/CfdpFaultHandlerMock.h"
TEST_CASE("CFDP Fault Handler", "[cfdp]") {
using namespace cfdp;
auto fhMock = CfdpFaultHandlerMock();
cfdp::FaultHandlerCodes fhCode;
SECTION("State") {
// Verify initial condition
CHECK(fhMock.getFaultHandler(ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::POSITIVE_ACK_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::INVALID_TRANSMISSION_MODE, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::FILESTORE_REJECTION, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::FILE_CHECKSUM_FAILURE, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::FILE_SIZE_ERROR, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::NAK_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::INACTIVITY_DETECTED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::CHECK_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
}
SECTION("Call Handler") {
fhMock.reportFault(ConditionCode::CHECK_LIMIT_REACHED);
}
}

View File

@ -4,7 +4,7 @@
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/pdu/FileDirectiveReader.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h"
TEST_CASE("CFDP File Directive", "[cfdp]") { TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
using namespace cfdp; using namespace cfdp;
std::array<uint8_t, 32> serBuf{}; std::array<uint8_t, 32> serBuf{};
ReturnValue_t result; ReturnValue_t result;

View File

@ -19,7 +19,7 @@ class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase {
void ignoreCb(cfdp::ConditionCode code) override; void ignoreCb(cfdp::ConditionCode code) override;
FaultInfo& getFhInfo(cfdp::FaultHandlerCodes fhCode); FaultInfo& getFhInfo(cfdp::FaultHandlerCodes fhCode);
bool faultCbWasCalled() const; [[nodiscard]] bool faultCbWasCalled() const;
void reset(); void reset();
private: private: