more tests
This commit is contained in:
parent
4fa9a1fe19
commit
6993415873
@ -820,6 +820,11 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalDataPoolManager::clearReceiversList() {
|
||||||
|
// clear the vector completely and releases allocated memory.
|
||||||
|
HkReceivers().swap(hkReceiversMap);
|
||||||
|
}
|
||||||
|
|
||||||
void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
|
void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
|
||||||
const char* functionName, ReturnValue_t error, const char* errorPrint) {
|
const char* functionName, ReturnValue_t error, const char* errorPrint) {
|
||||||
if(errorPrint == nullptr) {
|
if(errorPrint == nullptr) {
|
||||||
|
@ -250,6 +250,12 @@ public:
|
|||||||
LocalDataPoolManager(const LocalDataPoolManager &) = delete;
|
LocalDataPoolManager(const LocalDataPoolManager &) = delete;
|
||||||
LocalDataPoolManager operator=(const LocalDataPoolManager&) = delete;
|
LocalDataPoolManager operator=(const LocalDataPoolManager&) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function can be used to clear the receivers list. This is
|
||||||
|
* intended for test functions and not for regular operations, because
|
||||||
|
* the insertion operations allocate dynamically.
|
||||||
|
*/
|
||||||
|
void clearReceiversList();
|
||||||
private:
|
private:
|
||||||
LocalDataPool localPoolMap;
|
LocalDataPool localPoolMap;
|
||||||
//! Every housekeeping data manager has a mutex to protect access
|
//! Every housekeeping data manager has a mutex to protect access
|
||||||
|
@ -66,6 +66,7 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("AdvancedTests") {
|
SECTION("AdvancedTests") {
|
||||||
|
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) ==
|
||||||
@ -89,7 +90,31 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
|||||||
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);
|
||||||
|
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||||
|
// now two messages should be sent.
|
||||||
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
|
CHECK(messagesSent == 2);
|
||||||
|
mqMock->clearMessages(true);
|
||||||
|
|
||||||
|
poolOwner->dataset.setChanged(true);
|
||||||
|
poolVar->setChanged(true);
|
||||||
|
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||||
|
// now three messages should be sent.
|
||||||
|
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||||
|
CHECK(messagesSent == 3);
|
||||||
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
|
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||||
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
|
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||||
|
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||||
|
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||||
|
HousekeepingMessage::HK_REPORT));
|
||||||
|
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
||||||
|
REQUIRE(mqMock->receiveMessage(&messageSent) ==
|
||||||
|
static_cast<int>(MessageQueueIF::EMPTY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +168,10 @@ public:
|
|||||||
MessageQueueIF::NO_QUEUE, objects::NO_OBJECT, false);
|
MessageQueueIF::NO_QUEUE, objects::NO_OBJECT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resetSubscriptionList() {
|
||||||
|
hkManager.clearReceiversList();
|
||||||
|
}
|
||||||
|
|
||||||
LocalDataPoolManager hkManager;
|
LocalDataPoolManager hkManager;
|
||||||
LocalPoolTestDataSet dataset;
|
LocalPoolTestDataSet dataset;
|
||||||
private:
|
private:
|
||||||
|
@ -40,6 +40,10 @@ public:
|
|||||||
return receiveMessage(message);
|
return receiveMessage(message);
|
||||||
}
|
}
|
||||||
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) {
|
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) {
|
||||||
|
if(messagesSentQueue.empty()) {
|
||||||
|
return MessageQueueIF::EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
std::memcpy(message->getBuffer(), messagesSentQueue.front().getBuffer(),
|
std::memcpy(message->getBuffer(), messagesSentQueue.front().getBuffer(),
|
||||||
message->getMessageSize());
|
message->getMessageSize());
|
||||||
messagesSentQueue.pop();
|
messagesSentQueue.pop();
|
||||||
@ -95,8 +99,15 @@ public:
|
|||||||
return defaultDestSet;
|
return defaultDestSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearMessages() {
|
void clearMessages(bool clearCommandMessages = true) {
|
||||||
while(not messagesSentQueue.empty()) {
|
while(not messagesSentQueue.empty()) {
|
||||||
|
if(clearCommandMessages) {
|
||||||
|
CommandMessage message;
|
||||||
|
std::memcpy(message.getBuffer(),
|
||||||
|
messagesSentQueue.front().getBuffer(),
|
||||||
|
message.getMessageSize());
|
||||||
|
message.clear();
|
||||||
|
}
|
||||||
messagesSentQueue.pop();
|
messagesSentQueue.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user