mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Shmem: track number of message objects, throw if non-zero at reset
This commit is contained in:
committed by
Dennis Klein
parent
5b5fecc994
commit
684e711b8b
@@ -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
|
||||
|
Reference in New Issue
Block a user