1
0
forked from fsfw/fsfw

more tests added

This commit is contained in:
2021-01-10 13:58:33 +01:00
parent 918200e88c
commit b570da6467
6 changed files with 131 additions and 31 deletions

View File

@ -3,6 +3,7 @@
#include <catch2/catch_test_macros.hpp>
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/ipc/CommandMessageCleaner.h>
#include <unittest/core/CatchDefinitions.h>
@ -17,12 +18,49 @@ TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
MessageQueueMockBase* mqMock = poolOwner->getMockQueueHandle();
REQUIRE(mqMock != nullptr);
poolOwner->subscribeWrapperSetUpdate();
SECTION("BasicTest") {
// Subscribe for message generation on update.
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
// Subscribe for an update message.
poolOwner->dataset.setChanged(true);
// Now the update message should be generated.
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(mqMock->wasMessageSent() == true);
CommandMessage messageSent;
uint8_t messagesSent = 0;
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
CHECK(messageSent.getCommand() == static_cast<int>(
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
// Should have been reset.
CHECK(poolOwner->dataset.hasChanged() == false);
// Set changed again, result should be the same.
poolOwner->dataset.setChanged(true);
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 1);
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
CHECK(messageSent.getCommand() == static_cast<int>(
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
// now subscribe for set update HK as well.
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
poolOwner->dataset.setChanged(true);
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
CHECK(messagesSent == 2);
// first message sent should be the update notification, considering
// the internal list is a vector checked in insertion order.
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);
}
}

View File

@ -18,6 +18,8 @@ static constexpr lp_id_t uint16Vec3Id = 3;
static constexpr lp_id_t int64Vec2Id = 4;
static constexpr uint32_t testSetId = 0;
static const sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE,
testSetId);
}
@ -123,12 +125,27 @@ public:
return &dataset;
}
virtual LocalPoolObjectBase* getPoolObjectHandle(
lp_id_t localPoolId) override {
return &testUint8;
}
MessageQueueMockBase* getMockQueueHandle() const {
return dynamic_cast<MessageQueueMockBase*>(messageQueue);
}
void subscribeWrapperSetUpdate() {
hkManager.subscribeForSetUpdateMessages(lpool::testSetId,
ReturnValue_t subscribeWrapperSetUpdate() {
return hkManager.subscribeForSetUpdateMessages(lpool::testSetId,
objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false);
}
ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false) {
return hkManager.subscribeForUpdatePackets(lpool::testSid, diagnostics,
false, objects::HK_RECEIVER_MOCK);
}
ReturnValue_t subscribeWrapperVariableUpdate() {
return hkManager.subscribeForSetUpdateMessages(lpool::testSetId,
objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false);
}