Merge remote-tracking branch 'origin/mueller/expand-retval-if' into mueller/refactor-tmtc-stack
This commit is contained in:
commit
fb4ba487b5
@ -15,21 +15,28 @@ 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);
|
||||
static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = retval::makeCode(CFDP_CLASS_ID, 2);
|
||||
static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = retval::makeCode(CFDP_CLASS_ID, 3);
|
||||
static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = retval::makeCode(CFDP_CLASS_ID, 4);
|
||||
static constexpr ReturnValue_t INVALID_TLV_TYPE =
|
||||
result::makeCode(CFDP_CLASS_ID, 1);
|
||||
static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS =
|
||||
result::makeCode(CFDP_CLASS_ID, 2);
|
||||
static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN =
|
||||
result::makeCode(CFDP_CLASS_ID, 3);
|
||||
static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS =
|
||||
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);
|
||||
static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = retval::makeCode(CFDP_CLASS_ID, 6);
|
||||
static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS =
|
||||
result::makeCode(CFDP_CLASS_ID, 5);
|
||||
static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS =
|
||||
result::makeCode(CFDP_CLASS_ID, 6);
|
||||
static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES =
|
||||
retval::makeCode(CFDP_CLASS_ID, 6);
|
||||
static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = retval::makeCode(CFDP_CLASS_ID, 8);
|
||||
result::makeCode(CFDP_CLASS_ID, 6);
|
||||
static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE =
|
||||
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/
|
||||
|
@ -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;
|
||||
|
@ -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,8 +33,9 @@ class HasReturnvaluesIF {
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) {
|
||||
return retval::makeCode(classId, number);
|
||||
static constexpr ReturnValue_t makeReturnCode(
|
||||
uint8_t classId, uint8_t number) {
|
||||
return result::makeCode(classId, number);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -20,12 +20,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());
|
||||
@ -81,10 +81,10 @@ TEST_CASE("Action Helper", "[ActionHelper]") {
|
||||
SECTION("Handle failed") {
|
||||
store_address_t toLongParamAddress = store_address_t::invalid();
|
||||
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;
|
||||
@ -98,7 +98,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") {
|
||||
SECTION("Missing IPC Data") {
|
||||
ActionMessage::setCommand(&actionMessage, testActionId, store_address_t::invalid());
|
||||
CHECK(not testDhMock.executeActionCalled);
|
||||
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
|
||||
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK);
|
||||
CommandMessage testMessage;
|
||||
REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK);
|
||||
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") {
|
||||
const std::vector<uint8_t>& 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<uint8_t>& 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++) {
|
||||
|
@ -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;
|
||||
|
@ -19,7 +19,7 @@ TEST_CASE("Binary Semaphore Test" , "[BinSemaphore]") {
|
||||
REQUIRE(binSemaph->release() ==
|
||||
static_cast<int>(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
|
||||
|
@ -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
|
||||
|
@ -102,7 +102,7 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") {
|
||||
size_t size = 6;
|
||||
auto result = tv_serial_buffer_adapter3.deSerialize(const_cast<const uint8_t**>(&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);
|
||||
|
@ -40,7 +40,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);
|
||||
@ -59,7 +59,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);
|
||||
|
@ -12,7 +12,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") {
|
||||
std::array<uint8_t, 20> testDataArray{};
|
||||
std::array<uint8_t, 20> 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("Pool Accessor", "[pool-accessor]") {
|
||||
|
||||
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("Pool Accessor", "[pool-accessor]") {
|
||||
|
||||
{
|
||||
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("Pool Accessor", "[pool-accessor]") {
|
||||
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("Pool Accessor", "[pool-accessor]") {
|
||||
|
||||
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("Pool Accessor", "[pool-accessor]") {
|
||||
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("Pool Accessor", "[pool-accessor]") {
|
||||
// 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("Pool Accessor", "[pool-accessor]") {
|
||||
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("Pool Accessor", "[pool-accessor]") {
|
||||
|
||||
SECTION("Operators") {
|
||||
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||
REQUIRE(result == retval::CATCH_OK);
|
||||
REQUIRE(result == result::OK);
|
||||
{
|
||||
StorageAccessor accessor(testStoreId);
|
||||
StorageAccessor accessor2(store_address_t::invalid());
|
||||
|
Loading…
Reference in New Issue
Block a user