a lot of bugfixes and important api change
This commit is contained in:
21
unittest/tests/datapoollocal/DataSetTest.cpp
Normal file
21
unittest/tests/datapoollocal/DataSetTest.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "LocalPoolOwnerBase.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||
#include <unittest/core/CatchDefinitions.h>
|
||||
|
||||
TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
|
||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
REQUIRE(poolOwner != nullptr);
|
||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||
== retval::CATCH_OK);
|
||||
|
||||
SECTION("BasicTest") {
|
||||
//StaticLocalDataSet<3> localSet = StaticLocalDataSet<3>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVector.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <testcfg/objects/systemObjectList.h>
|
||||
|
||||
@ -11,9 +12,12 @@ namespace lpool {
|
||||
static constexpr lp_id_t uint8VarId = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF {
|
||||
public:
|
||||
LocalPoolOwnerBase(
|
||||
@ -31,12 +35,19 @@ public:
|
||||
}
|
||||
|
||||
ReturnValue_t initializeHkManager() {
|
||||
return hkManager.initialize(messageQueue);
|
||||
|
||||
if(not initialized) {
|
||||
initialized = true;
|
||||
return hkManager.initialize(messageQueue);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t initializeHkManagerAfterTaskCreation() {
|
||||
return hkManager.initializeAfterTaskCreation();
|
||||
if(not initializedAfterTaskCreation) {
|
||||
initializedAfterTaskCreation = true;
|
||||
return hkManager.initializeAfterTaskCreation();
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
/** Command queue for housekeeping messages. */
|
||||
@ -44,12 +55,22 @@ public:
|
||||
return messageQueue->getId();
|
||||
}
|
||||
|
||||
// This is called by initializeAfterTaskCreation of the HK manager.
|
||||
virtual ReturnValue_t initializeLocalDataPool(
|
||||
LocalDataPool& 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::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;
|
||||
}
|
||||
|
||||
@ -77,9 +98,17 @@ private:
|
||||
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_vec_t<uint16_t, 3> testUint16Vec = lp_vec_t<uint16_t, 3>(this,
|
||||
lpool::uint16Vec3Id);
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
#endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */
|
||||
|
@ -6,9 +6,11 @@
|
||||
|
||||
|
||||
TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
||||
LocalPoolOwnerBase poolOwner(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK);
|
||||
REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation()
|
||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
REQUIRE(poolOwner != nullptr);
|
||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||
== retval::CATCH_OK);
|
||||
|
||||
SECTION("Basic Tests") {
|
||||
@ -26,6 +28,18 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
||||
testVariable.setValid(true);
|
||||
CHECK(testVariable.isValid());
|
||||
|
||||
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ);
|
||||
CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ);
|
||||
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE);
|
||||
|
||||
testVariable.setDataPoolId(22);
|
||||
CHECK(testVariable.getDataPoolId() == 22);
|
||||
testVariable.setDataPoolId(lpool::uint8VarId);
|
||||
|
||||
testVariable.setChanged(true);
|
||||
CHECK(testVariable.hasChanged());
|
||||
testVariable.setChanged(false);
|
||||
|
||||
gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE,
|
||||
lpool::uint8VarId);
|
||||
lp_var_t<uint8_t> testVariable2 = lp_var_t<uint8_t>(globPoolId);
|
||||
@ -93,6 +107,15 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "LocalPoolVariable printout: " <<uint32tVar << std::endl;
|
||||
#endif
|
||||
|
||||
// for code coverage. If program does not crash -> OK
|
||||
lp_var_t<uint8_t> invalidObjectVar = lp_var_t<uint8_t>(
|
||||
0xffffffff, lpool::uint8VarId);
|
||||
gp_id_t globPoolId(0xffffffff,
|
||||
lpool::uint8VarId);
|
||||
lp_var_t<uint8_t> invalidObjectVar2 = lp_var_t<uint8_t>(globPoolId);
|
||||
lp_var_t<uint8_t> invalidObjectVar3 = lp_var_t<uint8_t>(nullptr,
|
||||
lpool::uint8VarId);
|
||||
}
|
||||
|
||||
}
|
||||
|
16
unittest/tests/datapoollocal/LocalPoolVectorTest.cpp
Normal file
16
unittest/tests/datapoollocal/LocalPoolVectorTest.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "LocalPoolOwnerBase.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||
#include <unittest/core/CatchDefinitions.h>
|
||||
|
||||
TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
|
||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
REQUIRE(poolOwner != nullptr);
|
||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||
== retval::CATCH_OK);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user