use result instead of retval

This commit is contained in:
Robin Müller 2022-07-27 21:43:32 +02:00
parent 88ebb67c8d
commit 5355e63711
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
22 changed files with 298 additions and 303 deletions

View File

@ -16,27 +16,27 @@ static constexpr uint8_t VERSION_BITS = 0b00100000;
static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP;
static constexpr ReturnValue_t INVALID_TLV_TYPE =
retval::makeCode(CFDP_CLASS_ID, 1);
result::makeCode(CFDP_CLASS_ID, 1);
static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS =
retval::makeCode(CFDP_CLASS_ID, 2);
result::makeCode(CFDP_CLASS_ID, 2);
static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN =
retval::makeCode(CFDP_CLASS_ID, 3);
result::makeCode(CFDP_CLASS_ID, 3);
static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS =
retval::makeCode(CFDP_CLASS_ID, 4);
result::makeCode(CFDP_CLASS_ID, 4);
//! Can not parse options. This can also occur because there are options
//! available but the user did not pass a valid options array
static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS =
retval::makeCode(CFDP_CLASS_ID, 5);
result::makeCode(CFDP_CLASS_ID, 5);
static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS =
retval::makeCode(CFDP_CLASS_ID, 6);
result::makeCode(CFDP_CLASS_ID, 6);
static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES =
retval::makeCode(CFDP_CLASS_ID, 6);
result::makeCode(CFDP_CLASS_ID, 6);
static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE =
retval::makeCode(CFDP_CLASS_ID, 8);
result::makeCode(CFDP_CLASS_ID, 8);
//! Can not parse filestore response because user did not pass a valid instance
//! or remaining size is invalid
static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE =
retval::makeCode(CFDP_CLASS_ID, 9);
result::makeCode(CFDP_CLASS_ID, 9);
//! Checksum types according to the SANA Checksum Types registry
//! https://sanaregistry.org/r/checksum_identifiers/

View File

@ -108,7 +108,7 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb
StorageManagerIF* tmStore = nullptr;
private:
static constexpr ReturnValue_t CONN_BROKEN = retval::makeCode(1, 0);
static constexpr ReturnValue_t CONN_BROKEN = result::makeCode(1, 0);
//! TMTC bridge is cached.
object_id_t tmtcBridgeId = objects::NO_OBJECT;
TcpTmTcBridge* tmtcBridge = nullptr;

View File

