all retval replacements

This commit is contained in:
Robin Müller 2022-08-22 16:35:53 +02:00
parent 9e5dddf79c
commit d12c59c8ac
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
27 changed files with 204 additions and 207 deletions

View File

@ -9,24 +9,24 @@ ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& addre
AcceptsTelecommandsIF& tcDest) {
for (const auto& dest : tcDestinations) {
if (dest.id == address) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
}
tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue());
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) {
auto accessorPair = cfg.tcStore.getData(currentMessage.getStorageId());
if (accessorPair.first != HasReturnvaluesIF::RETURN_OK) {
if (accessorPair.first != returnvalue::OK) {
return accessorPair.first;
}
ReturnValue_t result = pduReader.setData(accessorPair.second.data(), accessorPair.second.size());
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
result = pduReader.parseData();
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
cfdp::EntityId foundId;
@ -44,7 +44,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) {
}
// Packet was forwarded successfully, so do not delete it.
accessorPair.second.release();
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
const char* CfdpDistributor::getName() const { return "CFDP Distributor"; }

View File

@ -5,7 +5,7 @@
#include <vector>
#include "fsfw/cfdp/pdu/HeaderReader.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/tcdistribution/CfdpPacketChecker.h"
#include "fsfw/tcdistribution/TcDistributorBase.h"
#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h"
@ -61,8 +61,8 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF {
MessageQueueId_t queueId;
};
HeaderReader pduReader;
ReturnValue_t lastTcError = HasReturnvaluesIF::RETURN_OK;
ReturnValue_t lastTmError = HasReturnvaluesIF::RETURN_OK;
ReturnValue_t lastTcError = returnvalue::OK;
ReturnValue_t lastTmError = returnvalue::OK;
// I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think
// it is okay to accept the overhead here
std::vector<EntityInfo> tcDestinations;

View File

@ -61,4 +61,3 @@
//};
//
//#endif /* FSFW_CFDP_CFDPHANDLER_H_ */

View File

@ -23,30 +23,30 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() {
case TransactionStep::SENDING_FINISHED_PDU:
break;
}
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) {
if (p.packetListRef.full()) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
p.packetListRef.push_back(packet);
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
ReturnValue_t cfdp::DestHandler::initialize() {
if (p.tmStore == nullptr) {
p.tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (p.tmStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
}
if (p.tcStore == nullptr) {
p.tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (p.tcStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
}
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}

View File

@ -6,6 +6,7 @@ AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Ac
ReturnValue_t AckPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveReader::parseData();
if (result != returnvalue::OK) {
return result;
}
size_t currentIdx = FileDirectiveReader::getHeaderSize();
if (currentIdx + 2 > this->maxSize) {

View File

@ -12,13 +12,13 @@ size_t FileDirectiveCreator::getSerializedSize() const {
ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const {
if (buffer == nullptr or size == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
if (FileDirectiveCreator::getWholePduSize() > maxSize) {
return BUFFER_TOO_SHORT;
}
ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
@ -28,7 +28,7 @@ ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, si
**buffer = directiveCode;
*buffer += 1;
*size += 1;
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) {

View File

@ -7,7 +7,7 @@ cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return file
ReturnValue_t FileDirectiveReader::parseData() {
ReturnValue_t result = HeaderReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
if (this->getPduDataFieldLen() < 1) {
@ -21,7 +21,7 @@ ReturnValue_t FileDirectiveReader::parseData() {
return cfdp::INVALID_DIRECTIVE_FIELDS;
}
setFileDirective(static_cast<cfdp::FileDirectives>(pointers.rawPtr[currentIdx]));
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
size_t FileDirectiveReader::getHeaderSize() const {

View File

@ -12,7 +12,7 @@ HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t i
ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const {
if (buffer == nullptr or size == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
if (maxSize < this->getSerializedSize()) {
return BUFFER_TOO_SHORT;
@ -29,19 +29,19 @@ ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t ma
*buffer += 1;
*size += 4;
ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
size_t HeaderCreator::getSerializedSize() const {
@ -51,7 +51,7 @@ size_t HeaderCreator::getSerializedSize() const {
ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) {
// We could implement this, but I prefer dedicated classes
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
size_t HeaderCreator::getWholePduSize() const {

View File

@ -8,7 +8,7 @@ HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) { setData(pduB
ReturnValue_t HeaderReader::parseData() {
if (pointers.rawPtr == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
if (maxSize < 7) {
return SerializeIF::STREAM_TOO_SHORT;
@ -20,19 +20,19 @@ ReturnValue_t HeaderReader::parseData() {
cfdp::WidthInBytes widthSeqNum = getLenSeqNum();
seqNumRaw = static_cast<uint8_t *>(sourceIdRaw) + static_cast<uint8_t>(widthEntityIds);
destIdRaw = static_cast<uint8_t *>(seqNumRaw) + static_cast<uint8_t>(widthSeqNum);
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) {
if (dataPtr == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
if (maxSize_ < 7) {
return SerializeIF::STREAM_TOO_SHORT;
}
pointers.rawPtr = dataPtr;
maxSize = maxSize_;
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
size_t HeaderReader::getHeaderSize() const {

View File

@ -7,7 +7,7 @@
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/returnvalues/FwClassIds.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/returnvalues/returnvalue.h"
struct FilesystemParams {
explicit FilesystemParams(const char* path) : path(path) {}

View File

@ -36,7 +36,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) {
#endif
auto accessorPair = tcStore->getData(currentMessage.getStorageId());
ReturnValue_t result = accessorPair.first;
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
@ -64,7 +64,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) {
}
SpacePacketReader currentPacket(accessorPair.second.data(), accessorPair.second.size());
result = packetChecker->checkPacket(currentPacket, accessorPair.second.size());
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
handlePacketCheckFailure(result);
return result;
}
@ -90,7 +90,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) {
return handleCcsdsHeaderRemoval(accessorPair.second);
}
accessorPair.second.release();
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) {
@ -116,10 +116,10 @@ void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) {
MessageQueueId_t CcsdsDistributor::getRequestQueue() const { return tcQueue->getId(); }
ReturnValue_t CcsdsDistributor::registerApplication(DestInfo info) {
ReturnValue_t returnValue = RETURN_OK;
ReturnValue_t returnValue = returnvalue::OK;
auto insertPair = receiverMap.emplace(info.apid, info);
if (not insertPair.second) {
returnValue = RETURN_FAILED;
returnValue = returnvalue::FAILED;
}
return returnValue;
}
@ -128,7 +128,7 @@ uint32_t CcsdsDistributor::getIdentifier() const { return 0; }
ReturnValue_t CcsdsDistributor::initialize() {
ReturnValue_t result = TcDistributorBase::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
if (packetChecker == nullptr) {
@ -156,10 +156,10 @@ ReturnValue_t CcsdsDistributor::initialize() {
}
ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
if (queueStatus != RETURN_OK) {
if (queueStatus != returnvalue::OK) {
tcStore->deleteData(currentMessage.getStorageId());
}
return RETURN_OK;
return returnvalue::OK;
}
void CcsdsDistributor::print() {
@ -180,7 +180,7 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a
store_address_t newStoreId;
ReturnValue_t result = tcStore->addData(&newStoreId, accessor.data() + ccsds::HEADER_LEN,
accessor.size() - ccsds::HEADER_LEN);
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << __func__ << ": TC store full" << std::endl;
#else
@ -190,5 +190,5 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a
}
currentMessage.setStorageId(newStoreId);
// The const accessor will delete the old data automatically
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}

View File

@ -27,8 +27,8 @@ ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) {
// TODO: Need to set the data
const uint8_t* packetPtr = nullptr;
size_t packetLen = 0;
ReturnValue_t result = store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) !=
returnvalue::OK;
ReturnValue_t result =
store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK;
if (result != returnvalue::OK) {
tcStatus = PACKET_LOST;
return result;

View File

@ -20,11 +20,11 @@ TcDistributorBase::~TcDistributorBase() {
ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) {
ReturnValue_t status;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
for (status = tcQueue->receiveMessage(&currentMessage); status == RETURN_OK;
ReturnValue_t result = returnvalue::OK;
for (status = tcQueue->receiveMessage(&currentMessage); status == returnvalue::OK;
status = tcQueue->receiveMessage(&currentMessage)) {
ReturnValue_t packetResult = handlePacket();
if (packetResult != HasReturnvaluesIF::RETURN_OK) {
if (packetResult != returnvalue::OK) {
result = packetResult;
triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, 1);
}
@ -38,12 +38,12 @@ ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) {
ReturnValue_t TcDistributorBase::handlePacket() {
MessageQueueId_t destId;
ReturnValue_t result = selectDestination(destId);
if (result != HasReturnvaluesIF::RETURN_OK) {
if (result != returnvalue::OK) {
return result;
}
return callbackAfterSending(tcQueue->sendMessage(destId, &currentMessage));
}
ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) {
return RETURN_OK;
return returnvalue::OK;
}

View File

@ -10,7 +10,7 @@
namespace tmtcdistrib {
static const uint8_t INTERFACE_ID = CLASS_ID::TMTC_DISTRIBUTION;
static constexpr ReturnValue_t NO_DESTINATION_FOUND = result::makeCode(INTERFACE_ID, 0);
static constexpr ReturnValue_t NO_DESTINATION_FOUND = returnvalue::makeCode(INTERFACE_ID, 0);
static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(1);
static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(2);
static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3);

View File

@ -12,7 +12,7 @@ HostFilesystem::HostFilesystem() = default;
ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) {
if (params.path() == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
path path(params.path());
if (not exists(path)) {
@ -24,13 +24,13 @@ ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *da
}
file.seekp(static_cast<unsigned int>(params.offset));
file.write(reinterpret_cast<const char *>(data), static_cast<unsigned int>(params.size));
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize,
size_t maxSize) {
if (params.path() == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
path path(params.path());
if (not exists(path)) {
@ -48,13 +48,13 @@ ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer
file.read(reinterpret_cast<char *>(*buffer), sizeToRead);
readSize += sizeToRead;
*buffer += sizeToRead;
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t *data,
size_t size) {
if (params.path == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
path path(params.path);
if (exists(path)) {
@ -64,26 +64,26 @@ ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t
if (file.fail()) {
return HasFileSystemIF::GENERIC_FILE_ERROR;
}
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
ReturnValue_t HostFilesystem::removeFile(const char *path_, FileSystemArgsIF *args) {
if (path_ == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
path path(path_);
if (not exists(path)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
}
if (remove(path, errorCode)) {
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
return HasFileSystemIF::GENERIC_FILE_ERROR;
}
ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool createParentDirs) {
if (params.path == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
path dirPath(params.path);
@ -93,19 +93,19 @@ ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool crea
if (createParentDirs) {
if (create_directories(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
return HasFileSystemIF::GENERIC_DIR_ERROR;
}
if (create_directory(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
return HasFileSystemIF::GENERIC_DIR_ERROR;
}
ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool deleteRecurively) {
if (params.path == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
path dirPath(params.path);
if (not exists(dirPath)) {
@ -116,11 +116,11 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele
}
if (deleteRecurively) {
if (remove_all(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
} else {
if (remove(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}
}
// Error handling
@ -133,7 +133,7 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele
ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_,
FileSystemArgsIF *args) {
if (oldPath_ == nullptr or newPath_ == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
return returnvalue::FAILED;
}
path oldPath(oldPath_);
path newPath(newPath_);
@ -142,5 +142,5 @@ ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_,
if (errorCode) {
return HasFileSystemIF::GENERIC_RENAME_ERROR;
}
return HasReturnvaluesIF::RETURN_OK;
return returnvalue::OK;
}

View File

@ -36,41 +36,41 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
uint8_t* dataPtr = nullptr;
SECTION("State") {
CHECK(distributor.initialize() == result::OK);
CHECK(distributor.initialize() == returnvalue::OK);
CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0);
CHECK(distributor.getIdentifier() == 0);
CHECK(distributor.getRequestQueue() == queue.getId());
}
SECTION("Packet Forwarding") {
CHECK(distributor.initialize() == result::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK);
CHECK(distributor.initialize() == returnvalue::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK);
size_t serLen = 0;
store_address_t storeId;
CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) ==
result::OK);
returnvalue::OK);
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
result::OK);
returnvalue::OK);
TmTcMessage msg(storeId);
queue.addReceivedMessage(msg);
CHECK(distributor.performOperation(0) == result::OK);
CHECK(distributor.performOperation(0) == returnvalue::OK);
CHECK(queue.wasMessageSent());
CHECK(queue.numberOfSentMessages() == 1);
// The packet is forwarded, with no need to delete the data
CHECK(pool.hasDataAtId(storeId));
TmTcMessage sentMsg;
CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == result::OK);
CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == returnvalue::OK);
CHECK(sentMsg.getStorageId() == storeId);
}
SECTION("No Destination found") {
CHECK(distributor.initialize() == result::OK);
CHECK(distributor.initialize() == returnvalue::OK);
size_t serLen = 0;
store_address_t storeId;
CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) ==
result::OK);
returnvalue::OK);
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
result::OK);
returnvalue::OK);
TmTcMessage msg(storeId);
queue.addReceivedMessage(msg);
CHECK(distributor.performOperation(0) == tmtcdistrib::NO_DESTINATION_FOUND);
@ -81,19 +81,19 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
pool.nextModifyDataCallFails.second = StorageManagerIF::DATA_DOES_NOT_EXIST;
size_t serLen = 0;
store_address_t storeId;
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK);
CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) ==
result::OK);
returnvalue::OK);
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
result::OK);
returnvalue::OK);
TmTcMessage msg(storeId);
queue.addReceivedMessage(msg);
CHECK(distributor.performOperation(0) == StorageManagerIF::DATA_DOES_NOT_EXIST);
}
SECTION("Duplicate registration") {
CHECK(distributor.initialize() == result::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::FAILED);
CHECK(distributor.initialize() == returnvalue::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::FAILED);
}
}

View File

@ -3,7 +3,7 @@
#include "fsfw/cfdp/pdu/HeaderCreator.h"
#include "fsfw/cfdp/pdu/HeaderReader.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/returnvalues/returnvalue.h"
TEST_CASE("CFDP Header", "[cfdp]") {
using namespace cfdp;
@ -49,12 +49,12 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Deserialization fails") {
const uint8_t** dummyPtr = nullptr;
REQUIRE(headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) ==
result::FAILED);
returnvalue::FAILED);
}
SECTION("Serialization fails") {
REQUIRE(headerSerializer.serialize(nullptr, &serSize, serBuf.size(),
SerializeIF::Endianness::NETWORK) == result::FAILED);
SerializeIF::Endianness::NETWORK) == returnvalue::FAILED);
}
SECTION("Buffer Too Short") {
@ -93,7 +93,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Regular") {
// Everything except version bit flipped to one now
REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG) == result::OK);
SerializeIF::Endianness::BIG) == returnvalue::OK);
CHECK(serBuf[0] == 0x3f);
CHECK(serBuf[3] == 0x99);
REQUIRE(headerSerializer.getCrcFlag() == true);
@ -114,7 +114,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(pduConf.sourceId.getSerializedSize() == 4);
REQUIRE(headerSerializer.getSerializedSize() == 14);
REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG) == result::OK);
SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(headerSerializer.getCrcFlag() == true);
REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER);
REQUIRE(headerSerializer.getLargeFileFlag() == true);
@ -157,17 +157,17 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Invalid Variable Sized Fields") {
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff);
REQUIRE(result == result::FAILED);
REQUIRE(result == returnvalue::FAILED);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff);
REQUIRE(result == result::FAILED);
REQUIRE(result == returnvalue::FAILED);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff);
REQUIRE(result == result::FAILED);
REQUIRE(result == returnvalue::FAILED);
}
SECTION("Header Serialization") {
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG);
REQUIRE(result == result::OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(serSize == 7);
// Only version bits are set
REQUIRE(serBuf[0] == 0b00100000);
@ -216,7 +216,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Header Deserialization") {
REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG) == result::OK);
SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(serBuf[1] == 0);
REQUIRE(serBuf[2] == 0);
// Entity and Transaction Sequence number are 1 byte large
@ -226,7 +226,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
auto headerDeser = HeaderReader(serBuf.data(), serBuf.size());
ReturnValue_t serResult = headerDeser.parseData();
REQUIRE(serResult == result::OK);
REQUIRE(serResult == returnvalue::OK);
REQUIRE(headerDeser.getPduDataFieldLen() == 0);
REQUIRE(headerDeser.getHeaderSize() == 7);
REQUIRE(headerDeser.getWholePduSize() == 7);
@ -249,11 +249,11 @@ TEST_CASE("CFDP Header", "[cfdp]") {
headerSerializer.setPduType(cfdp::PduType::FILE_DATA);
headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT);
result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff);
REQUIRE(result == result::OK);
REQUIRE(result == returnvalue::OK);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00);
REQUIRE(result == result::OK);
REQUIRE(result == returnvalue::OK);
result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff);
REQUIRE(result == result::OK);
REQUIRE(result == returnvalue::OK);
serTarget = serBuf.data();
serSize = 0;
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
@ -261,7 +261,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
headerDeser = HeaderReader(serBuf.data(), serBuf.size());
result = headerDeser.parseData();
REQUIRE(result == result::OK);
REQUIRE(result == returnvalue::OK);
// Everything except version bit flipped to one now
REQUIRE(serBuf[0] == 0x3f);
REQUIRE(serBuf[3] == 0b11001010);
@ -293,9 +293,9 @@ TEST_CASE("CFDP Header", "[cfdp]") {
serTarget = serBuf.data();
const auto** serTargetConst = const_cast<const uint8_t**>(&serTarget);
result = headerDeser.parseData();
REQUIRE(result == result::OK);
REQUIRE(result == returnvalue::OK);
CHECK(headerDeser.setData(nullptr, -1) != result::OK);
CHECK(headerDeser.setData(nullptr, -1) != returnvalue::OK);
REQUIRE(headerDeser.getHeaderSize() == 14);
headerDeser.setData(serBuf.data(), serBuf.size());
@ -305,7 +305,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48);
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG);
REQUIRE(result == result::OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(headerDeser.getWholePduSize() == 8);
headerDeser.setData(serBuf.data(), serBuf.size());

View File

@ -23,7 +23,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
serTarget = serBuf.data();
serSize = 0;
result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
// Only version bits are set
REQUIRE(serBuf[0] == 0b00100000);
// PDU data field length is 5 (4 + Directive code octet)
@ -42,7 +42,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
SECTION("Serialization fails") {
REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_FAILED);
returnvalue::FAILED);
}
SECTION("Buffer Too Short") {
@ -56,11 +56,11 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
SECTION("Deserialize") {
CHECK(fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK) ==
result::OK);
returnvalue::OK);
serTarget = serBuf.data();
REQUIRE(fdSer.deSerialize(&deserTarget, &serSize, SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_FAILED);
returnvalue::FAILED);
deserTarget = serBuf.data();
CHECK(serSize == 8);
auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size());
@ -70,7 +70,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
fdDeser.setEndianness(SerializeIF::Endianness::MACHINE);
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE);
fdDeser.setEndianness(SerializeIF::Endianness::NETWORK);
REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(fdDeser.parseData() == returnvalue::OK);
REQUIRE(not fdDeser.isNull());
REQUIRE(fdDeser);
REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK);

