From 5355e637114f5160439aadf64b2d455adf1d06f6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:43:32 +0200 Subject: [PATCH] use result instead of retval --- src/fsfw/cfdp/definitions.h | 18 +-- src/fsfw/osal/common/TcpTmTcServer.h | 2 +- src/fsfw/returnvalues/HasReturnvaluesIF.h | 12 +- src/fsfw/tasks/FixedTimeslotTaskIF.h | 2 +- src/fsfw_tests/internal/osal/testMq.cpp | 8 +- .../serialize/IntTestSerialization.cpp | 14 +- unittests/CatchDefinitions.h | 5 - unittests/action/TestActionHelper.cpp | 10 +- unittests/cfdp/testCfdp.cpp | 28 ++-- unittests/container/RingBufferTest.cpp | 148 +++++++++--------- unittests/datapoollocal/DataSetTest.cpp | 46 +++--- .../datapoollocal/LocalPoolManagerTest.cpp | 140 ++++++++--------- .../datapoollocal/LocalPoolVariableTest.cpp | 20 +-- .../datapoollocal/LocalPoolVectorTest.cpp | 16 +- unittests/globalfunctions/testDleEncoder.cpp | 4 +- .../TestInternalErrorReporter.cpp | 2 +- unittests/osal/TestMessageQueue.cpp | 16 +- unittests/osal/TestSemaphore.cpp | 4 +- .../serialize/TestSerialBufferAdapter.cpp | 2 +- .../serialize/TestSerialLinkedPacket.cpp | 4 +- unittests/storagemanager/TestNewAccessor.cpp | 42 ++--- unittests/storagemanager/TestPool.cpp | 58 +++---- 22 files changed, 298 insertions(+), 303 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 93d15bcb..7e023881 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -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/ diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index ae3fce39..1181ff10 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -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; diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index 4d59c26b..20c10e0b 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -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(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); } }; diff --git a/src/fsfw/tasks/FixedTimeslotTaskIF.h b/src/fsfw/tasks/FixedTimeslotTaskIF.h index 6a552d81..c7b90ec3 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskIF.h +++ b/src/fsfw/tasks/FixedTimeslotTaskIF.h @@ -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. diff --git a/src/fsfw_tests/internal/osal/testMq.cpp b/src/fsfw_tests/internal/osal/testMq.cpp index 30b46d63..3d8e1034 100644 --- a/src/fsfw_tests/internal/osal/testMq.cpp +++ b/src/fsfw_tests/internal/osal/testMq.cpp @@ -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) { diff --git a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp index 1e2a385c..5865f8fc 100644 --- a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp +++ b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp @@ -13,18 +13,18 @@ std::array 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; } diff --git a/unittests/CatchDefinitions.h b/unittests/CatchDefinitions.h index f0189602..dbe3848b 100644 --- a/unittests/CatchDefinitions.h +++ b/unittests/CatchDefinitions.h @@ -5,11 +5,6 @@ #include #include -namespace retval { -static constexpr int CATCH_OK = static_cast(HasReturnvaluesIF::RETURN_OK); -static constexpr int CATCH_FAILED = static_cast(HasReturnvaluesIF::RETURN_FAILED); -} // namespace retval - namespace tconst { static constexpr MessageQueueId_t testQueueId = 42; } diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index 6461a195..0d160c6f 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -19,12 +19,12 @@ TEST_CASE("Action Helper", "[ActionHelper]") { StorageManagerIF* ipcStore = tglob::getIpcStoreHandle(); REQUIRE(ipcStore != nullptr); ipcStore->addData(¶mAddress, 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 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(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(HasReturnvaluesIF::RETURN_OK)); diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 78ef618b..e7acab01 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -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(&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()); diff --git a/unittests/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp index f4f111a6..edabfd55 100644 --- a/unittests/container/RingBufferTest.cpp +++ b/unittests/container/RingBufferTest.cpp @@ -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); } } diff --git a/unittests/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/DataSetTest.cpp index c9f023ef..45085eaf 100644 --- a/unittests/datapoollocal/DataSetTest.cpp +++ b/unittests/datapoollocal/DataSetTest.cpp @@ -16,8 +16,8 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(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 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); } diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp index 58a6065e..4fc67c97 100644 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittests/datapoollocal/LocalPoolManagerTest.cpp @@ -18,8 +18,8 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(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(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(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(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(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(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*>(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(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* poolVar = dynamic_cast*>(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(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(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); CommandMessageCleaner::clearCommandMessage(&messageSent); REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == static_cast(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); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); 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(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); /* For non-diagnostics and a specified minimum frequency of 0.2 seconds, the resulting collection interval should be 1.0 second */ CHECK(poolOwner->dataset.getCollectionInterval() == 1.0); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); /* Now HK packet should be sent as message. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); sid_t sidToCheck; store_address_t storeId; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); @@ -330,7 +330,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* We still expect a failure message being sent */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); @@ -338,68 +338,68 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); 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, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); gp_id_t gpidToCheck; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, storeId::INVALID_STORE_ADDRESS); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, storeId::INVALID_STORE_ADDRESS); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); @@ -408,6 +408,6 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* 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); poolOwnerMock->clearMessages(true); } diff --git a/unittests/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/LocalPoolVariableTest.cpp index 3479cdbe..e9bed9ed 100644 --- a/unittests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittests/datapoollocal/LocalPoolVariableTest.cpp @@ -11,23 +11,23 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { auto* poolOwner = ObjectManager::instance()->get(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); SECTION("Basic Tests") { /* very basic test. */ lp_var_t testVariable = lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.read() == result::OK); CHECK(testVariable.value == 0); testVariable.value = 5; - REQUIRE(testVariable.commit() == retval::CATCH_OK); - REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.commit() == result::OK); + REQUIRE(testVariable.read() == result::OK); REQUIRE(testVariable.value == 5); CHECK(not testVariable.isValid()); testVariable.setValid(true); CHECK(testVariable.isValid()); - CHECK(testVariable.commit(true) == retval::CATCH_OK); + CHECK(testVariable.commit(true) == result::OK); testVariable.setReadWriteMode(pool_rwm_t::VAR_READ); CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ); @@ -43,7 +43,7 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t testVariable2 = lp_var_t(globPoolId); - REQUIRE(testVariable2.read() == retval::CATCH_OK); + REQUIRE(testVariable2.read() == result::OK); CHECK(testVariable2 == 5); CHECK(testVariable == testVariable2); testVariable = 10; @@ -55,12 +55,12 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { CHECK(maxSize == 1); size_t serSize = 0; CHECK(testVariable.serialize(&varPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(variableRaw == 10); const uint8_t* varConstPtr = &variableRaw; testVariable = 5; CHECK(testVariable.deSerialize(&varConstPtr, &serSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(testVariable == 10); CHECK(testVariable != testVariable2); CHECK(testVariable2 < testVariable); @@ -107,5 +107,5 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { lp_var_t invalidObjectVar3 = lp_var_t(nullptr, lpool::uint8VarId); } - CHECK(poolOwner->reset() == retval::CATCH_OK); + CHECK(poolOwner->reset() == result::OK); } diff --git a/unittests/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/LocalPoolVectorTest.cpp index 2235ad39..ddf6da9b 100644 --- a/unittests/datapoollocal/LocalPoolVectorTest.cpp +++ b/unittests/datapoollocal/LocalPoolVectorTest.cpp @@ -11,26 +11,26 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(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); SECTION("BasicTest") { // very basic test. lp_vec_t testVector = lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); - REQUIRE(testVector.read() == retval::CATCH_OK); + REQUIRE(testVector.read() == result::OK); testVector.value[0] = 5; testVector.value[1] = 232; testVector.value[2] = 32023; - REQUIRE(testVector.commit(true) == retval::CATCH_OK); + REQUIRE(testVector.commit(true) == result::OK); CHECK(testVector.isValid()); testVector.value[0] = 0; testVector.value[1] = 0; testVector.value[2] = 0; - CHECK(testVector.read() == retval::CATCH_OK); + CHECK(testVector.read() == result::OK); CHECK(testVector.value[0] == 5); CHECK(testVector.value[1] == 232); CHECK(testVector.value[2] == 32023); @@ -41,7 +41,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { (we can't throw exceptions) */ testVector[4] = 12; CHECK(testVector[2] == 12); - CHECK(testVector.commit() == retval::CATCH_OK); + CHECK(testVector.commit() == result::OK); /* Use read-only reference. */ const lp_vec_t& roTestVec = testVector; @@ -58,7 +58,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { uint8_t* vecPtr = reinterpret_cast(serializedVector); size_t serSize = 0; REQUIRE(testVector.serialize(&vecPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(serSize == 6); CHECK(serializedVector[0] == 5); @@ -75,7 +75,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { const uint8_t* constVecPtr = reinterpret_cast(serializedVector); REQUIRE(testVector.deSerialize(&constVecPtr, &serSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(testVector[0] == 16); CHECK(testVector[1] == 7832); CHECK(testVector[2] == 39232); diff --git a/unittests/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp index 0c707f4c..fc4d79bf 100644 --- a/unittests/globalfunctions/testDleEncoder.cpp +++ b/unittests/globalfunctions/testDleEncoder.cpp @@ -60,7 +60,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.encode(vecToEncode.data(), vecToEncode.size(), buffer.data(), buffer.size(), &encodedLen); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); for (size_t idx = 0; idx < expectedVec.size(); idx++) { REQUIRE(buffer[idx] == expectedVec[idx]); } @@ -71,7 +71,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.decode(testVecEncoded.data(), testVecEncoded.size(), &readLen, buffer.data(), buffer.size(), &decodedLen); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(readLen == testVecEncoded.size()); REQUIRE(decodedLen == expectedVec.size()); for (size_t idx = 0; idx < decodedLen; idx++) { diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index 2b999fae..b61a6203 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -38,7 +38,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { CommandMessage message; ActionMessage::setCompletionReply(&message, 10, true); auto result = hkQueue->sendMessage(testQueue->getId(), &message); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); uint32_t queueHits = 0; uint32_t lostTm = 0; uint32_t storeHits = 0; diff --git a/unittests/osal/TestMessageQueue.cpp b/unittests/osal/TestMessageQueue.cpp index df15b33d..b1792a9c 100644 --- a/unittests/osal/TestMessageQueue.cpp +++ b/unittests/osal/TestMessageQueue.cpp @@ -19,17 +19,17 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { SECTION("Simple Tests") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); CHECK(senderId == testSenderMqId); senderId = testReceiverMq->getLastPartner(); @@ -37,7 +37,7 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { } SECTION("Test Full") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); REQUIRE(result == MessageQueueIF::FULL); // We try another message @@ -45,12 +45,12 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { REQUIRE(result == MessageQueueIF::FULL); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); } // We have to clear MQs ourself ATM diff --git a/unittests/osal/TestSemaphore.cpp b/unittests/osal/TestSemaphore.cpp index 6988af5b..376b08db 100644 --- a/unittests/osal/TestSemaphore.cpp +++ b/unittests/osal/TestSemaphore.cpp @@ -19,7 +19,7 @@ TEST_CASE("Binary Semaphore Test" , "[BinSemaphore]") { REQUIRE(binSemaph->release() == static_cast(SemaphoreIF::SEMAPHORE_NOT_OWNED)); REQUIRE(binSemaph->acquire(SemaphoreIF::POLLING) == - retval::CATCH_OK); + result::OK); { // not precise enough on linux.. should use clock instead.. //Stopwatch stopwatch(false); @@ -29,7 +29,7 @@ TEST_CASE("Binary Semaphore Test" , "[BinSemaphore]") { //CHECK(time == 5); } REQUIRE(binSemaph->getSemaphoreCounter() == 0); - REQUIRE(binSemaph->release() == retval::CATCH_OK); + REQUIRE(binSemaph->release() == result::OK); } SemaphoreFactory::instance()->deleteSemaphore(binSemaph); // perform tear-down here diff --git a/unittests/serialize/TestSerialBufferAdapter.cpp b/unittests/serialize/TestSerialBufferAdapter.cpp index 2aa76ec8..2a8fe68c 100644 --- a/unittests/serialize/TestSerialBufferAdapter.cpp +++ b/unittests/serialize/TestSerialBufferAdapter.cpp @@ -102,7 +102,7 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { size_t size = 6; auto result = tv_serial_buffer_adapter3.deSerialize(const_cast(&arrayPtr), &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(test_recv_array[0] == 1); CHECK(test_recv_array[1] == 1); CHECK(test_recv_array[2] == 1); diff --git a/unittests/serialize/TestSerialLinkedPacket.cpp b/unittests/serialize/TestSerialLinkedPacket.cpp index 2d6e476f..863c77a9 100644 --- a/unittests/serialize/TestSerialLinkedPacket.cpp +++ b/unittests/serialize/TestSerialLinkedPacket.cpp @@ -41,7 +41,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // Deserialize big endian packet by setting bigEndian to true. ReturnValue_t result = testClass.deSerialize(&readOnlyPointer, &packetLen, SerializeIF::Endianness::BIG); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testClass.getHeader() == 42); // Equivalent check. // CHECK(testClass.getBuffer()[0] == 1); @@ -60,7 +60,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // serialize for ground: bigEndian = true. ReturnValue_t result = testClass.serialize(&packetPointer, &serializedSize, packetMaxSize, SerializeIF::Endianness::BIG); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Result should be big endian now. CHECK(packet[3] == 42); CHECK(packet[4] == 1); diff --git a/unittests/storagemanager/TestNewAccessor.cpp b/unittests/storagemanager/TestNewAccessor.cpp index 2cc2e469..311ba44d 100644 --- a/unittests/storagemanager/TestNewAccessor.cpp +++ b/unittests/storagemanager/TestNewAccessor.cpp @@ -12,7 +12,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result = result::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; @@ -21,9 +21,9 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Simple tests getter functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); auto resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); CHECK(resultPair.second.getId() == testStoreId); CHECK(resultPair.second.size() == 10); @@ -39,18 +39,18 @@ TEST_CASE("New Accessor", "[NewAccessor]") { { auto resultPairLoc = SimplePool.getData(testStoreId); - REQUIRE(resultPairLoc.first == retval::CATCH_OK); + REQUIRE(resultPairLoc.first == result::OK); // data should be deleted when accessor goes out of scope. } resultPair = SimplePool.getData(testStoreId); REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { ConstStorageAccessor constAccessor(testStoreId); result = SimplePool.getData(testStoreId, constAccessor); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); constAccessor.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -63,12 +63,12 @@ TEST_CASE("New Accessor", "[NewAccessor]") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); { resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); resultPair.second.release(); // now data should not be deleted anymore } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -77,11 +77,11 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Simple tests modify functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { StorageAccessor accessor(testStoreId); result = SimplePool.modifyData(testStoreId, accessor); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(accessor.getId() == testStoreId); CHECK(accessor.size() == 10); accessor.getDataCopy(receptionArray.data(), 20); @@ -98,10 +98,10 @@ TEST_CASE("New Accessor", "[NewAccessor]") { REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { auto resultPairLoc = SimplePool.modifyData(testStoreId); - REQUIRE(resultPairLoc.first == retval::CATCH_OK); + REQUIRE(resultPairLoc.first == result::OK); CHECK(resultPairLoc.second.getId() == testStoreId); CHECK(resultPairLoc.second.size() == 10); resultPairLoc.second.getDataCopy(receptionArray.data(), 20); @@ -117,22 +117,22 @@ TEST_CASE("New Accessor", "[NewAccessor]") { // data should not be deleted when accessor goes out of scope } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); } SECTION("Write tests") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); testDataArray[9] = 42; resultPair.second.write(testDataArray.data(), 10, 0); // now data should not be deleted resultPair.second.release(); } auto resultConstPair = SimplePool.getData(testStoreId); - REQUIRE(resultConstPair.first == retval::CATCH_OK); + REQUIRE(resultConstPair.first == result::OK); resultConstPair.second.getDataCopy(receptionArray.data(), 10); for (size_t i = 0; i < size - 1; i++) { @@ -141,15 +141,15 @@ TEST_CASE("New Accessor", "[NewAccessor]") { CHECK(receptionArray[9] == 42); auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); result = resultPair.second.write(testDataArray.data(), 20, 0); - REQUIRE(result == retval::CATCH_FAILED); + REQUIRE(result == result::FAILED); result = resultPair.second.write(testDataArray.data(), 10, 5); - REQUIRE(result == retval::CATCH_FAILED); + REQUIRE(result == result::FAILED); std::memset(testDataArray.data(), 42, 5); result = resultPair.second.write(testDataArray.data(), 5, 5); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); resultConstPair = SimplePool.getData(testStoreId); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 5; i < 10; i++) { @@ -159,7 +159,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Operators") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { StorageAccessor accessor(testStoreId); StorageAccessor accessor2(0); diff --git a/unittests/storagemanager/TestPool.cpp b/unittests/storagemanager/TestPool.cpp index e37c6934..f3c4f330 100644 --- a/unittests/storagemanager/TestPool.cpp +++ b/unittests/storagemanager/TestPool.cpp @@ -13,7 +13,7 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result = result::FAILED; uint8_t* pointer = nullptr; const uint8_t* constPointer = nullptr; @@ -24,9 +24,9 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Basic tests") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -34,12 +34,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { memset(receptionArray.data(), 0, size); result = simplePool.modifyData(testStoreId, &pointer, &size); memcpy(receptionArray.data(), pointer, size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), 15); CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE); } @@ -47,12 +47,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Reservation Tests ") { pointer = nullptr; result = simplePool.getFreeElement(&testStoreId, size, &pointer); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(pointer, testDataArray.data(), size); constPointer = nullptr; result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -61,21 +61,21 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Add, delete, add, add when full") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -102,20 +102,20 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Initialize and clear store, delete with pointer") { result = simplePool.initialize(); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); simplePool.clearStore(); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.modifyData(testStoreId, &pointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); store_address_t newId; result = simplePool.deleteData(pointer, size, &testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(testStoreId.raw != (uint32_t)StorageManagerIF::INVALID_ADDRESS); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); } } @@ -141,7 +141,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result = result::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; } @@ -150,20 +150,20 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { SECTION("Basic tests") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on second page of the pool now for 8 bytes CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 0); size = 15; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 0); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 1); @@ -174,7 +174,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should still work CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 1); @@ -182,7 +182,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { // fill the rest of the pool for (uint8_t idx = 2; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } @@ -203,21 +203,21 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } size = 20; for (uint8_t idx = 0; idx < 2; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == idx); } @@ -244,7 +244,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } @@ -261,7 +261,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); }