added first unit tests for hk manager
This commit is contained in:
@ -7,6 +7,8 @@
|
||||
#include <fsfw/datapoollocal/LocalPoolVector.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <testcfg/objects/systemObjectList.h>
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/unittest/tests/mocks/MessageQueueMockBase.h>
|
||||
|
||||
namespace lpool {
|
||||
static constexpr lp_id_t uint8VarId = 0;
|
||||
@ -14,16 +16,45 @@ static constexpr lp_id_t floatVarId = 1;
|
||||
static constexpr lp_id_t uint32VarId = 2;
|
||||
static constexpr lp_id_t uint16Vec3Id = 3;
|
||||
static constexpr lp_id_t int64Vec2Id = 4;
|
||||
|
||||
static constexpr uint32_t testSetId = 0;
|
||||
}
|
||||
|
||||
|
||||
class LocalPoolTestDataSet: public StaticLocalDataSet<3> {
|
||||
public:
|
||||
LocalPoolTestDataSet(HasLocalDataPoolIF* owner, uint32_t setId):
|
||||
StaticLocalDataSet(owner, setId) {
|
||||
}
|
||||
|
||||
ReturnValue_t assignPointers() {
|
||||
PoolVariableIF** rawVarArray = getContainer();
|
||||
localPoolVarUint8 = dynamic_cast<lp_var_t<uint8_t>*>(rawVarArray[0]);
|
||||
localPoolVarFloat = dynamic_cast<lp_var_t<float>*>(rawVarArray[1]);
|
||||
localPoolUint16Vec = dynamic_cast<lp_vec_t<uint16_t, 3>*>(
|
||||
rawVarArray[2]);
|
||||
if(localPoolVarUint8 == nullptr or localPoolVarFloat == nullptr or
|
||||
localPoolUint16Vec == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
lp_var_t<uint8_t>* localPoolVarUint8 = nullptr;
|
||||
lp_var_t<float>* localPoolVarFloat = nullptr;
|
||||
lp_vec_t<uint16_t, 3>* localPoolUint16Vec = nullptr;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF {
|
||||
public:
|
||||
LocalPoolOwnerBase(
|
||||
object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE):
|
||||
SystemObject(objectId), hkManager(this, messageQueue) {
|
||||
messageQueue = QueueFactory::instance()->createMessageQueue(10);
|
||||
SystemObject(objectId), hkManager(this, messageQueue),
|
||||
dataset(this, lpool::testSetId) {
|
||||
messageQueue = new MessageQueueMockBase();
|
||||
}
|
||||
|
||||
~LocalPoolOwnerBase() {
|
||||
@ -89,22 +120,34 @@ public:
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override {
|
||||
// empty for now
|
||||
return nullptr;
|
||||
return &dataset;
|
||||
}
|
||||
|
||||
MessageQueueMockBase* getMockQueueHandle() const {
|
||||
return dynamic_cast<MessageQueueMockBase*>(messageQueue);
|
||||
}
|
||||
|
||||
void subscribeWrapperSetUpdate() {
|
||||
hkManager.subscribeForSetUpdateMessages(lpool::testSetId,
|
||||
objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false);
|
||||
}
|
||||
|
||||
LocalDataPoolManager hkManager;
|
||||
LocalPoolTestDataSet dataset;
|
||||
private:
|
||||
|
||||
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<uint8_t> testUint8 = lp_var_t<uint8_t>(this, lpool::uint8VarId,
|
||||
&dataset);
|
||||
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId,
|
||||
&dataset);
|
||||
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,
|
||||
lpool::uint16Vec3Id);
|
||||
lpool::uint16Vec3Id, &dataset);
|
||||
lp_vec_t<int64_t, 2> testInt64Vec = lp_vec_t<int64_t, 2>(this,
|
||||
lpool::int64Vec2Id);
|
||||
|
||||
MessageQueueIF* messageQueue = nullptr;
|
||||
LocalDataPoolManager hkManager;
|
||||
|
||||
bool initialized = false;
|
||||
bool initializedAfterTaskCreation = false;
|
||||
|
Reference in New Issue
Block a user