Shmem: track number of message objects, throw if non-zero at reset

This commit is contained in:
Alexey Rybalchenko
2019-12-19 15:06:14 +01:00
committed by Dennis Klein
parent 5b5fecc994
commit 684e711b8b
5 changed files with 63 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
#include <gtest/gtest.h>
#include <boost/process.hpp>
#include <fairmq/Tools.h>
#include <FairMQDevice.h>
#include <string>
#include <thread>
@@ -23,6 +24,39 @@ using namespace std;
using namespace fair::mq::test;
using namespace fair::mq::tools;
class BadDevice : public FairMQDevice
{
public:
BadDevice()
{
fDeviceThread = thread([&](){
EXPECT_THROW(RunStateMachine(), fair::mq::MessageError);
});
SetTransport("shmem");
ChangeState(fair::mq::Transition::InitDevice);
WaitForState(fair::mq::State::InitializingDevice);
ChangeState(fair::mq::Transition::CompleteInit);
WaitForState(fair::mq::State::Initialized);
parts.AddPart(NewMessage());
}
~BadDevice()
{
ChangeState(fair::mq::Transition::ResetDevice);
if (fDeviceThread.joinable()) {
fDeviceThread.join();
}
}
private:
thread fDeviceThread;
FairMQParts parts;
};
void RunErrorStateIn(const string& state, const string& control, const string& input = "")
{
size_t session{fair::mq::tools::UuidHash()};
@@ -118,4 +152,9 @@ TEST(ErrorState, interactive_InReset)
EXPECT_EXIT(RunErrorStateIn("Reset", "interactive", "q"), ::testing::ExitedWithCode(1), "");
}
TEST(ErrorState, OrphanMessages)
{
BadDevice badDevice;
}
} // namespace