Fixed an issue in host OSAL and added more coverage to IER
All checks were successful
fsfw/fsfw/pipeline/pr-master This commit looks good

This commit is contained in:
Steffen Gaisser 2022-02-22 13:37:28 +01:00
parent 45ea09291a
commit a50b52df51
4 changed files with 34 additions and 9 deletions

View File

@ -84,7 +84,7 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
return result;
}
printWarningOrError(sif::OutputTypes::OUT_WARNING, "initialize", HasReturnvaluesIF::RETURN_FAILED,
printWarningOrError(sif::OutputTypes::OUT_WARNING, "initializeHousekeepingPoolEntriesOnce", HasReturnvaluesIF::RETURN_FAILED,
"The map should only be initialized once");
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -125,6 +125,13 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
memcpy(targetQueue->messageQueue.back().data(), message->getBuffer(),
message->getMaximumMessageSize());
} else {
if (not ignoreFault) {
InternalErrorReporterIF* internalErrorReporter =
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
if (internalErrorReporter != nullptr) {
internalErrorReporter->queueMessageNotSent();
}
}
return MessageQueueIF::FULL;
}
return HasReturnvaluesIF::RETURN_OK;

View File

@ -23,6 +23,9 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
}
InternalErrorReporter* internalErrorReporter =
dynamic_cast<InternalErrorReporter*>(ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER));
if(internalErrorReporter == nullptr){
FAIL();
}
task.addComponent(objects::INTERNAL_ERROR_REPORTER);
MessageQueueIF* testQueue = QueueFactory::instance()->createMessageQueue(1);
MessageQueueIF* hkQueue = QueueFactory::instance()->createMessageQueue(1);
@ -34,8 +37,13 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
ActionMessage::setCompletionReply(&message, 10, true);
auto result = hkQueue->sendMessage(testQueue->getId(), &message);
REQUIRE(result == retval::CATCH_OK);
internalErrorReporter->performOperation(0);
uint32_t queueHits = 0;
uint32_t lostTm = 0;
uint32_t storeHits = 0;
/* We don't know if another test caused a queue Hit so we will enforce one,
then remeber the queueHit count and force another hit */
internalErrorReporter->queueMessageNotSent();
internalErrorReporter->performOperation(0);
{
CommandMessage hkMessage;
result = hkQueue->receiveMessage(&hkMessage);
@ -44,7 +52,8 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
store_address_t storeAddress;
gp_id_t gpid = HousekeepingMessage::getUpdateSnapshotVariableCommand(&hkMessage, &storeAddress);
REQUIRE(gpid.objectId == objects::INTERNAL_ERROR_REPORTER);
InternalErrorDataset dataset(objects::NO_OBJECT);
// We need the object ID of the reporter here (NO_OBJECT)
InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER);
CCSDSTime::CDS_short time;
ConstAccessorPair data = ipcStore->getData(storeAddress);
REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK);
@ -53,10 +62,15 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
size_t size = data.second.size();
result = hkSnapshot.deSerialize(&buffer, &size, SerializeIF::Endianness::MACHINE);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
// Remember the amount of queueHits before to see the increase
queueHits = dataset.queueHits.value;
lostTm = dataset.tmHits.value;
storeHits = dataset.storeHits.value;
}
result = hkQueue->sendMessage(testQueue->getId(), &message);
REQUIRE(result == MessageQueueIF::FULL);
internalErrorReporter->lostTm();
internalErrorReporter->storeFull();
{
internalErrorReporter->performOperation(0);
CommandMessage hkMessage;
@ -70,15 +84,19 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") {
ConstAccessorPair data = ipcStore->getData(storeAddress);
REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK);
CCSDSTime::CDS_short time;
InternalErrorDataset dataset(objects::NO_OBJECT);
// We need the object ID of the reporter here (NO_OBJECT)
InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER);
HousekeepingSnapshot hkSnapshot(&time, &dataset);
const uint8_t* buffer = data.second.data();
size_t size = data.second.size();
result = hkSnapshot.deSerialize(&buffer, &size, SerializeIF::Endianness::MACHINE);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(dataset.queueHits == (queueHits + 1));
// Test that we had one more queueHit
REQUIRE(dataset.queueHits.value == (queueHits + 1));
REQUIRE(dataset.tmHits.value == (lostTm + 1));
REQUIRE(dataset.storeHits.value == (storeHits + 1));
}
}
delete testQueue;
delete hkQueue;
QueueFactory::instance()->deleteMessageQueue(testQueue);
QueueFactory::instance()->deleteMessageQueue(hkQueue);
}

View File

@ -54,6 +54,6 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") {
CHECK(recvMessage.getData()[0] == 42);
}
// We have to clear MQs ourself ATM
delete testSenderMq;
delete testReceiverMq;
QueueFactory::instance()->deleteMessageQueue(testSenderMq);
QueueFactory::instance()->deleteMessageQueue(testReceiverMq);
}