snapshot test added, bugfix
This commit is contained in:
parent
3789663db7
commit
03936fc5c1
@ -132,13 +132,16 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() {
|
||||
ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver,
|
||||
ReturnValue_t& status) {
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
// Update packets shall only be generated from datasets.
|
||||
/* Update packets shall only be generated from datasets. */
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
|
||||
receiver.dataId.sid);
|
||||
if(dataSet == nullptr) {
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update notification
|
||||
/* Prepare and send update notification */
|
||||
ReturnValue_t result = generateHousekeepingPacket(
|
||||
receiver.dataId.sid, dataSet, true);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -328,7 +331,7 @@ void LocalDataPoolManager::handleChangeResetLogic(
|
||||
toReset->setChanged(false);
|
||||
}
|
||||
/* All recipients have been notified, reset the changed flag */
|
||||
if(changeInfo.currentUpdateCounter <= 1) {
|
||||
else if(changeInfo.currentUpdateCounter <= 1) {
|
||||
toReset->setChanged(false);
|
||||
changeInfo.currentUpdateCounter = 0;
|
||||
}
|
||||
@ -398,7 +401,6 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid,
|
||||
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
|
||||
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
//LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||
if(dataSet != nullptr) {
|
||||
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
|
||||
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
|
||||
@ -616,7 +618,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
LocalPoolDataSetBase* dataSet, bool forDownlink,
|
||||
MessageQueueId_t destination) {
|
||||
if(dataSet == nullptr) {
|
||||
// Configuration error.
|
||||
/* Configuration error. */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"generateHousekeepingPacket",
|
||||
DATASET_NOT_FOUND);
|
||||
@ -632,7 +634,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
return result;
|
||||
}
|
||||
|
||||
// and now we set a HK message and send it the HK packet destination.
|
||||
/* Now we set a HK message and send it the HK packet destination. */
|
||||
CommandMessage hkMessage;
|
||||
if(LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
|
||||
HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId);
|
||||
@ -642,7 +644,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
}
|
||||
|
||||
if(hkQueue == nullptr) {
|
||||
// error, no queue available to send packet with.
|
||||
/* Error, no queue available to send packet with. */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"generateHousekeepingPacket",
|
||||
QUEUE_OR_DESTINATION_INVALID);
|
||||
@ -650,7 +652,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
}
|
||||
if(destination == MessageQueueIF::NO_QUEUE) {
|
||||
if(hkDestinationId == MessageQueueIF::NO_QUEUE) {
|
||||
// error, all destinations invalid
|
||||
/* Error, all destinations invalid */
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"generateHousekeepingPacket",
|
||||
QUEUE_OR_DESTINATION_INVALID);
|
||||
@ -831,6 +833,9 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
||||
void LocalDataPoolManager::clearReceiversList() {
|
||||
/* Clear the vector completely and releases allocated memory. */
|
||||
HkReceivers().swap(hkReceivers);
|
||||
if(hkUpdateResetList != nullptr) {
|
||||
HkUpdateResetList().swap(*hkUpdateResetList);
|
||||
}
|
||||
}
|
||||
|
||||
MutexIF* LocalDataPoolManager::getLocalPoolMutex() {
|
||||
|
@ -76,7 +76,7 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
||||
|
||||
}
|
||||
|
||||
SECTION("SnapshotUpdateTests") {
|
||||
SECTION("SetSnapshotUpdateTest") {
|
||||
/* Set the variables in the set to certain values. These are checked later. */
|
||||
{
|
||||
PoolReadGuard readHelper(&poolOwner->dataset);
|
||||
@ -141,7 +141,31 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
||||
CHECK(cdsShort.msDay_ll == Catch::Approx(timeCdsNow.msDay_ll).margin(1));
|
||||
}
|
||||
|
||||
SECTION("AdvancedTests") {
|
||||
SECTION("VariableSnapshotTest") {
|
||||
/* Acquire subscription interface */
|
||||
ProvidesDataPoolSubscriptionIF* subscriptionIF = poolOwner->getSubscriptionInterface();
|
||||
REQUIRE(subscriptionIF != nullptr);
|
||||
|
||||
/* Subscribe for variable snapshot */
|
||||
REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == retval::CATCH_OK);
|
||||
auto poolVar = dynamic_cast<lp_var_t<uint8_t>*>(
|
||||
poolOwner->getPoolObjectHandle(lpool::uint8VarId));
|
||||
REQUIRE(poolVar != nullptr);
|
||||
poolVar->setChanged(true);
|
||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||
|
||||
/* Check update snapshot was sent. */
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 1);
|
||||
|
||||
/* Should have been reset. */
|
||||
CHECK(poolVar->hasChanged() == false);
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE));
|
||||
}
|
||||
|
||||
SECTION("VariableUpdateTest") {
|
||||
/* Acquire subscription interface */
|
||||
ProvidesDataPoolSubscriptionIF* subscriptionIF = poolOwner->getSubscriptionInterface();
|
||||
REQUIRE(subscriptionIF != nullptr);
|
||||
@ -153,6 +177,7 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
||||
poolOwner->getPoolObjectHandle(lpool::uint8VarId));
|
||||
REQUIRE(poolVar != nullptr);
|
||||
poolVar->setChanged(true);
|
||||
REQUIRE(poolVar->hasChanged() == true);
|
||||
REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK);
|
||||
|
||||
/* Check update notification was sent. */
|
||||
@ -204,6 +229,22 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
||||
/* Now HK packet should be sent as message. */
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 1);
|
||||
|
||||
LocalPoolDataSetBase* setHandle = poolOwner->getDataSetHandle(lpool::testSid);
|
||||
REQUIRE(setHandle != nullptr);
|
||||
CHECK(poolOwner->poolManager.generateHousekeepingPacket(lpool::testSid,
|
||||
setHandle, false) == retval::CATCH_OK);
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 1);
|
||||
|
||||
CHECK(setHandle->getReportingEnabled() == true);
|
||||
CommandMessage hkCmd;
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false);
|
||||
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||
CHECK(setHandle->getReportingEnabled() == false);
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false);
|
||||
CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||
CHECK(setHandle->getReportingEnabled() == true);
|
||||
}
|
||||
|
||||
/* we need to reset the subscription list because the pool owner
|
||||
|
@ -193,6 +193,11 @@ public:
|
||||
MessageQueueIF::NO_QUEUE, objects::HK_RECEIVER_MOCK, false);
|
||||
}
|
||||
|
||||
ReturnValue_t subscribeWrapperVariableSnapshot(lp_id_t localPoolId) {
|
||||
return poolManager.subscribeForVariableUpdateMessage(localPoolId,
|
||||
MessageQueueIF::NO_QUEUE, objects::HK_RECEIVER_MOCK, true);
|
||||
}
|
||||
|
||||
ReturnValue_t reset() {
|
||||
resetSubscriptionList();
|
||||
ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user