View File

@ -5,7 +5,7 @@
TEST_CASE("CFDP LV", "[cfdp][lv]") {
using namespace cfdp;
ReturnValue_t result = result::OK;
ReturnValue_t result = returnvalue::OK;
std::array<uint8_t, 255> rawBuf{};
uint8_t* serPtr = rawBuf.data();
const uint8_t* deserPtr = rawBuf.data();
@ -16,7 +16,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
std::array<uint8_t, 8> lvRawBuf{};
serPtr = lvRawBuf.data();
REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK);
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(deserSize == 2);
auto lv = cfdp::Lv(lvRawBuf.data(), 2);
@ -31,12 +31,12 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
serPtr = rawBuf.data();
deserSize = 0;
REQUIRE(lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) ==
result::OK);
returnvalue::OK);
REQUIRE(deserSize == 3);
REQUIRE(rawBuf[0] == 2);
uint16_t sourceIdRaw = 0;
REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize,
SerializeIF::Endianness::BIG) == result::OK);
SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(sourceIdRaw == 0x0ff0);
}
@ -47,11 +47,11 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
deserSize = 0;
result =
lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(deserSize == 1);
deserPtr = rawBuf.data();
result = lvEmpty.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(lvEmpty.getSerializedSize() == 1);
}
@ -59,29 +59,29 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
std::array<uint8_t, 8> lvRawBuf{};
serPtr = lvRawBuf.data();
REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK);
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
auto lv = cfdp::Lv(lvRawBuf.data(), 2);
serPtr = rawBuf.data();
deserSize = 0;
result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
Lv uninitLv;
deserPtr = rawBuf.data();
deserSize = 3;
result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(uninitLv.getSerializedSize() == 3);
const uint8_t* storedValue = uninitLv.getValue(nullptr);
uint16_t sourceIdRaw = 0;
REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize,
SerializeIF::Endianness::BIG) == result::OK);
SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(sourceIdRaw == 0x0ff0);
}
SECTION("Invalid Input") {
Lv uninitLv;
REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) ==
HasReturnvaluesIF::RETURN_FAILED);
returnvalue::FAILED);
serPtr = rawBuf.data();
deserSize = 0;
REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) ==
@ -96,7 +96,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
std::string filename = "hello.txt";
StringLv sourceFileName(filename);
REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size());
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK);
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == returnvalue::OK);
REQUIRE(rawBuf[0] == filename.size());
std::string filenameFromRaw(reinterpret_cast<const char*>(rawBuf.data() + 1), filename.size());
REQUIRE(filenameFromRaw == filename);
@ -106,7 +106,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
const char filename[] = "hello.txt";
StringLv sourceFileName(filename, sizeof(filename) - 1);
REQUIRE(sourceFileName.getSerializedSize() == 1 + sizeof(filename) - 1);
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK);
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == returnvalue::OK);
REQUIRE(rawBuf[0] == sizeof(filename) - 1);
rawBuf[deserSize] = '\0';
const char* filenameFromRaw = reinterpret_cast<const char*>(rawBuf.data() + 1);

