Skip to content

Commit

Permalink
iox-eclipse-iceoryx#454 updated the sendMQ fail test function
Browse files Browse the repository at this point in the history
Signed-off-by: Chiranjeevi Maddi (RBEI/EBB1) <[email protected]>
  • Loading branch information
chiranjeevimaddi committed Jan 8, 2021
1 parent 31ee8de commit 4437cf0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions iceoryx_posh/source/roudi/roudi_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ const ProcessName_t RouDiProcess::getName() const noexcept

void RouDiProcess::sendToMQ(const runtime::MqMessage& data) noexcept
{
auto sendSuccess = m_mq.send(data);
if (sendSuccess == false)
bool sendSuccess = m_mq.send(data);
if (!sendSuccess)
{
LogWarn() << "RouDiProcess cannot send data via MQ ";
LogWarn() << "RouDiProcess cannot send message over communication channel";
errorHandler(Error::kPOSH__ROUDI_PROCESS_SENDMQ_FAILED, nullptr, ErrorLevel::SEVERE);
}
}
Expand Down
13 changes: 12 additions & 1 deletion iceoryx_posh/test/moduletests/test_roudi_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,19 @@ TEST_F(RouDiProcess_test, sendToMQPass)
TEST_F(RouDiProcess_test, sendToMQFail)
{
iox::runtime::MqMessage data{""};
iox::cxx::optional<iox::Error> sendtoMQStatusFail;

auto errorHandlerGuard = iox::ErrorHandler::SetTemporaryErrorHandler(
[&sendtoMQStatusFail](const iox::Error error, const std::function<void()>, const iox::ErrorLevel errorLevel) {
sendtoMQStatusFail.emplace(error);
EXPECT_THAT(errorLevel, Eq(iox::ErrorLevel::SEVERE));
});

RouDiProcess roudiproc(processname, pid, payloadMemoryManager, isMonitored, payloadSegmentId, sessionId);
EXPECT_DEATH(roudiproc.sendToMQ(data), "RouDiProcess cannot send data via MQ");
roudiproc.sendToMQ(data);

ASSERT_THAT(sendtoMQStatusFail.has_value(), Eq(true));
EXPECT_THAT(sendtoMQStatusFail.value(), Eq(iox::Error::kPOSH__ROUDI_PROCESS_SENDMQ_FAILED));
}

TEST_F(RouDiProcess_test, TimeStamp)
Expand Down

0 comments on commit 4437cf0

Please sign in to comment.