updated indentation
This commit is contained in:
parent
cc2e26443d
commit
e245f56a4f
@ -6,17 +6,17 @@
|
|||||||
#include <unittest/core/CatchDefinitions.h>
|
#include <unittest/core/CatchDefinitions.h>
|
||||||
|
|
||||||
TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
|
TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||||
REQUIRE(poolOwner != nullptr);
|
REQUIRE(poolOwner != nullptr);
|
||||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||||
== retval::CATCH_OK);
|
== retval::CATCH_OK);
|
||||||
const uint32_t setId = 0;
|
const uint32_t setId = 0;
|
||||||
SECTION("BasicTest") {
|
SECTION("BasicTest") {
|
||||||
StaticLocalDataSet<3> localSet = StaticLocalDataSet<3>(
|
StaticLocalDataSet<3> localSet = StaticLocalDataSet<3>(
|
||||||
sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, setId));
|
sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, setId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,115 +8,115 @@
|
|||||||
|
|
||||||
|
|
||||||
TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||||
REQUIRE(poolOwner != nullptr);
|
REQUIRE(poolOwner != nullptr);
|
||||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||||
== retval::CATCH_OK);
|
== retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->dataset.assignPointers() == retval::CATCH_OK);
|
REQUIRE(poolOwner->dataset.assignPointers() == retval::CATCH_OK);
|
||||||
MessageQueueMockBase* mqMock = poolOwner->getMockQueueHandle();
|
MessageQueueMockBase* mqMock = poolOwner->getMockQueueHandle();
|
||||||
REQUIRE(mqMock != nullptr);
|
REQUIRE(mqMock != nullptr);
|
||||||
CommandMessage messageSent;
|
CommandMessage messageSent;
|
||||||
uint8_t messagesSent = 0;
|
uint8_t messagesSent = 0;
|
||||||
|
|
||||||
|
|
||||||
SECTION("BasicTest") {
|
SECTION("BasicTest") {
|
||||||
// Subscribe for message generation on update.
|
/* Subscribe for message generation on update. */
|
||||||
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
|
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
|
||||||
// Subscribe for an update message.
|
/* Subscribe for an update message. */
|
||||||
poolOwner->dataset.setChanged(true);
|
poolOwner->dataset.setChanged(true);
|
||||||
// Now the update message should be generated.
|
/* Now the update message should be generated. */
|
||||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
REQUIRE(mqMock->wasMessageSent() == true);
|
REQUIRE(mqMock->wasMessageSent() == true);
|
||||||
|
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||||
|
|
||||||
// Should have been reset.
|
/* Should have been reset. */
|
||||||
CHECK(poolOwner->dataset.hasChanged() == false);
|
CHECK(poolOwner->dataset.hasChanged() == false);
|
||||||
// Set changed again, result should be the same.
|
/* Set changed again, result should be the same. */
|
||||||
poolOwner->dataset.setChanged(true);
|
poolOwner->dataset.setChanged(true);
|
||||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
|
|
||||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
CHECK(messagesSent == 1);
|
CHECK(messagesSent == 1);
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||||
|
|
||||||
// now subscribe for set update HK as well.
|
/* Now subscribe for set update HK as well. */
|
||||||
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
|
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
|
||||||
poolOwner->dataset.setChanged(true);
|
poolOwner->dataset.setChanged(true);
|
||||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
CHECK(messagesSent == 2);
|
CHECK(messagesSent == 2);
|
||||||
// first message sent should be the update notification, considering
|
/* first message sent should be the update notification, considering
|
||||||
// the internal list is a vector checked in insertion order.
|
the internal list is a vector checked in insertion order. */
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||||
|
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::HK_REPORT));
|
HousekeepingMessage::HK_REPORT));
|
||||||
// clear message to avoid memory leak, our mock won't do it for us (yet)
|
/* Clear message to avoid memory leak, our mock won't do it for us (yet) */
|
||||||
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("AdvancedTests") {
|
SECTION("AdvancedTests") {
|
||||||
// we need to reset the subscription list because the pool owner
|
/* we need to reset the subscription list because the pool owner
|
||||||
// is a global object.
|
is a global object. */
|
||||||
poolOwner->resetSubscriptionList();
|
poolOwner->resetSubscriptionList();
|
||||||
// Subscribe for variable update as well
|
/* Subscribe for variable update as well */
|
||||||
REQUIRE(not poolOwner->dataset.hasChanged());
|
REQUIRE(not poolOwner->dataset.hasChanged());
|
||||||
REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) ==
|
REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) ==
|
||||||
retval::CATCH_OK);
|
retval::CATCH_OK);
|
||||||
lp_var_t<uint8_t>* poolVar = dynamic_cast<lp_var_t<uint8_t>*>(
|
lp_var_t<uint8_t>* poolVar = dynamic_cast<lp_var_t<uint8_t>*>(
|
||||||
poolOwner->getPoolObjectHandle(lpool::uint8VarId));
|
poolOwner->getPoolObjectHandle(lpool::uint8VarId));
|
||||||
REQUIRE(poolVar != nullptr);
|
REQUIRE(poolVar != nullptr);
|
||||||
poolVar->setChanged(true);
|
poolVar->setChanged(true);
|
||||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
|
|
||||||
// Check update notification was sent.
|
/* Check update notification was sent. */
|
||||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
CHECK(messagesSent == 1);
|
CHECK(messagesSent == 1);
|
||||||
// Should have been reset.
|
/* Should have been reset. */
|
||||||
CHECK(poolVar->hasChanged() == false);
|
CHECK(poolVar->hasChanged() == false);
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||||
|
|
||||||
// now subscribe for the dataset update (HK and update) again
|
/* Now subscribe for the dataset update (HK and update) again */
|
||||||
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
|
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
|
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
|
||||||
|
|
||||||
poolOwner->dataset.setChanged(true);
|
poolOwner->dataset.setChanged(true);
|
||||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
// now two messages should be sent.
|
/* Now two messages should be sent. */
|
||||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
CHECK(messagesSent == 2);
|
CHECK(messagesSent == 2);
|
||||||
mqMock->clearMessages(true);
|
mqMock->clearMessages(true);
|
||||||
|
|
||||||
poolOwner->dataset.setChanged(true);
|
poolOwner->dataset.setChanged(true);
|
||||||
poolVar->setChanged(true);
|
poolVar->setChanged(true);
|
||||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
// now three messages should be sent.
|
/* Now three messages should be sent. */
|
||||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
CHECK(messagesSent == 3);
|
CHECK(messagesSent == 3);
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
HousekeepingMessage::HK_REPORT));
|
HousekeepingMessage::HK_REPORT));
|
||||||
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
||||||
REQUIRE(mqMock->receiveMessage(&messageSent) ==
|
REQUIRE(mqMock->receiveMessage(&messageSent) ==
|
||||||
static_cast<int>(MessageQueueIF::EMPTY));
|
static_cast<int>(MessageQueueIF::EMPTY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,32 +21,32 @@ static constexpr lp_id_t int64Vec2Id = 4;
|
|||||||
static constexpr uint32_t testSetId = 0;
|
static constexpr uint32_t testSetId = 0;
|
||||||
static constexpr uint8_t dataSetMaxVariables = 10;
|
static constexpr uint8_t dataSetMaxVariables = 10;
|
||||||
static const sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE,
|
static const sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE,
|
||||||
testSetId);
|
testSetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class LocalPoolTestDataSet: public LocalDataSet {
|
class LocalPoolTestDataSet: public LocalDataSet {
|
||||||
public:
|
public:
|
||||||
LocalPoolTestDataSet(HasLocalDataPoolIF* owner, uint32_t setId):
|
LocalPoolTestDataSet(HasLocalDataPoolIF* owner, uint32_t setId):
|
||||||
LocalDataSet(owner, setId, lpool::dataSetMaxVariables) {
|
LocalDataSet(owner, setId, lpool::dataSetMaxVariables) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t assignPointers() {
|
ReturnValue_t assignPointers() {
|
||||||
PoolVariableIF** rawVarArray = getContainer();
|
PoolVariableIF** rawVarArray = getContainer();
|
||||||
localPoolVarUint8 = dynamic_cast<lp_var_t<uint8_t>*>(rawVarArray[0]);
|
localPoolVarUint8 = dynamic_cast<lp_var_t<uint8_t>*>(rawVarArray[0]);
|
||||||
localPoolVarFloat = dynamic_cast<lp_var_t<float>*>(rawVarArray[1]);
|
localPoolVarFloat = dynamic_cast<lp_var_t<float>*>(rawVarArray[1]);
|
||||||
localPoolUint16Vec = dynamic_cast<lp_vec_t<uint16_t, 3>*>(
|
localPoolUint16Vec = dynamic_cast<lp_vec_t<uint16_t, 3>*>(
|
||||||
rawVarArray[2]);
|
rawVarArray[2]);
|
||||||
if(localPoolVarUint8 == nullptr or localPoolVarFloat == nullptr or
|
if(localPoolVarUint8 == nullptr or localPoolVarFloat == nullptr or
|
||||||
localPoolUint16Vec == nullptr) {
|
localPoolUint16Vec == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
lp_var_t<uint8_t>* localPoolVarUint8 = nullptr;
|
lp_var_t<uint8_t>* localPoolVarUint8 = nullptr;
|
||||||
lp_var_t<float>* localPoolVarFloat = nullptr;
|
lp_var_t<float>* localPoolVarFloat = nullptr;
|
||||||
lp_vec_t<uint16_t, 3>* localPoolUint16Vec = nullptr;
|
lp_vec_t<uint16_t, 3>* localPoolUint16Vec = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@ -54,143 +54,143 @@ private:
|
|||||||
|
|
||||||
class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF {
|
class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF {
|
||||||
public:
|
public:
|
||||||
LocalPoolOwnerBase(
|
LocalPoolOwnerBase(
|
||||||
object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE):
|
object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE):
|
||||||
SystemObject(objectId), poolManager(this, messageQueue),
|
SystemObject(objectId), poolManager(this, messageQueue),
|
||||||
dataset(this, lpool::testSetId) {
|
dataset(this, lpool::testSetId) {
|
||||||
messageQueue = new MessageQueueMockBase();
|
messageQueue = new MessageQueueMockBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
~LocalPoolOwnerBase() {
|
~LocalPoolOwnerBase() {
|
||||||
QueueFactory::instance()->deleteMessageQueue(messageQueue);
|
QueueFactory::instance()->deleteMessageQueue(messageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_id_t getObjectId() const override {
|
object_id_t getObjectId() const override {
|
||||||
return SystemObject::getObjectId();
|
return SystemObject::getObjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t initializeHkManager() {
|
ReturnValue_t initializeHkManager() {
|
||||||
if(not initialized) {
|
if(not initialized) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
return poolManager.initialize(messageQueue);
|
return poolManager.initialize(messageQueue);
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t initializeHkManagerAfterTaskCreation() {
|
ReturnValue_t initializeHkManagerAfterTaskCreation() {
|
||||||
if(not initializedAfterTaskCreation) {
|
if(not initializedAfterTaskCreation) {
|
||||||
initializedAfterTaskCreation = true;
|
initializedAfterTaskCreation = true;
|
||||||
return poolManager.initializeAfterTaskCreation();
|
return poolManager.initializeAfterTaskCreation();
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Command queue for housekeeping messages. */
|
/** Command queue for housekeeping messages. */
|
||||||
MessageQueueId_t getCommandQueue() const override {
|
MessageQueueId_t getCommandQueue() const override {
|
||||||
return messageQueue->getId();
|
return messageQueue->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is called by initializeAfterTaskCreation of the HK manager.
|
// This is called by initializeAfterTaskCreation of the HK manager.
|
||||||
virtual ReturnValue_t initializeLocalDataPool(
|
virtual ReturnValue_t initializeLocalDataPool(
|
||||||
localpool::DataPool& localDataPoolMap,
|
localpool::DataPool& localDataPoolMap,
|
||||||
LocalDataPoolManager& poolManager) {
|
LocalDataPoolManager& poolManager) {
|
||||||
// Default initialization empty for now.
|
// Default initialization empty for now.
|
||||||
localDataPoolMap.emplace(lpool::uint8VarId,
|
localDataPoolMap.emplace(lpool::uint8VarId,
|
||||||
new PoolEntry<uint8_t>({0}));
|
new PoolEntry<uint8_t>({0}));
|
||||||
localDataPoolMap.emplace(lpool::floatVarId,
|
localDataPoolMap.emplace(lpool::floatVarId,
|
||||||
new PoolEntry<float>({0}));
|
new PoolEntry<float>({0}));
|
||||||
localDataPoolMap.emplace(lpool::uint32VarId,
|
localDataPoolMap.emplace(lpool::uint32VarId,
|
||||||
new PoolEntry<uint32_t>({0}));
|
new PoolEntry<uint32_t>({0}));
|
||||||
|
|
||||||
localDataPoolMap.emplace(lpool::uint16Vec3Id,
|
localDataPoolMap.emplace(lpool::uint16Vec3Id,
|
||||||
new PoolEntry<uint16_t>({0, 0, 0}));
|
new PoolEntry<uint16_t>({0, 0, 0}));
|
||||||
localDataPoolMap.emplace(lpool::int64Vec2Id,
|
localDataPoolMap.emplace(lpool::int64Vec2Id,
|
||||||
new PoolEntry<int64_t>({0, 0}));
|
new PoolEntry<int64_t>({0, 0}));
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDataPoolManager* getHkManagerHandle() override {
|
LocalDataPoolManager* getHkManagerHandle() override {
|
||||||
return &poolManager;
|
return &poolManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getPeriodicOperationFrequency() const override {
|
uint32_t getPeriodicOperationFrequency() const override {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used by the pool manager to get a valid dataset
|
* This function is used by the pool manager to get a valid dataset
|
||||||
* from a SID
|
* from a SID
|
||||||
* @param sid Corresponding structure ID
|
* @param sid Corresponding structure ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override {
|
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override {
|
||||||
return &dataset;
|
return &dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual LocalPoolObjectBase* getPoolObjectHandle(
|
virtual LocalPoolObjectBase* getPoolObjectHandle(
|
||||||
lp_id_t localPoolId) override {
|
lp_id_t localPoolId) override {
|
||||||
if(localPoolId == lpool::uint8VarId) {
|
if(localPoolId == lpool::uint8VarId) {
|
||||||
return &testUint8;
|
return &testUint8;
|
||||||
}
|
}
|
||||||
else if(localPoolId == lpool::uint16Vec3Id) {
|
else if(localPoolId == lpool::uint16Vec3Id) {
|
||||||
return &testUint16Vec;
|
return &testUint16Vec;
|
||||||
}
|
}
|
||||||
else if(localPoolId == lpool::floatVarId) {
|
else if(localPoolId == lpool::floatVarId) {
|
||||||
return &testFloat;
|
return &testFloat;
|
||||||
}
|
}
|
||||||
else if(localPoolId == lpool::int64Vec2Id) {
|
else if(localPoolId == lpool::int64Vec2Id) {
|
||||||
return &testInt64Vec;
|
return &testInt64Vec;
|
||||||
}
|
}
|
||||||
else if(localPoolId == lpool::uint32VarId) {
|
else if(localPoolId == lpool::uint32VarId) {
|
||||||
return &testUint32;
|
return &testUint32;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return &testUint8;
|
return &testUint8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueMockBase* getMockQueueHandle() const {
|
MessageQueueMockBase* getMockQueueHandle() const {
|
||||||
return dynamic_cast<MessageQueueMockBase*>(messageQueue);
|
return dynamic_cast<MessageQueueMockBase*>(messageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t subscribeWrapperSetUpdate() {
|
ReturnValue_t subscribeWrapperSetUpdate() {
|
||||||
return poolManager.subscribeForSetUpdateMessages(lpool::testSetId,
|
return poolManager.subscribeForSetUpdateMessages(lpool::testSetId,
|
||||||
objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false);
|
objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false) {
|
ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false) {
|
||||||
return poolManager.subscribeForUpdatePackets(lpool::testSid, diagnostics,
|
return poolManager.subscribeForUpdatePackets(lpool::testSid, diagnostics,
|
||||||
false, objects::HK_RECEIVER_MOCK);
|
false, objects::HK_RECEIVER_MOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t subscribeWrapperVariableUpdate(lp_id_t localPoolId) {
|
ReturnValue_t subscribeWrapperVariableUpdate(lp_id_t localPoolId) {
|
||||||
return poolManager.subscribeForVariableUpdateMessages(localPoolId,
|
return poolManager.subscribeForVariableUpdateMessages(localPoolId,
|
||||||
MessageQueueIF::NO_QUEUE, objects::NO_OBJECT, false);
|
MessageQueueIF::NO_QUEUE, objects::NO_OBJECT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetSubscriptionList() {
|
void resetSubscriptionList() {
|
||||||
poolManager.clearReceiversList();
|
poolManager.clearReceiversList();
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDataPoolManager poolManager;
|
LocalDataPoolManager poolManager;
|
||||||
LocalPoolTestDataSet dataset;
|
LocalPoolTestDataSet dataset;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
lp_var_t<uint8_t> testUint8 = lp_var_t<uint8_t>(this, lpool::uint8VarId,
|
lp_var_t<uint8_t> testUint8 = lp_var_t<uint8_t>(this, lpool::uint8VarId,
|
||||||
&dataset);
|
&dataset);
|
||||||
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId,
|
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId,
|
||||||
&dataset);
|
&dataset);
|
||||||
lp_var_t<uint32_t> testUint32 = lp_var_t<uint32_t>(this, lpool::uint32VarId);
|
lp_var_t<uint32_t> testUint32 = lp_var_t<uint32_t>(this, lpool::uint32VarId);
|
||||||
|
|
||||||
lp_vec_t<uint16_t, 3> testUint16Vec = lp_vec_t<uint16_t, 3>(this,
|
lp_vec_t<uint16_t, 3> testUint16Vec = lp_vec_t<uint16_t, 3>(this,
|
||||||
lpool::uint16Vec3Id, &dataset);
|
lpool::uint16Vec3Id, &dataset);
|
||||||
lp_vec_t<int64_t, 2> testInt64Vec = lp_vec_t<int64_t, 2>(this,
|
lp_vec_t<int64_t, 2> testInt64Vec = lp_vec_t<int64_t, 2>(this,
|
||||||
lpool::int64Vec2Id);
|
lpool::int64Vec2Id);
|
||||||
|
|
||||||
MessageQueueIF* messageQueue = nullptr;
|
MessageQueueIF* messageQueue = nullptr;
|
||||||
|
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
bool initializedAfterTaskCreation = false;
|
bool initializedAfterTaskCreation = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,117 +6,117 @@
|
|||||||
|
|
||||||
|
|
||||||
TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||||
REQUIRE(poolOwner != nullptr);
|
REQUIRE(poolOwner != nullptr);
|
||||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||||
== retval::CATCH_OK);
|
== retval::CATCH_OK);
|
||||||
|
|
||||||
SECTION("Basic Tests") {
|
SECTION("Basic Tests") {
|
||||||
// very basic test.
|
/* very basic test. */
|
||||||
lp_var_t<uint8_t> testVariable = lp_var_t<uint8_t>(
|
lp_var_t<uint8_t> testVariable = lp_var_t<uint8_t>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
|
||||||
REQUIRE(testVariable.read() == retval::CATCH_OK);
|
REQUIRE(testVariable.read() == retval::CATCH_OK);
|
||||||
CHECK(testVariable.value == 0);
|
CHECK(testVariable.value == 0);
|
||||||
testVariable.value = 5;
|
testVariable.value = 5;
|
||||||
REQUIRE(testVariable.commit() == retval::CATCH_OK);
|
REQUIRE(testVariable.commit() == retval::CATCH_OK);
|
||||||
REQUIRE(testVariable.read() == retval::CATCH_OK);
|
REQUIRE(testVariable.read() == retval::CATCH_OK);
|
||||||
REQUIRE(testVariable.value == 5);
|
REQUIRE(testVariable.value == 5);
|
||||||
CHECK(not testVariable.isValid());
|
CHECK(not testVariable.isValid());
|
||||||
testVariable.setValid(true);
|
testVariable.setValid(true);
|
||||||
CHECK(testVariable.isValid());
|
CHECK(testVariable.isValid());
|
||||||
CHECK(testVariable.commit(true) == retval::CATCH_OK);
|
CHECK(testVariable.commit(true) == retval::CATCH_OK);
|
||||||
|
|
||||||
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ);
|
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ);
|
||||||
CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ);
|
CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ);
|
||||||
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE);
|
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE);
|
||||||
|
|
||||||
testVariable.setDataPoolId(22);
|
testVariable.setDataPoolId(22);
|
||||||
CHECK(testVariable.getDataPoolId() == 22);
|
CHECK(testVariable.getDataPoolId() == 22);
|
||||||
testVariable.setDataPoolId(lpool::uint8VarId);
|
testVariable.setDataPoolId(lpool::uint8VarId);
|
||||||
|
|
||||||
testVariable.setChanged(true);
|
testVariable.setChanged(true);
|
||||||
CHECK(testVariable.hasChanged());
|
CHECK(testVariable.hasChanged());
|
||||||
testVariable.setChanged(false);
|
testVariable.setChanged(false);
|
||||||
|
|
||||||
gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE,
|
gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE,
|
||||||
lpool::uint8VarId);
|
lpool::uint8VarId);
|
||||||
lp_var_t<uint8_t> testVariable2 = lp_var_t<uint8_t>(globPoolId);
|
lp_var_t<uint8_t> testVariable2 = lp_var_t<uint8_t>(globPoolId);
|
||||||
REQUIRE(testVariable2.read() == retval::CATCH_OK);
|
REQUIRE(testVariable2.read() == retval::CATCH_OK);
|
||||||
CHECK(testVariable2 == 5);
|
CHECK(testVariable2 == 5);
|
||||||
CHECK(testVariable == testVariable2);
|
CHECK(testVariable == testVariable2);
|
||||||
testVariable = 10;
|
testVariable = 10;
|
||||||
CHECK(testVariable != 5);
|
CHECK(testVariable != 5);
|
||||||
//CHECK(not testVariable != testVariable2);
|
//CHECK(not testVariable != testVariable2);
|
||||||
uint8_t variableRaw = 0;
|
uint8_t variableRaw = 0;
|
||||||
uint8_t* varPtr = &variableRaw;
|
uint8_t* varPtr = &variableRaw;
|
||||||
size_t maxSize = testVariable.getSerializedSize();
|
size_t maxSize = testVariable.getSerializedSize();
|
||||||
CHECK(maxSize == 1);
|
CHECK(maxSize == 1);
|
||||||
size_t serSize = 0;
|
size_t serSize = 0;
|
||||||
CHECK(testVariable.serialize(&varPtr, &serSize, maxSize,
|
CHECK(testVariable.serialize(&varPtr, &serSize, maxSize,
|
||||||
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
||||||
CHECK(variableRaw == 10);
|
CHECK(variableRaw == 10);
|
||||||
const uint8_t* varConstPtr = &variableRaw;
|
const uint8_t* varConstPtr = &variableRaw;
|
||||||
testVariable = 5;
|
testVariable = 5;
|
||||||
CHECK(testVariable.deSerialize(&varConstPtr, &serSize,
|
CHECK(testVariable.deSerialize(&varConstPtr, &serSize,
|
||||||
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
||||||
CHECK(testVariable == 10);
|
CHECK(testVariable == 10);
|
||||||
CHECK(testVariable != testVariable2);
|
CHECK(testVariable != testVariable2);
|
||||||
CHECK(testVariable2 < testVariable);
|
CHECK(testVariable2 < testVariable);
|
||||||
CHECK(testVariable2 < 10);
|
CHECK(testVariable2 < 10);
|
||||||
CHECK(testVariable > 5);
|
CHECK(testVariable > 5);
|
||||||
CHECK(testVariable > testVariable2);
|
CHECK(testVariable > testVariable2);
|
||||||
variableRaw = static_cast<uint8_t>(testVariable2);
|
variableRaw = static_cast<uint8_t>(testVariable2);
|
||||||
CHECK(variableRaw == 5);
|
CHECK(variableRaw == 5);
|
||||||
|
|
||||||
CHECK(testVariable == 10);
|
CHECK(testVariable == 10);
|
||||||
testVariable = testVariable2;
|
testVariable = testVariable2;
|
||||||
CHECK(testVariable == 5);
|
CHECK(testVariable == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("ErrorHandling") {
|
SECTION("ErrorHandling") {
|
||||||
|
|
||||||
// not try to use a local pool variable which does not exist
|
/* now try to use a local pool variable which does not exist */
|
||||||
lp_var_t<uint8_t> invalidVariable = lp_var_t<uint8_t>(
|
lp_var_t<uint8_t> invalidVariable = lp_var_t<uint8_t>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff);
|
objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff);
|
||||||
REQUIRE(invalidVariable.read() ==
|
REQUIRE(invalidVariable.read() ==
|
||||||
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
||||||
|
|
||||||
REQUIRE(invalidVariable.commit() ==
|
REQUIRE(invalidVariable.commit() ==
|
||||||
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
||||||
// now try to access with wrong type
|
/* now try to access with wrong type */
|
||||||
lp_var_t<int8_t> invalidVariable2 = lp_var_t<int8_t>(
|
lp_var_t<int8_t> invalidVariable2 = lp_var_t<int8_t>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
|
||||||
REQUIRE(invalidVariable2.read() ==
|
REQUIRE(invalidVariable2.read() ==
|
||||||
static_cast<int>(localpool::POOL_ENTRY_TYPE_CONFLICT));
|
static_cast<int>(localpool::POOL_ENTRY_TYPE_CONFLICT));
|
||||||
|
|
||||||
lp_var_t<uint8_t> readOnlyVar = lp_var_t<uint8_t>(
|
lp_var_t<uint8_t> readOnlyVar = lp_var_t<uint8_t>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId,
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId,
|
||||||
nullptr, pool_rwm_t::VAR_READ);
|
nullptr, pool_rwm_t::VAR_READ);
|
||||||
REQUIRE(readOnlyVar.commit() ==
|
REQUIRE(readOnlyVar.commit() ==
|
||||||
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
||||||
lp_var_t<uint8_t> writeOnlyVar = lp_var_t<uint8_t>(
|
lp_var_t<uint8_t> writeOnlyVar = lp_var_t<uint8_t>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId,
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId,
|
||||||
nullptr, pool_rwm_t::VAR_WRITE);
|
nullptr, pool_rwm_t::VAR_WRITE);
|
||||||
REQUIRE(writeOnlyVar.read() == static_cast<int>(
|
REQUIRE(writeOnlyVar.read() == static_cast<int>(
|
||||||
PoolVariableIF::INVALID_READ_WRITE_MODE));
|
PoolVariableIF::INVALID_READ_WRITE_MODE));
|
||||||
|
|
||||||
lp_var_t<uint32_t> uint32tVar = lp_var_t<uint32_t>(
|
lp_var_t<uint32_t> uint32tVar = lp_var_t<uint32_t>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint32VarId);
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint32VarId);
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "LocalPoolVariable printout: " <<uint32tVar << std::endl;
|
sif::info << "LocalPoolVariable printout: " <<uint32tVar << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// for code coverage. If program does not crash -> OK
|
/* for code coverage. If program does not crash -> OK */
|
||||||
lp_var_t<uint8_t> invalidObjectVar = lp_var_t<uint8_t>(
|
lp_var_t<uint8_t> invalidObjectVar = lp_var_t<uint8_t>(
|
||||||
0xffffffff, lpool::uint8VarId);
|
0xffffffff, lpool::uint8VarId);
|
||||||
gp_id_t globPoolId(0xffffffff,
|
gp_id_t globPoolId(0xffffffff,
|
||||||
lpool::uint8VarId);
|
lpool::uint8VarId);
|
||||||
lp_var_t<uint8_t> invalidObjectVar2 = lp_var_t<uint8_t>(globPoolId);
|
lp_var_t<uint8_t> invalidObjectVar2 = lp_var_t<uint8_t>(globPoolId);
|
||||||
lp_var_t<uint8_t> invalidObjectVar3 = lp_var_t<uint8_t>(nullptr,
|
lp_var_t<uint8_t> invalidObjectVar3 = lp_var_t<uint8_t>(nullptr,
|
||||||
lpool::uint8VarId);
|
lpool::uint8VarId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,116 +5,116 @@
|
|||||||
#include <unittest/core/CatchDefinitions.h>
|
#include <unittest/core/CatchDefinitions.h>
|
||||||
|
|
||||||
TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
|
TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
|
||||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||||
REQUIRE(poolOwner != nullptr);
|
REQUIRE(poolOwner != nullptr);
|
||||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||||
== retval::CATCH_OK);
|
== retval::CATCH_OK);
|
||||||
|
|
||||||
SECTION("BasicTest") {
|
SECTION("BasicTest") {
|
||||||
// very basic test.
|
// very basic test.
|
||||||
lp_vec_t<uint16_t, 3> testVector = lp_vec_t<uint16_t, 3>(
|
lp_vec_t<uint16_t, 3> testVector = lp_vec_t<uint16_t, 3>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id);
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id);
|
||||||
REQUIRE(testVector.read() == retval::CATCH_OK);
|
REQUIRE(testVector.read() == retval::CATCH_OK);
|
||||||
testVector.value[0] = 5;
|
testVector.value[0] = 5;
|
||||||
testVector.value[1] = 232;
|
testVector.value[1] = 232;
|
||||||
testVector.value[2] = 32023;
|
testVector.value[2] = 32023;
|
||||||
|
|
||||||
REQUIRE(testVector.commit(true) == retval::CATCH_OK);
|
REQUIRE(testVector.commit(true) == retval::CATCH_OK);
|
||||||
CHECK(testVector.isValid());
|
CHECK(testVector.isValid());
|
||||||
|
|
||||||
testVector.value[0] = 0;
|
testVector.value[0] = 0;
|
||||||
testVector.value[1] = 0;
|
testVector.value[1] = 0;
|
||||||
testVector.value[2] = 0;
|
testVector.value[2] = 0;
|
||||||
|
|
||||||
CHECK(testVector.read() == retval::CATCH_OK);
|
CHECK(testVector.read() == retval::CATCH_OK);
|
||||||
CHECK(testVector.value[0] == 5);
|
CHECK(testVector.value[0] == 5);
|
||||||
CHECK(testVector.value[1] == 232);
|
CHECK(testVector.value[1] == 232);
|
||||||
CHECK(testVector.value[2] == 32023);
|
CHECK(testVector.value[2] == 32023);
|
||||||
|
|
||||||
CHECK(testVector[0] == 5);
|
CHECK(testVector[0] == 5);
|
||||||
|
|
||||||
// This is invalid access, so the last value will be set instead.
|
/* This is invalid access, so the last value will be set instead.
|
||||||
// (we can't throw exceptions)
|
(we can't throw exceptions) */
|
||||||
testVector[4] = 12;
|
testVector[4] = 12;
|
||||||
CHECK(testVector[2] == 12);
|
CHECK(testVector[2] == 12);
|
||||||
CHECK(testVector.commit() == retval::CATCH_OK);
|
CHECK(testVector.commit() == retval::CATCH_OK);
|
||||||
|
|
||||||
// Use read-only reference.
|
/* Use read-only reference. */
|
||||||
const lp_vec_t<uint16_t, 3>& roTestVec = testVector;
|
const lp_vec_t<uint16_t, 3>& roTestVec = testVector;
|
||||||
uint16_t valueOne = roTestVec[0];
|
uint16_t valueOne = roTestVec[0];
|
||||||
CHECK(valueOne == 5);
|
CHECK(valueOne == 5);
|
||||||
|
|
||||||
uint16_t lastVal = roTestVec[25];
|
uint16_t lastVal = roTestVec[25];
|
||||||
CHECK(lastVal == 12);
|
CHECK(lastVal == 12);
|
||||||
|
|
||||||
size_t maxSize = testVector.getSerializedSize();
|
size_t maxSize = testVector.getSerializedSize();
|
||||||
CHECK(maxSize == 6);
|
CHECK(maxSize == 6);
|
||||||
|
|
||||||
uint16_t serializedVector[3];
|
uint16_t serializedVector[3];
|
||||||
uint8_t* vecPtr = reinterpret_cast<uint8_t*>(serializedVector);
|
uint8_t* vecPtr = reinterpret_cast<uint8_t*>(serializedVector);
|
||||||
size_t serSize = 0;
|
size_t serSize = 0;
|
||||||
REQUIRE(testVector.serialize(&vecPtr, &serSize,
|
REQUIRE(testVector.serialize(&vecPtr, &serSize,
|
||||||
maxSize, SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
maxSize, SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
||||||
|
|
||||||
CHECK(serSize == 6);
|
CHECK(serSize == 6);
|
||||||
CHECK(serializedVector[0] == 5);
|
CHECK(serializedVector[0] == 5);
|
||||||
CHECK(serializedVector[1] == 232);
|
CHECK(serializedVector[1] == 232);
|
||||||
CHECK(serializedVector[2] == 12);
|
CHECK(serializedVector[2] == 12);
|
||||||
|
|
||||||
maxSize = 1;
|
maxSize = 1;
|
||||||
REQUIRE(testVector.serialize(&vecPtr, &serSize,
|
REQUIRE(testVector.serialize(&vecPtr, &serSize,
|
||||||
maxSize, SerializeIF::Endianness::MACHINE) ==
|
maxSize, SerializeIF::Endianness::MACHINE) ==
|
||||||
static_cast<int>(SerializeIF::BUFFER_TOO_SHORT));
|
static_cast<int>(SerializeIF::BUFFER_TOO_SHORT));
|
||||||
|
|
||||||
serializedVector[0] = 16;
|
serializedVector[0] = 16;
|
||||||
serializedVector[1] = 7832;
|
serializedVector[1] = 7832;
|
||||||
serializedVector[2] = 39232;
|
serializedVector[2] = 39232;
|
||||||
|
|
||||||
const uint8_t* constVecPtr = reinterpret_cast<const uint8_t*>(
|
const uint8_t* constVecPtr = reinterpret_cast<const uint8_t*>(
|
||||||
serializedVector);
|
serializedVector);
|
||||||
REQUIRE(testVector.deSerialize(&constVecPtr, &serSize,
|
REQUIRE(testVector.deSerialize(&constVecPtr, &serSize,
|
||||||
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
||||||
CHECK(testVector[0] == 16);
|
CHECK(testVector[0] == 16);
|
||||||
CHECK(testVector[1] == 7832);
|
CHECK(testVector[1] == 7832);
|
||||||
CHECK(testVector[2] == 39232);
|
CHECK(testVector[2] == 39232);
|
||||||
|
|
||||||
serSize = 1;
|
serSize = 1;
|
||||||
REQUIRE(testVector.deSerialize(&constVecPtr, &serSize,
|
REQUIRE(testVector.deSerialize(&constVecPtr, &serSize,
|
||||||
SerializeIF::Endianness::MACHINE) ==
|
SerializeIF::Endianness::MACHINE) ==
|
||||||
static_cast<int>(SerializeIF::STREAM_TOO_SHORT));
|
static_cast<int>(SerializeIF::STREAM_TOO_SHORT));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("ErrorHandling") {
|
SECTION("ErrorHandling") {
|
||||||
// not try to use a local pool variable which does not exist
|
/* Now try to use a local pool variable which does not exist */
|
||||||
lp_vec_t<uint16_t, 3> invalidVector = lp_vec_t<uint16_t, 3>(
|
lp_vec_t<uint16_t, 3> invalidVector = lp_vec_t<uint16_t, 3>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff);
|
objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff);
|
||||||
REQUIRE(invalidVector.read() ==
|
REQUIRE(invalidVector.read() ==
|
||||||
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
||||||
REQUIRE(invalidVector.commit() ==
|
REQUIRE(invalidVector.commit() ==
|
||||||
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
static_cast<int>(localpool::POOL_ENTRY_NOT_FOUND));
|
||||||
|
|
||||||
// now try to access with wrong type
|
/* Now try to access with wrong type */
|
||||||
lp_vec_t<uint32_t, 3> invalidVector2 = lp_vec_t<uint32_t, 3>(
|
lp_vec_t<uint32_t, 3> invalidVector2 = lp_vec_t<uint32_t, 3>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id);
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id);
|
||||||
REQUIRE(invalidVector2.read() ==
|
REQUIRE(invalidVector2.read() ==
|
||||||
static_cast<int>(localpool::POOL_ENTRY_TYPE_CONFLICT));
|
static_cast<int>(localpool::POOL_ENTRY_TYPE_CONFLICT));
|
||||||
REQUIRE(invalidVector2.commit() ==
|
REQUIRE(invalidVector2.commit() ==
|
||||||
static_cast<int>(localpool::POOL_ENTRY_TYPE_CONFLICT));
|
static_cast<int>(localpool::POOL_ENTRY_TYPE_CONFLICT));
|
||||||
|
|
||||||
lp_vec_t<uint16_t, 3> writeOnlyVec = lp_vec_t<uint16_t, 3>(
|
lp_vec_t<uint16_t, 3> writeOnlyVec = lp_vec_t<uint16_t, 3>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id,
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id,
|
||||||
nullptr, pool_rwm_t::VAR_WRITE);
|
nullptr, pool_rwm_t::VAR_WRITE);
|
||||||
REQUIRE(writeOnlyVec.read() ==
|
REQUIRE(writeOnlyVec.read() ==
|
||||||
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
||||||
|
|
||||||
lp_vec_t<uint16_t, 3> readOnlyVec = lp_vec_t<uint16_t, 3>(
|
lp_vec_t<uint16_t, 3> readOnlyVec = lp_vec_t<uint16_t, 3>(
|
||||||
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id,
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id,
|
||||||
nullptr, pool_rwm_t::VAR_READ);
|
nullptr, pool_rwm_t::VAR_READ);
|
||||||
REQUIRE(readOnlyVec.commit() ==
|
REQUIRE(readOnlyVec.commit() ==
|
||||||
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user