@ -10,19 +10,19 @@
#define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number))
typedef uint16_t ReturnValue_t;
namespace retval {
namespace result {
static constexpr ReturnValue_t OK = 0;
static constexpr ReturnValue_t FAILED = 1;
static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) {
return (static_cast<ReturnValue_t>(classId) << 8) + number;
}
} // namespace retval
} // namespace result
class HasReturnvaluesIF {
public:
static const ReturnValue_t RETURN_OK = retval::OK;
static const ReturnValue_t RETURN_FAILED = retval::FAILED;
static const ReturnValue_t RETURN_OK = result::OK;
static const ReturnValue_t RETURN_FAILED = result::FAILED;
virtual ~HasReturnvaluesIF() = default;
@ -33,9 +33,9 @@ class HasReturnvaluesIF {
* @param number
* @return
*/
[[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode(
[[deprecated("Use result::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode(
uint8_t classId, uint8_t number) {
return retval::makeCode(classId, number);
return result::makeCode(classId, number);
}
};

View File

@ -15,7 +15,7 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF {
~FixedTimeslotTaskIF() override = default;
static constexpr ReturnValue_t SLOT_LIST_EMPTY =
retval::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0);
result::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0);
/**
* Add an object with a slot time and the execution step to the task.

View File

@ -20,22 +20,22 @@ void testmq::testMq() {
testSenderMq->setDefaultDestination(testReceiverMqId);
auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage);
if (result != retval::OK) {
if (result != result::OK) {
unitt::put_error(id);
}
MessageQueueMessage recvMessage;
result = testReceiverMq->receiveMessage(&recvMessage);
if (result != retval::OK or recvMessage.getData()[0] != 42) {
if (result != result::OK or recvMessage.getData()[0] != 42) {
unitt::put_error(id);
}
result = testSenderMq->sendMessage(testReceiverMqId, &testMessage);
if (result != retval::OK) {
if (result != result::OK) {
unitt::put_error(id);
}
MessageQueueId_t senderId = 0;
result = testReceiverMq->receiveMessage(&recvMessage, &senderId);
if (result != retval::OK or recvMessage.getData()[0] != 42) {
if (result != result::OK or recvMessage.getData()[0] != 42) {
unitt::put_error(id);
}
if (senderId != testSenderMqId) {

View File

@ -13,18 +13,18 @@ std::array<uint8_t, 512> testserialize::test_array = {0};
ReturnValue_t testserialize::test_serialization() {
// Here, we test all serialization tools. First test basic cases.
ReturnValue_t result = test_endianness_tools();
if (result != retval::OK) {
if (result != result::OK) {
return result;
}
result = test_autoserialization();
if (result != retval::OK) {
if (result != result::OK) {
return result;
}
result = test_serial_buffer_adapter();
if (result != retval::OK) {
if (result != result::OK) {
return result;
}
return retval::OK;
return result::OK;
}
ReturnValue_t testserialize::test_endianness_tools() {
@ -48,7 +48,7 @@ ReturnValue_t testserialize::test_endianness_tools() {
if (test_array[0] != 0 and test_array[1] != 1) {
return unitt::put_error(id);
}
return retval::OK;
return result::OK;
}
ReturnValue_t testserialize::test_autoserialization() {
@ -152,7 +152,7 @@ ReturnValue_t testserialize::test_autoserialization() {
}
// Check overflow
return retval::OK;
return result::OK;
}
// TODO: Also test for constant buffers.
@ -205,5 +205,5 @@ ReturnValue_t testserialize::test_serial_buffer_adapter() {
if (testUint16 != 16) {
return unitt::put_error(id);
}
return retval::OK;
return result::OK;
}

View File

@ -5,11 +5,6 @@
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/storagemanager/StorageManagerIF.h>
namespace retval {
static constexpr int CATCH_OK = static_cast<int>(HasReturnvaluesIF::RETURN_OK);
static constexpr int CATCH_FAILED = static_cast<int>(HasReturnvaluesIF::RETURN_FAILED);
} // namespace retval
namespace tconst {
static constexpr MessageQueueId_t testQueueId = 42;
}

View File

@ -19,12 +19,12 @@ TEST_CASE("Action Helper", "[ActionHelper]") {
StorageManagerIF* ipcStore = tglob::getIpcStoreHandle();
REQUIRE(ipcStore != nullptr);
ipcStore->addData(&paramAddress, testParams.data(), 3);
REQUIRE(actionHelper.initialize() == retval::CATCH_OK);
REQUIRE(actionHelper.initialize() == result::OK);
SECTION("Simple tests") {
ActionMessage::setCommand(&actionMessage, testActionId, paramAddress);
CHECK(not testDhMock.executeActionCalled);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK);
CHECK(testDhMock.executeActionCalled);
// No message is sent if everything is alright.
CHECK(not testMqMock.wasMessageSent());
@ -82,10 +82,10 @@ TEST_CASE("Action Helper", "[ActionHelper]") {
SECTION("Handle failed") {
store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS;
std::array<uint8_t, 5> toLongData = {5, 4, 3, 2, 1};
REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == retval::CATCH_OK);
REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == result::OK);
ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress);
CHECK(not testDhMock.executeActionCalled);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK);
REQUIRE(ipcStore->getData(toLongParamAddress).first ==
static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
CommandMessage testMessage;
@ -100,7 +100,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") {
SECTION("Missing IPC Data") {
ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS);
CHECK(not testDhMock.executeActionCalled);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK);
CommandMessage testMessage;
REQUIRE(testMqMock.receiveMessage(&testMessage) ==
static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));

View File

@ -29,10 +29,10 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
const uint8_t** dummyPtr = nullptr;
ReturnValue_t deserResult =
headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK);
REQUIRE(deserResult == retval::CATCH_FAILED);
REQUIRE(deserResult == result::FAILED);
deserResult = headerSerializer.serialize(nullptr, &serSize, serBuf.size(),
SerializeIF::Endianness::NETWORK);
REQUIRE(deserResult == retval::CATCH_FAILED);
REQUIRE(deserResult == result::FAILED);
REQUIRE(seqNum.getSerializedSize() == 1);
REQUIRE(headerSerializer.getPduDataFieldLen() == 0);
@ -62,7 +62,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
REQUIRE(serSize == 7);
// Only version bits are set
REQUIRE(serBuf[0] == 0b00100000);
@ -155,11 +155,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
REQUIRE(entityId == 0x00ff00ff);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff);
REQUIRE(result == retval::CATCH_FAILED);
REQUIRE(result == result::FAILED);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff);
REQUIRE(result == retval::CATCH_FAILED);
REQUIRE(result == result::FAILED);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff);
REQUIRE(result == retval::CATCH_FAILED);
REQUIRE(result == result::FAILED);
uint8_t oneByteSourceId = 32;
serTarget = &oneByteSourceId;
size_t deserLen = 1;
@ -197,7 +197,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0);
ReturnValue_t result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
REQUIRE(serBuf[1] == 0);
REQUIRE(serBuf[2] == 0);
// Entity and Transaction Sequence number are 1 byte large
@ -207,7 +207,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size());
ReturnValue_t serResult = headerDeser.parseData();
REQUIRE(serResult == retval::CATCH_OK);
REQUIRE(serResult == result::OK);
REQUIRE(headerDeser.getPduDataFieldLen() == 0);
REQUIRE(headerDeser.getHeaderSize() == 7);
REQUIRE(headerDeser.getWholePduSize() == 7);
@ -230,11 +230,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
headerSerializer.setPduType(cfdp::PduType::FILE_DATA);
headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT);
result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
serTarget = serBuf.data();
serSize = 0;
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
@ -242,7 +242,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size());
result = headerDeser.parseData();
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
// Everything except version bit flipped to one now
REQUIRE(serBuf[0] == 0x3f);
REQUIRE(serBuf[3] == 0b11001010);
@ -274,7 +274,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
serTarget = serBuf.data();
const uint8_t** serTargetConst = const_cast<const uint8_t**>(&serTarget);
result = headerDeser.parseData();
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
headerDeser.setData(nullptr, -1);
REQUIRE(headerDeser.getHeaderSize() == 0);
@ -286,7 +286,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") {
pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48);
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(result == result::OK);
REQUIRE(headerDeser.getWholePduSize() == 8);
headerDeser.setData(serBuf.data(), serBuf.size());

View File

@ -12,42 +12,42 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") {
SECTION("Simple Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK);
for (uint8_t i = 0; i < 5; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.availableWriteSpace() == 5);
ringBuffer.clear();
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 4) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK);
for (uint8_t i = 0; i < 4; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK);
for (uint8_t i = 0; i < 9; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.writeData(testData, 1024) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.writeData(nullptr, 5) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.writeData(testData, 1024) == result::FAILED);
REQUIRE(ringBuffer.writeData(nullptr, 5) == result::FAILED);
}
SECTION("Get Free Element Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 8) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 1);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 9);
uint8_t *testPtr = nullptr;
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED);
REQUIRE(ringBuffer.writeTillWrap() == 2);
// too many excess bytes.
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK);
REQUIRE(ringBuffer.getExcessBytes() == 3);
std::memcpy(testPtr, testData, 5);
ringBuffer.confirmBytesWritten(5);
@ -59,19 +59,19 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") {
}
SECTION("Read Remaining Test") {
REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 3) == result::OK);
REQUIRE(ringBuffer.getAvailableReadData() == 3);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED);
size_t trueSize = 0;
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
for (uint8_t i = 0; i < 3; i++) {
CHECK(readBuffer[i] == i);
}
trueSize = 0;
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED);
REQUIRE(trueSize == 0);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
}
}
@ -84,21 +84,21 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") {
SECTION("Simple Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK);
for (uint8_t i = 0; i < 5; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.availableWriteSpace() == 5);
ringBuffer.clear();
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 4) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK);
for (uint8_t i = 0; i < 4; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK);
for (uint8_t i = 0; i < 9; i++) {
CHECK(readBuffer[i] == i);
}
@ -106,17 +106,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") {
SECTION("Get Free Element Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 8) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 1);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 9);
uint8_t *testPtr = nullptr;
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED);
REQUIRE(ringBuffer.writeTillWrap() == 2);
// too many excess bytes.
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK);
REQUIRE(ringBuffer.getExcessBytes() == 3);
std::memcpy(testPtr, testData, 5);
ringBuffer.confirmBytesWritten(5);
@ -128,19 +128,19 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") {
}
SECTION("Read Remaining Test") {
REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 3) == result::OK);
REQUIRE(ringBuffer.getAvailableReadData() == 3);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED);
size_t trueSize = 0;
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
for (uint8_t i = 0; i < 3; i++) {
CHECK(readBuffer[i] == i);
}
trueSize = 0;
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED);
REQUIRE(trueSize == 0);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
}
@ -148,17 +148,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
// We don't allow writing of Data that is larger than the ring buffer in total
REQUIRE(ringBuffer.getMaxSize() == 9);
REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED);
REQUIRE(ringBuffer.getAvailableReadData() == 0);
ringBuffer.clear();
uint8_t *ptr = nullptr;
// With excess Bytes 13 Bytes can be written to this Buffer
REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK);
REQUIRE(ptr != nullptr);
memcpy(ptr, testData, 13);
ringBuffer.confirmBytesWritten(13);
REQUIRE(ringBuffer.getAvailableReadData() == 3);
REQUIRE(ringBuffer.readData(readBuffer, 3, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK);
for (auto i = 0; i < 3; i++) {
REQUIRE(readBuffer[i] == testData[i + 10]);
}
@ -173,21 +173,21 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") {
SECTION("Simple Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK);
for (uint8_t i = 0; i < 5; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.availableWriteSpace() == 5);
ringBuffer.clear();
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 4) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK);
for (uint8_t i = 0; i < 4; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK);
for (uint8_t i = 0; i < 9; i++) {
CHECK(readBuffer[i] == i);
}
@ -195,19 +195,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") {
SECTION("Get Free Element Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 8) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 1);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 9);
uint8_t *testPtr = nullptr;
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::OK);
REQUIRE(ringBuffer.getExcessBytes() == 8);
REQUIRE(ringBuffer.writeTillWrap() == 2);
// too many excess bytes.
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED);
// Less Execss bytes overwrites before
REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == result::OK);
REQUIRE(ringBuffer.getExcessBytes() == 1);
std::memcpy(testPtr, testData, 3);
ringBuffer.confirmBytesWritten(3);
@ -219,19 +219,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") {
}
SECTION("Read Remaining Test") {
REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 3) == result::OK);
REQUIRE(ringBuffer.getAvailableReadData() == 3);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED);
size_t trueSize = 0;
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
for (uint8_t i = 0; i < 3; i++) {
CHECK(readBuffer[i] == i);
}
trueSize = 0;
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED);
REQUIRE(trueSize == 0);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
}
@ -239,18 +239,18 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
// Writing more than the buffer is large.
// This write will be rejected and is seen as a configuration mistake
REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED);
REQUIRE(ringBuffer.getAvailableReadData() == 0);
ringBuffer.clear();
// Using FreeElement allows the usage of excessBytes but
// should be used with caution
uint8_t *ptr = nullptr;
REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK);
REQUIRE(ptr != nullptr);
memcpy(ptr, testData, 13);
ringBuffer.confirmBytesWritten(13);
REQUIRE(ringBuffer.getAvailableReadData() == 3);
REQUIRE(ringBuffer.readData(readBuffer, 3, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK);
for (auto i = 0; i < 3; i++) {
REQUIRE(readBuffer[i] == testData[i + 10]);
}
@ -264,22 +264,22 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") {
SECTION("Simple Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK);
for (uint8_t i = 0; i < 5; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.availableWriteSpace() == 5);
ringBuffer.clear();
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 4) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK);
for (uint8_t i = 0; i < 4; i++) {
CHECK(readBuffer[i] == i);
}
REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 9) == result::OK);
REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK);
for (uint8_t i = 0; i < 9; i++) {
CHECK(readBuffer[i] == i);
}
@ -287,16 +287,16 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") {
SECTION("Get Free Element Test") {
REQUIRE(ringBuffer.availableWriteSpace() == 9);
REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 8) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 1);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK);
REQUIRE(ringBuffer.availableWriteSpace() == 9);
uint8_t *testPtr = nullptr;
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED);
REQUIRE(ringBuffer.writeTillWrap() == 2);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == retval::CATCH_OK);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::OK);
REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK);
REQUIRE(ringBuffer.getExcessBytes() == 3);
std::memcpy(testPtr, testData, 5);
ringBuffer.confirmBytesWritten(5);
@ -308,19 +308,19 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") {
}
SECTION("Read Remaining Test") {
REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK);
REQUIRE(ringBuffer.writeData(testData, 3) == result::OK);
REQUIRE(ringBuffer.getAvailableReadData() == 3);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED);
size_t trueSize = 0;
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
for (uint8_t i = 0; i < 3; i++) {
CHECK(readBuffer[i] == i);
}
trueSize = 0;
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED);
REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED);
REQUIRE(trueSize == 0);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK);
REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK);
REQUIRE(trueSize == 3);
}
}

View File

@ -16,8 +16,8 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
LocalPoolOwnerBase* poolOwner =
ObjectManager::instance()->get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner != nullptr);
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK);
REQUIRE(poolOwner->initializeHkManager() == result::OK);
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK);
LocalPoolStaticTestDataSet localSet;
SECTION("BasicTest") {
@ -36,7 +36,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
/* Test local pool ID serialization */
CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize,
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
SerializeIF::Endianness::MACHINE) == result::OK);
CHECK(serSize == maxSize);
CHECK(localPoolIdBuff[0] == 3);
CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId());
@ -48,7 +48,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
serSize = 0;
CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize,
SerializeIF::Endianness::MACHINE,
false) == retval::CATCH_OK);
false) == result::OK);
CHECK(serSize == maxSize - sizeof(uint8_t));
CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId());
CHECK(lpIds[1] == localSet.localPoolVarFloat.getDataPoolId());
@ -57,7 +57,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
{
/* Test read operation. Values should be all zeros */
PoolReadGuard readHelper(&localSet);
REQUIRE(readHelper.getReadResult() == retval::CATCH_OK);
REQUIRE(readHelper.getReadResult() == result::OK);
CHECK(not localSet.isValid());
CHECK(localSet.localPoolVarUint8.value == 0);
CHECK(not localSet.localPoolVarUint8.isValid());
@ -90,7 +90,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
/* Now we read again and check whether our zeroed values were overwritten with
the values in the pool */
PoolReadGuard readHelper(&localSet);
REQUIRE(readHelper.getReadResult() == retval::CATCH_OK);
REQUIRE(readHelper.getReadResult() == result::OK);
CHECK(localSet.isValid());
CHECK(localSet.localPoolVarUint8.value == 232);
CHECK(localSet.localPoolVarUint8.isValid());
@ -110,7 +110,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
uint8_t buffer[maxSize + 1];
uint8_t* buffPtr = buffer;
CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) ==
retval::CATCH_OK);
result::OK);
uint8_t rawUint8 = buffer[0];
CHECK(rawUint8 == 232);
float rawFloat = 0.0;
@ -128,7 +128,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
std::memset(buffer, 0, sizeof(buffer));
const uint8_t* constBuffPtr = buffer;
CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize,
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
SerializeIF::Endianness::MACHINE) == result::OK);
/* Check whether deserialization was successfull */
CHECK(localSet.localPoolVarUint8.value == 0);
CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0));
@ -156,7 +156,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
serSize = 0;
buffPtr = buffer;
CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) ==
retval::CATCH_OK);
result::OK);
CHECK(rawUint8 == 232);
std::memcpy(&rawFloat, buffer + sizeof(uint8_t), sizeof(float));
CHECK(rawFloat == Catch::Approx(-2324.322));
@ -186,7 +186,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
sizeToDeserialize = maxSize;
constBuffPtr = buffer;
CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize,
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
SerializeIF::Endianness::MACHINE) == result::OK);
/* Check whether deserialization was successfull */
CHECK(localSet.localPoolVarUint8.value == 0);
CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0));
@ -213,10 +213,10 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
/* Register same variables again to get more than 8 registered variables */
for (uint8_t idx = 0; idx < 8; idx++) {
REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK);
REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK);
}
REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK);
REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == retval::CATCH_OK);
REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK);
REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == result::OK);
set.setValidityBufferGeneration(true);
{
@ -233,7 +233,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
uint8_t buffer[maxSize + 1];
uint8_t* buffPtr = buffer;
CHECK(set.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) ==
retval::CATCH_OK);
result::OK);
std::array<uint8_t, 2> validityBuffer;
std::memcpy(validityBuffer.data(), buffer + 9 + sizeof(uint16_t) * 3, 2);
/* The first 9 variables should be valid */
@ -251,7 +251,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
const uint8_t* constBuffPtr = buffer;
size_t sizeToDeSerialize = serSize;
CHECK(set.deSerialize(&constBuffPtr, &sizeToDeSerialize, SerializeIF::Endianness::MACHINE) ==
retval::CATCH_OK);
result::OK);
CHECK(localSet.localPoolVarUint8.isValid() == false);
CHECK(localSet.localPoolUint16Vec.isValid() == true);
}
@ -261,20 +261,20 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
SharedLocalDataSet sharedSet(sharedSetId, poolOwner, lpool::testSetId, 5);
localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE);
localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE);
CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK);
CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == retval::CATCH_OK);
CHECK(sharedSet.initialize() == retval::CATCH_OK);
CHECK(sharedSet.lockDataset() == retval::CATCH_OK);
CHECK(sharedSet.unlockDataset() == retval::CATCH_OK);
CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == result::OK);
CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == result::OK);
CHECK(sharedSet.initialize() == result::OK);
CHECK(sharedSet.lockDataset() == result::OK);
CHECK(sharedSet.unlockDataset() == result::OK);
{
// PoolReadGuard rg(&sharedSet);
// CHECK(rg.getReadResult() == retval::CATCH_OK);
// CHECK(rg.getReadResult() == result::OK);
localSet.localPoolVarUint8.value = 5;
localSet.localPoolUint16Vec.value[0] = 1;
localSet.localPoolUint16Vec.value[1] = 2;
localSet.localPoolUint16Vec.value[2] = 3;
CHECK(sharedSet.commit() == retval::CATCH_OK);
CHECK(sharedSet.commit() == result::OK);
}
sharedSet.setReadCommitProtectionBehaviour(true);
@ -282,5 +282,5 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
/* we need to reset the subscription list because the pool owner
is a global object. */
CHECK(poolOwner->reset() == retval::CATCH_OK);
CHECK(poolOwner->reset() == result::OK);
}