View File

@ -40,14 +40,14 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
std::array<uint8_t, 128> serBuf = {};
result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(),
SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
cfdp::StringLv emptyMsg;
cfdp::StringLv emptySecondName;
FilestoreResponseTlv emptyTlv(firstName, &emptyMsg);
emptyTlv.setSecondFileName(&emptySecondName);
result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS);
size_t firstNameLen = 0;
@ -81,26 +81,26 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
REQUIRE(expectedSz == 10 + 11 + 1);
REQUIRE(request.getSerializedSize() == expectedSz + 2);
result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(sz == expectedSz + 2);
FilestoreRequestTlv emptyRequest(firstName);
emptyRequest.setSecondFileName(&secondName);
const uint8_t* constptr = serBuf.data();
result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
cfdp::Tlv rawRequest;
ptr = serBuf.data();
sz = 0;
result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(),
SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE);
result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
}
@ -117,11 +117,11 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(faultOverrideTlv.getSerializedSize() == 3);
REQUIRE(sz == 3);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
FaultHandlerOverrideTlv emptyOverrideTlv;
result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42);
EntityId emptyId;
@ -129,9 +129,9 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
serPtr = rawBuf.data();
result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
deserPtr = rawBuf.data();
result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
}
}

View File

@ -14,25 +14,25 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
SECTION("Entity ID Serialization") {
REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK);
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(deserSize == 2);
}
SECTION("TLV Serialization") {
std::array<uint8_t, 8> tlvBuf{};
REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == result::OK);
REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == returnvalue::OK);
auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize);
REQUIRE(tlv.getSerializedSize() == 4);
REQUIRE(tlv.getLengthField() == 2);
deserSize = 0;
REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) ==
result::OK);
returnvalue::OK);
REQUIRE(deserSize == 4);
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
REQUIRE(rawBuf[1] == 2);
uint16_t entityId = 0;
REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize,
SerializeIF::Endianness::NETWORK) == result::OK);
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(entityId == 0x0ff0);
}
@ -41,30 +41,30 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
// Set new value
sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12);
REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK);
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
tlv.setValue(rawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES);
serPtr = rawBuf.data();
deserSize = 0;
result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
REQUIRE(rawBuf[1] == 4);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
}
SECTION("TLV Invalid") {
auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK);
SerializeIF::Endianness::NETWORK) != returnvalue::OK);
tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK);
SerializeIF::Endianness::NETWORK) != returnvalue::OK);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) !=
HasReturnvaluesIF::RETURN_OK);
returnvalue::OK);
REQUIRE(tlvInvalid.getSerializedSize() == 0);
REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) !=
HasReturnvaluesIF::RETURN_OK);
returnvalue::OK);
}
SECTION("TLV Zero Length Field") {
@ -73,8 +73,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
serPtr = rawBuf.data();
deserSize = 0;
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_OK);
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER);
REQUIRE(rawBuf[1] == 0);
}
@ -93,7 +92,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
Tlv tlv;
deserPtr = rawBuf.data();
result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(tlv.getSerializedSize() == 4);
REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID);
deserPtr = tlv.getValue();
@ -103,8 +102,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
SerializeIF::Endianness::NETWORK);
REQUIRE(entityId == 0x0ff0);
REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) !=
HasReturnvaluesIF::RETURN_OK);
REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != returnvalue::OK);
deserPtr = rawBuf.data();
deserSize = 0;
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) ==
@ -113,17 +111,16 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
rawBuf[0] = TlvTypes::INVALID_TLV;
deserSize = 4;
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) !=
HasReturnvaluesIF::RETURN_OK);
returnvalue::OK);
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
serPtr = rawBuf.data();
deserSize = 0;
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_OK);
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
deserPtr = rawBuf.data();
result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == returnvalue::OK);
REQUIRE(zeroLenField.getSerializedSize() == 2);
REQUIRE(deserSize == 0);
}

