From d474c4a7ee1d62d640ecca1a6cedd6f7df397b73 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 11:43:48 +0200 Subject: [PATCH] store helper --- src/fsfw/serialize/SerializeIF.h | 6 +- src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h | 4 ++ .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 2 + .../tmtcpacket/ccsds/SpacePacketCreator.h | 1 + src/fsfw/tmtcservices/TmStoreHelper.cpp | 19 +++-- unittests/CMakeLists.txt | 1 + unittests/mocks/SimpleSerializable.h | 2 +- unittests/serialize/testSerializeIF.cpp | 44 ++++++++---- unittests/tmtcpacket/testCcsds.cpp | 69 +++++++++++++++++-- unittests/tmtcpacket/testCcsdsCreator.cpp | 57 ++++++++------- unittests/tmtcservices/CMakeLists.txt | 2 + unittests/tmtcservices/testStoreHelper.cpp | 3 + 12 files changed, 150 insertions(+), 60 deletions(-) create mode 100644 unittests/tmtcservices/CMakeLists.txt create mode 100644 unittests/tmtcservices/testStoreHelper.cpp diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 54a1f4e3..2b466839 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -64,7 +64,7 @@ class SerializeIF { /** * Forwards to regular @serialize call with network endianness */ - virtual ReturnValue_t serializeNe(uint8_t** buffer, size_t* size, size_t maxSize) { + virtual ReturnValue_t serializeNe(uint8_t **buffer, size_t *size, size_t maxSize) { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** @@ -105,13 +105,13 @@ class SerializeIF { /** * Forwards to regular @deSerialize call with network endianness */ - virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size) { + virtual ReturnValue_t deSerializeNe(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size) { + virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE); } diff --git a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h index 830a6fa2..cd4e153e 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h @@ -12,6 +12,10 @@ struct PacketSeqCtrl : public SerializeIF { PacketSeqCtrl(ccsds::SequenceFlags seqFlags, uint16_t seqCount) : seqFlags(seqFlags), seqCount(seqCount) {} + bool operator==(const PacketSeqCtrl &other) const { + return seqCount == other.seqCount and seqFlags == other.seqFlags; + } + /** * NOTE: If the sequence control has an invalid value, the invalid bits will be cut off * @return diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index 05da88b4..20c9341f 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -81,3 +81,5 @@ void SpacePacketCreator::setPacketType(ccsds::PacketType type) { params.packetId.packetType = type; } bool SpacePacketCreator::operator==(const SpacePacketCreator &other) const { return false; } + +SpacePacketCreator::operator bool() const { return isValid(); } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h index d30457ea..9c13bd5a 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -26,6 +26,7 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { explicit SpacePacketCreator(SpacePacketParams params); bool operator==(const SpacePacketCreator &other) const; + explicit operator bool() const; SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 44b2e6a1..3260d4d1 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -14,13 +14,10 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore) : } ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { - // TODO: Implement - // creator.setApid(apid); PusTmParams& params = creator.getParams(); params.secHeader.service = service; params.secHeader.subservice = subservice; params.secHeader.messageTypeCounter = counter; - // TODO: Implement serialize and then serialize into the store return HasReturnvaluesIF::RETURN_OK; } @@ -31,22 +28,21 @@ const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAdd ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); } void TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { - PusTmParams& params = creator.getParams(); - params.dataWrapper.type = ecss::DataTypes::RAW; - params.dataWrapper.dataUnion.raw.data = data; - params.dataWrapper.dataUnion.raw.len = len; + creator.setRawUserData(data, len); } void TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) { - PusTmParams& params = creator.getParams(); - params.dataWrapper.type = ecss::DataTypes::SERIALIZABLE; - params.dataWrapper.dataUnion.serializable = serializable; + creator.setSerializableUserData(serializable); } ReturnValue_t TmStoreHelper::addPacketToStore() { creator.updateSpLengthField(); uint8_t* dataPtr; - tmStore->getFreeElement(¤tAddr, creator.getSerializedSize(), &dataPtr); + ReturnValue_t result = + tmStore->getFreeElement(¤tAddr, creator.getSerializedSize(), &dataPtr); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } size_t serLen = 0; return creator.serialize(&dataPtr, &serLen, creator.getSerializedSize(), SerializeIF::Endianness::NETWORK); @@ -55,4 +51,5 @@ ReturnValue_t TmStoreHelper::addPacketToStore() { void TmStoreHelper::setTimeStamper(TimeStamperIF* timeStamper_) { creator.setTimeStamper(timeStamper_); } + void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); } diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index f32c6e08..28d950d4 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -27,5 +27,6 @@ add_subdirectory(cfdp) add_subdirectory(hal) add_subdirectory(internalerror) add_subdirectory(devicehandler) +add_subdirectory(tmtcservices) target_include_directories(${FSFW_TEST_TGT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/unittests/mocks/SimpleSerializable.h b/unittests/mocks/SimpleSerializable.h index 5c28a09a..222f1729 100644 --- a/unittests/mocks/SimpleSerializable.h +++ b/unittests/mocks/SimpleSerializable.h @@ -1,8 +1,8 @@ #ifndef FSFW_TESTS_SIMPLESERIALIZABLE_H #define FSFW_TESTS_SIMPLESERIALIZABLE_H -#include "fsfw/serialize.h" #include "fsfw/osal/Endiness.h" +#include "fsfw/serialize.h" class SimpleSerializable : public SerializeIF { public: diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 2cbe6132..968d2b1e 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -13,7 +13,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { size_t len = 0; SECTION("Little Endian Normal") { - REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -23,7 +24,9 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Little Endian Simple") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE( + simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -35,7 +38,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { REQUIRE(simpleSer.serializeNe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); @@ -51,14 +55,18 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Big Endian Simple") { SECTION("Explicit") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE( + simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serializeNe(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); @@ -102,7 +110,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t len = buf.size(); SECTION("Little Endian Normal") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(ptr == buf.data() + 3); @@ -110,17 +119,20 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Little Endian Simple") { - REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, len, SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); } SECTION("Big Endian Normal") { SECTION("Explicit") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { REQUIRE(simpleSer.SerializeIF::deSerializeNe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); @@ -133,14 +145,18 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Big Endian Simple") { SECTION("Explicit") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), + SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeNe(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index 1bae5912..16883458 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -1,7 +1,9 @@ #include #include +#include #include "fsfw/tmtcpacket/ccsds/PacketId.h" +#include "fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h" #include "fsfw/tmtcpacket/ccsds/header.h" TEST_CASE("CCSDS Low Level", "[ccsds-ll]") { @@ -43,16 +45,73 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { REQUIRE(packetId.raw() == 0x1ff); REQUIRE(packetId.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(buf[0] == 0x1); - REQUIRE(buf[1] == 0xff); + CHECK(buf[0] == 0x1); + CHECK(buf[1] == 0xff); + } + + SECTION("Invalid Ser") { + REQUIRE(packetId.SerializeIF::serializeNe(buf.data(), 0) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(packetId.SerializeIF::serializeNe(buf.data(), 1) == SerializeIF::BUFFER_TOO_SHORT); + } + + SECTION("Invalid Deser") { + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), 1) == SerializeIF::STREAM_TOO_SHORT); + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), 0) == SerializeIF::STREAM_TOO_SHORT); } SECTION("From Raw") { auto newId = PacketId(ccsds::PacketType::TC, true, 0x2ff); uint16_t rawId = newId.raw(); - REQUIRE(rawId == 0x1aff); - REQUIRE(PacketId::fromRaw(rawId) == newId); + CHECK(rawId == 0x1aff); + CHECK(PacketId::fromRaw(rawId) == newId); + } + + SECTION("Deserialize") { + buf[0] = 0x1a; + buf[1] = 0xff; + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); + CHECK(packetId.apid == 0x2ff); + CHECK(packetId.packetType == ccsds::PacketType::TC); + CHECK(packetId.secHeaderFlag == true); } } -TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") {} +TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { + PacketSeqCtrl psc; + std::array buf{}; + SECTION("Basic") { + psc.seqFlags = ccsds::SequenceFlags::FIRST_SEGMENT; + psc.seqCount = static_cast(std::round(std::pow(2, 14) - 1)); + REQUIRE(psc.raw() == 0x7fff); + REQUIRE(psc.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(buf[0] == 0x7f); + CHECK(buf[1] == 0xff); + } + + SECTION("From Raw") { + auto newId = PacketSeqCtrl(ccsds::SequenceFlags::LAST_SEGMENT, + static_cast(std::round(std::pow(2, 14) - 2))); + uint16_t rawId = newId.raw(); + REQUIRE(rawId == 0xbffe); + CHECK(PacketSeqCtrl::fromRaw(rawId) == newId); + } + + SECTION("Deserialize") { + buf[0] = 0xbf; + buf[1] = 0xfe; + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(psc.seqFlags == ccsds::SequenceFlags::LAST_SEGMENT); + CHECK(psc.seqCount == static_cast(std::round(std::pow(2, 14) - 2))); + } + + SECTION("Invalid Ser") { + REQUIRE(psc.SerializeIF::serializeNe(buf.data(), 0) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(psc.SerializeIF::serializeNe(buf.data(), 1) == SerializeIF::BUFFER_TOO_SHORT); + } + + SECTION("Invalid Deser") { + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), 1) == SerializeIF::STREAM_TOO_SHORT); + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), 0) == SerializeIF::STREAM_TOO_SHORT); + } +} diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index 91122ef9..570e791b 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -5,8 +5,9 @@ #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" TEST_CASE("CCSDS Creator", "[ccsds-creator]") { - auto params = SpacePacketParams(PacketId(ccsds::PacketType::TC, true, 0x02), - PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); + auto packetId = PacketId(ccsds::PacketType::TC, true, 0x02); + auto psc = PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34); + auto params = SpacePacketParams(packetId, psc, 0x16); SpacePacketCreator base = SpacePacketCreator(params); std::array buf{}; uint8_t* bufPtr = buf.data(); @@ -21,15 +22,18 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { } SECTION("Basic Test") { - REQUIRE(base.isValid()); - REQUIRE(base.getApid() == 0x02); - REQUIRE(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); - REQUIRE(base.getVersion() == 0b000); - REQUIRE(base.getSequenceCount() == 0x34); - REQUIRE(base.getPacketDataLen() == 0x16); - REQUIRE(base.getPacketType() == ccsds::PacketType::TC); - REQUIRE(base.getPacketIdRaw() == 0x1802); - REQUIRE(base.getSerializedSize() == 6); + CHECK(base.isValid()); + CHECK(base); + CHECK(base.getApid() == 0x02); + CHECK(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); + CHECK(base.getVersion() == 0b000); + CHECK(base.getSequenceCount() == 0x34); + CHECK(base.getPacketDataLen() == 0x16); + CHECK(base.getPacketType() == ccsds::PacketType::TC); + CHECK(base.getPacketIdRaw() == 0x1802); + CHECK(base.getSerializedSize() == 6); + CHECK(base.getPacketSeqCtrl() == psc); + CHECK(base.getPacketId() == packetId); } SECTION("Deserialization Fails") { @@ -42,18 +46,18 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { SECTION("Raw Output") { REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); // TC, and secondary header flag is set -> 0b0001100 -> 0x18 - REQUIRE(buf[0] == 0x18); + CHECK(buf[0] == 0x18); // APID 0x02 - REQUIRE(buf[1] == 0x02); + CHECK(buf[1] == 0x02); // Sequence count is one byte value, so the only set bit here is the bit // from the Sequence flag argument, which is the second bit for // SequenceFlags.FIRST_SEGMENT - REQUIRE(buf[2] == 0x40); + CHECK(buf[2] == 0x40); // Sequence Count specified above - REQUIRE(buf[3] == 0x34); + CHECK(buf[3] == 0x34); // This byte and the next byte should be 22 big endian (packet length) - REQUIRE(buf[4] == 0x00); - REQUIRE(buf[5] == 0x16); + CHECK(buf[4] == 0x00); + CHECK(buf[5] == 0x16); } SECTION("All Ones Output") { @@ -63,19 +67,20 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { base.setDataLen(static_cast(std::pow(2, 16)) - 1); REQUIRE(base.isValid()); REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(buf[0] == 0x1F); - REQUIRE(buf[1] == 0xFF); - REQUIRE(buf[2] == 0xFF); - REQUIRE(buf[3] == 0xFF); - REQUIRE(buf[4] == 0xFF); - REQUIRE(buf[5] == 0xFF); + CHECK(buf[0] == 0x1F); + CHECK(buf[1] == 0xFF); + CHECK(buf[2] == 0xFF); + CHECK(buf[3] == 0xFF); + CHECK(buf[4] == 0xFF); + CHECK(buf[5] == 0xFF); } SECTION("Invalid APID") { - SpacePacketCreator invalid = SpacePacketCreator( + SpacePacketCreator creator = SpacePacketCreator( ccsds::PacketType::TC, true, 0xFFFF, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); - REQUIRE(not invalid.isValid()); - REQUIRE(invalid.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(not creator.isValid()); + REQUIRE(not creator); + REQUIRE(creator.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } SECTION("Invalid Seq Count") { diff --git a/unittests/tmtcservices/CMakeLists.txt b/unittests/tmtcservices/CMakeLists.txt new file mode 100644 index 00000000..5d1c1858 --- /dev/null +++ b/unittests/tmtcservices/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE +) diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp new file mode 100644 index 00000000..0374ece5 --- /dev/null +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -0,0 +1,3 @@ +#include + +TEST_CASE("TM Store Helper", "[tm-store-helper]") {} \ No newline at end of file