View File

@ -18,8 +18,8 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
LocalPoolOwnerBase* poolOwner =
ObjectManager::instance()->get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
REQUIRE(poolOwner != nullptr);
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK);
REQUIRE(poolOwner->initializeHkManager() == result::OK);
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK);
MessageQueueMockBase* poolOwnerMock = poolOwner->getMockQueueHandle();
REQUIRE(poolOwnerMock != nullptr);
@ -38,14 +38,14 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE);
/* Subscribe for message generation on update. */
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == result::OK);
/* Subscribe for an update message. */
poolOwner->dataset.setChanged(true);
/* Now the update message should be generated. */
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
REQUIRE(poolOwnerMock->wasMessageSent() == true);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
@ -53,27 +53,27 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
CHECK(poolOwner->dataset.hasChanged() == false);
/* Set changed again, result should be the same. */
poolOwner->dataset.setChanged(true);
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
/* Now subscribe for set update HK as well. */
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == result::OK);
poolOwner->dataset.setChanged(true);
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 2);
/* first message sent should be the update notification, considering
the internal list is a vector checked in insertion order. */
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::HK_REPORT));
/* Clear message to avoid memory leak, our mock won't do it for us (yet) */
CommandMessageCleaner::clearCommandMessage(&messageSent);
@ -83,7 +83,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
/* Set the variables in the set to certain values. These are checked later. */
{
PoolReadGuard readHelper(&poolOwner->dataset);
REQUIRE(readHelper.getReadResult() == retval::CATCH_OK);
REQUIRE(readHelper.getReadResult() == result::OK);
poolOwner->dataset.localPoolVarUint8.value = 5;
poolOwner->dataset.localPoolVarFloat.value = -12.242;
poolOwner->dataset.localPoolUint16Vec.value[0] = 2;
@ -92,7 +92,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
}
/* Subscribe for snapshot generation on update. */
REQUIRE(poolOwner->subscribeWrapperSetUpdateSnapshot() == retval::CATCH_OK);
REQUIRE(poolOwner->subscribeWrapperSetUpdateSnapshot() == result::OK);
poolOwner->dataset.setChanged(true);
/* Store current time, we are going to check the (approximate) time equality later */
@ -100,10 +100,10 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
Clock::getClock_timeval(&now);
/* Trigger generation of snapshot */
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
/* Check that snapshot was generated */
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_SET));
/* Now we deserialize the snapshot into a new dataset instance */
@ -113,7 +113,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
store_address_t storeId;
HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId);
ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId);
REQUIRE(accessorPair.first == retval::CATCH_OK);
REQUIRE(accessorPair.first == result::OK);
const uint8_t* readOnlyPtr = accessorPair.second.data();
size_t sizeToDeserialize = accessorPair.second.size();
CHECK(newSet.localPoolVarFloat.value == 0);
@ -123,7 +123,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
CHECK(newSet.localPoolUint16Vec.value[2] == 0);
/* Fill the dataset and timestamp */
REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize,
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
SerializeIF::Endianness::MACHINE) == result::OK);
/* Now we check that the snapshot is actually correct */
CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242));
CHECK(newSet.localPoolVarUint8 == 5);
@ -145,14 +145,14 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
REQUIRE(subscriptionIF != nullptr);
/* Subscribe for variable snapshot */
REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == retval::CATCH_OK);
REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == result::OK);
auto poolVar =
dynamic_cast<lp_var_t<uint8_t>*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId));
REQUIRE(poolVar != nullptr);
{
PoolReadGuard rg(poolVar);
CHECK(rg.getReadResult() == retval::CATCH_OK);
CHECK(rg.getReadResult() == result::OK);
poolVar->value = 25;
}
@ -161,7 +161,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
CCSDSTime::CDS_short timeCdsNow;
timeval now;
Clock::getClock_timeval(&now);
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
/* Check update snapshot was sent. */
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
@ -169,7 +169,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
/* Should have been reset. */
CHECK(poolVar->hasChanged() == false);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE));
/* Now we deserialize the snapshot into a new dataset instance */
@ -179,13 +179,13 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
store_address_t storeId;
HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId);
ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId);
REQUIRE(accessorPair.first == retval::CATCH_OK);
REQUIRE(accessorPair.first == result::OK);
const uint8_t* readOnlyPtr = accessorPair.second.data();
size_t sizeToDeserialize = accessorPair.second.size();
CHECK(varCopy.value == 0);
/* Fill the dataset and timestamp */
REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize,
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
SerializeIF::Endianness::MACHINE) == result::OK);
CHECK(varCopy.value == 25);
/* Now we check that both times are equal */
@ -202,30 +202,30 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
REQUIRE(subscriptionIF != nullptr);
/* Subscribe for variable update */
REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) == retval::CATCH_OK);
REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) == result::OK);
lp_var_t<uint8_t>* poolVar =
dynamic_cast<lp_var_t<uint8_t>*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId));
REQUIRE(poolVar != nullptr);
poolVar->setChanged(true);
REQUIRE(poolVar->hasChanged() == true);
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
/* Check update notification was sent. */
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
/* Should have been reset. */
CHECK(poolVar->hasChanged() == false);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
/* Now subscribe for the dataset update (HK and update) again with subscription interface */
REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT,
objects::HK_RECEIVER_MOCK,
false) == retval::CATCH_OK);
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
false) == result::OK);
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == result::OK);
poolOwner->dataset.setChanged(true);
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
/* Now two messages should be sent. */
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 2);
@ -233,17 +233,17 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
poolOwner->dataset.setChanged(true);
poolVar->setChanged(true);
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
/* Now three messages should be sent. */
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 3);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK);
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::HK_REPORT));
CommandMessageCleaner::clearCommandMessage(&messageSent);
REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == static_cast<int>(MessageQueueIF::EMPTY));
@ -254,70 +254,70 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") {
the temporal behaviour correctly the HK manager should generate a HK packet
immediately and the periodic helper depends on HK op function calls anyway instead of
using the clock, so we could also just call performHkOperation multiple times */
REQUIRE(poolOwner->subscribePeriodicHk(true) == retval::CATCH_OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(poolOwner->subscribePeriodicHk(true) == result::OK);
REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK);
/* Now HK packet should be sent as message immediately. */
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK);
CHECK(poolOwnerMock->popMessage() == result::OK);
LocalPoolDataSetBase* setHandle = poolOwner->getDataSetHandle(lpool::testSid);
REQUIRE(setHandle != nullptr);
CHECK(poolOwner->poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) ==
retval::CATCH_OK);
result::OK);
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK);
CHECK(poolOwnerMock->popMessage() == result::OK);
CHECK(setHandle->getReportingEnabled() == true);
CommandMessage hkCmd;
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false);
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK);
CHECK(setHandle->getReportingEnabled() == false);
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK);
CHECK(poolOwnerMock->popMessage() == result::OK);
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false);
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK);
CHECK(setHandle->getReportingEnabled() == true);
REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true);