View File

@ -10,7 +10,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") {
SECTION("Create File") {
FilesystemParams params("hello.txt");
CHECK(fsMock.createFile(params) == result::OK);
CHECK(fsMock.createFile(params) == returnvalue::OK);
auto iter = fsMock.fileMap.find("hello.txt");
REQUIRE(iter != fsMock.fileMap.end());
FilesystemMock::FileInfo &stats = iter->second;
@ -22,7 +22,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") {
std::string testData = "test data";
FileOpParams params("hello.txt", testData.size());
CHECK(fsMock.writeToFile(params, reinterpret_cast<const uint8_t *>(testData.data())) ==
HasReturnvaluesIF::RETURN_OK);
returnvalue::OK);
auto iter = fsMock.fileMap.find("hello.txt");
REQUIRE(iter != fsMock.fileMap.end());
FilesystemMock::FileInfo &stats = iter->second;
@ -38,7 +38,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") {
SECTION("Create Directory") {
FilesystemParams params("hello");
CHECK(fsMock.createDirectory(params) == result::OK);
CHECK(fsMock.createDirectory(params) == returnvalue::OK);
REQUIRE(not fsMock.dirMap.empty());
auto iter = fsMock.dirMap.find("hello");
REQUIRE(iter != fsMock.dirMap.end());

View File

@ -23,51 +23,51 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
SECTION("Create file") {
FilesystemParams params(file0.c_str());
REQUIRE(hostFs.createFile(params) == result::OK);
REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0));
}
SECTION("Remove File") {
FilesystemParams params(file0.c_str());
REQUIRE(hostFs.createFile(params) == result::OK);
REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0));
REQUIRE(hostFs.removeFile(file0.c_str()) == result::OK);