added source file
This commit is contained in:
parent
dcde177fe3
commit
8d28bc4b6a
@ -3,4 +3,5 @@ target_sources(${TARGET_NAME} PRIVATE
|
|||||||
LocalPoolVectorTest.cpp
|
LocalPoolVectorTest.cpp
|
||||||
DataSetTest.cpp
|
DataSetTest.cpp
|
||||||
LocalPoolManagerTest.cpp
|
LocalPoolManagerTest.cpp
|
||||||
|
LocalPoolOwnerBase.cpp
|
||||||
)
|
)
|
||||||
|
@ -276,6 +276,8 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
|||||||
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
CHECK(messagesSent == 1);
|
CHECK(messagesSent == 1);
|
||||||
|
|
||||||
|
HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we need to reset the subscription list because the pool owner
|
/* we need to reset the subscription list because the pool owner
|
||||||
|
91
unittest/tests/datapoollocal/LocalPoolOwnerBase.cpp
Normal file
91
unittest/tests/datapoollocal/LocalPoolOwnerBase.cpp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#include "LocalPoolOwnerBase.h"
|
||||||
|
|
||||||
|
LocalPoolOwnerBase::LocalPoolOwnerBase(object_id_t objectId):
|
||||||
|
SystemObject(objectId), poolManager(this, messageQueue),
|
||||||
|
dataset(this, lpool::testSetId) {
|
||||||
|
messageQueue = new MessageQueueMockBase();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t LocalPoolOwnerBase::initializeHkManager() {
|
||||||
|
if(not initialized) {
|
||||||
|
initialized = true;
|
||||||
|
return poolManager.initialize(messageQueue);
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||||
|
LocalDataPoolManager &poolManager) {
|
||||||
|
|
||||||
|
// Default initialization empty for now.
|
||||||
|
localDataPoolMap.emplace(lpool::uint8VarId,
|
||||||
|
new PoolEntry<uint8_t>({0}));
|
||||||
|
localDataPoolMap.emplace(lpool::floatVarId,
|
||||||
|
new PoolEntry<float>({0}));
|
||||||
|
localDataPoolMap.emplace(lpool::uint32VarId,
|
||||||
|
new PoolEntry<uint32_t>({0}));
|
||||||
|
|
||||||
|
localDataPoolMap.emplace(lpool::uint16Vec3Id,
|
||||||
|
new PoolEntry<uint16_t>({0, 0, 0}));
|
||||||
|
localDataPoolMap.emplace(lpool::int64Vec2Id,
|
||||||
|
new PoolEntry<int64_t>({0, 0}));
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalPoolObjectBase* LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId) {
|
||||||
|
if(localPoolId == lpool::uint8VarId) {
|
||||||
|
return &testUint8;
|
||||||
|
}
|
||||||
|
else if(localPoolId == lpool::uint16Vec3Id) {
|
||||||
|
return &testUint16Vec;
|
||||||
|
}
|
||||||
|
else if(localPoolId == lpool::floatVarId) {
|
||||||
|
return &testFloat;
|
||||||
|
}
|
||||||
|
else if(localPoolId == lpool::int64Vec2Id) {
|
||||||
|
return &testInt64Vec;
|
||||||
|
}
|
||||||
|
else if(localPoolId == lpool::uint32VarId) {
|
||||||
|
return &testUint32;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return &testUint8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t LocalPoolOwnerBase::reset() {
|
||||||
|
resetSubscriptionList();
|
||||||
|
ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
|
||||||
|
{
|
||||||
|
PoolReadGuard readHelper(&dataset);
|
||||||
|
if(readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
status = readHelper.getReadResult();
|
||||||
|
}
|
||||||
|
dataset.localPoolVarUint8.value = 0;
|
||||||
|
dataset.localPoolVarFloat.value = 0.0;
|
||||||
|
dataset.localPoolUint16Vec.value[0] = 0;
|
||||||
|
dataset.localPoolUint16Vec.value[1] = 0;
|
||||||
|
dataset.localPoolUint16Vec.value[2] = 0;
|
||||||
|
dataset.setValidity(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
PoolReadGuard readHelper(&testUint32);
|
||||||
|
if(readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
status = readHelper.getReadResult();
|
||||||
|
}
|
||||||
|
testUint32.value = 0;
|
||||||
|
testUint32.setValid(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
PoolReadGuard readHelper(&testInt64Vec);
|
||||||
|
if(readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
status = readHelper.getReadResult();
|
||||||
|
}
|
||||||
|
testInt64Vec.value[0] = 0;
|
||||||
|
testInt64Vec.value[1] = 0;
|
||||||
|
testInt64Vec.setValid(false);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
@ -70,12 +70,7 @@ 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),
|
|
||||||
dataset(this, lpool::testSetId) {
|
|
||||||
messageQueue = new MessageQueueMockBase();
|
|
||||||
}
|
|
||||||
|
|
||||||
~LocalPoolOwnerBase() {
|
~LocalPoolOwnerBase() {
|
||||||
QueueFactory::instance()->deleteMessageQueue(messageQueue);
|
QueueFactory::instance()->deleteMessageQueue(messageQueue);
|
||||||
@ -85,13 +80,7 @@ public:
|
|||||||
return SystemObject::getObjectId();
|
return SystemObject::getObjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t initializeHkManager() {
|
ReturnValue_t initializeHkManager();
|
||||||
if(not initialized) {
|
|
||||||
initialized = true;
|
|
||||||
return poolManager.initialize(messageQueue);
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t initializeHkManagerAfterTaskCreation() {
|
ReturnValue_t initializeHkManagerAfterTaskCreation() {
|
||||||
if(not initializedAfterTaskCreation) {
|
if(not initializedAfterTaskCreation) {
|
||||||
@ -107,23 +96,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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) override;
|
||||||
LocalDataPoolManager& poolManager) {
|
|
||||||
// Default initialization empty for now.
|
|
||||||
localDataPoolMap.emplace(lpool::uint8VarId,
|
|
||||||
new PoolEntry<uint8_t>({0}));
|
|
||||||
localDataPoolMap.emplace(lpool::floatVarId,
|
|
||||||
new PoolEntry<float>({0}));
|
|
||||||
localDataPoolMap.emplace(lpool::uint32VarId,
|
|
||||||
new PoolEntry<uint32_t>({0}));
|
|
||||||
|
|
||||||
localDataPoolMap.emplace(lpool::uint16Vec3Id,
|
|
||||||
new PoolEntry<uint16_t>({0, 0, 0}));
|
|
||||||
localDataPoolMap.emplace(lpool::int64Vec2Id,
|
|
||||||
new PoolEntry<int64_t>({0, 0}));
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalDataPoolManager* getHkManagerHandle() override {
|
LocalDataPoolManager* getHkManagerHandle() override {
|
||||||
return &poolManager;
|
return &poolManager;
|
||||||
@ -143,27 +117,7 @@ public:
|
|||||||
return &dataset;
|
return &dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual LocalPoolObjectBase* getPoolObjectHandle(
|
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override;
|
||||||
lp_id_t localPoolId) override {
|
|
||||||
if(localPoolId == lpool::uint8VarId) {
|
|
||||||
return &testUint8;
|
|
||||||
}
|
|
||||||
else if(localPoolId == lpool::uint16Vec3Id) {
|
|
||||||
return &testUint16Vec;
|
|
||||||
}
|
|
||||||
else if(localPoolId == lpool::floatVarId) {
|
|
||||||
return &testFloat;
|
|
||||||
}
|
|
||||||
else if(localPoolId == lpool::int64Vec2Id) {
|
|
||||||
return &testInt64Vec;
|
|
||||||
}
|
|
||||||
else if(localPoolId == lpool::uint32VarId) {
|
|
||||||
return &testUint32;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return &testUint8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageQueueMockBase* getMockQueueHandle() const {
|
MessageQueueMockBase* getMockQueueHandle() const {
|
||||||
return dynamic_cast<MessageQueueMockBase*>(messageQueue);
|
return dynamic_cast<MessageQueueMockBase*>(messageQueue);
|
||||||
@ -198,51 +152,24 @@ public:
|
|||||||
MessageQueueIF::NO_QUEUE, objects::HK_RECEIVER_MOCK, true);
|
MessageQueueIF::NO_QUEUE, objects::HK_RECEIVER_MOCK, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t reset() {
|
ReturnValue_t reset();
|
||||||
resetSubscriptionList();
|
|
||||||
ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
|
|
||||||
{
|
|
||||||
PoolReadGuard readHelper(&dataset);
|
|
||||||
if(readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
status = readHelper.getReadResult();
|
|
||||||
}
|
|
||||||
dataset.localPoolVarUint8.value = 0;
|
|
||||||
dataset.localPoolVarFloat.value = 0.0;
|
|
||||||
dataset.localPoolUint16Vec.value[0] = 0;
|
|
||||||
dataset.localPoolUint16Vec.value[1] = 0;
|
|
||||||
dataset.localPoolUint16Vec.value[2] = 0;
|
|
||||||
dataset.setValidity(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
PoolReadGuard readHelper(&testUint32);
|
|
||||||
if(readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
status = readHelper.getReadResult();
|
|
||||||
}
|
|
||||||
testUint32.value = 0;
|
|
||||||
testUint32.setValid(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
PoolReadGuard readHelper(&testInt64Vec);
|
|
||||||
if(readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
status = readHelper.getReadResult();
|
|
||||||
}
|
|
||||||
testInt64Vec.value[0] = 0;
|
|
||||||
testInt64Vec.value[1] = 0;
|
|
||||||
testInt64Vec.setValid(false);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetSubscriptionList() {
|
void resetSubscriptionList() {
|
||||||
poolManager.clearReceiversList();
|
poolManager.clearReceiversList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleChangedDataset(sid_t sid, store_address_t storeId) {
|
||||||
|
this->thisSidHasChanged = sid;
|
||||||
|
this->storeIdForChangedSid = storeId;
|
||||||
|
}
|
||||||
|
|
||||||
LocalDataPoolManager poolManager;
|
LocalDataPoolManager poolManager;
|
||||||
LocalPoolTestDataSet dataset;
|
LocalPoolTestDataSet dataset;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
sid_t thisSidHasChanged;
|
||||||
|
store_address_t storeIdForChangedSid;
|
||||||
|
|
||||||
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);
|
||||||
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId);
|
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId);
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user