Skip to content

Exec testFail instead of exit(3) if channel is not connected #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions test/src/testChannelMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ class ChannelRequesterImpl : public ChannelRequester
{
private:
Event event;
bool connected;

public:
ChannelRequesterImpl() : connected(false) {}

virtual string getRequesterName()
{
Expand Down Expand Up @@ -167,17 +169,18 @@ class ChannelRequesterImpl : public ChannelRequester
virtual void channelStateChange(const Channel::shared_pointer& /*channel*/, Channel::ConnectionState connectionState)
{
if (connectionState == Channel::CONNECTED) {
event.signal();
}
else {
connected = true;
} else {
cout << Channel::ConnectionStateNames[connectionState] << endl;
exit(3);
connected = false;
}
event.signal();
}

bool waitUntilConnected(double timeOut)
{
return event.wait(timeOut);
event.wait(timeOut);
return connected;
}
};

Expand Down Expand Up @@ -207,8 +210,11 @@ static void test()
TR1::shared_ptr<ChannelRequesterImpl> channelRequesterImpl(new ChannelRequesterImpl());

Channel::shared_pointer channel = provider->createChannel(recordName, channelRequesterImpl);
bool channelConnected = channelRequesterImpl->waitUntilConnected(1.0);
bool channelConnected = channelRequesterImpl->waitUntilConnected(2.0);
testOk1(channelConnected);
if (!channelConnected) {
testAbort("Channel did not reach CONNECTED state");
}
if (channelConnected) {
string remoteAddress = channel->getRemoteAddress();
cout << "remote address: " << remoteAddress << endl;
Expand All @@ -218,7 +224,7 @@ static void test()
PVStructure::shared_pointer pvRequest = CreateRequest::create()->createRequest(request);
TR1::shared_ptr<ChannelMonitorRequesterImpl> cmRequesterImpl(new ChannelMonitorRequesterImpl(channel->getChannelName()));
Monitor::shared_pointer monitor = channel->createMonitor(cmRequesterImpl, pvRequest);
bool monitorConnected = cmRequesterImpl->waitUntilConnected(1.0);
bool monitorConnected = cmRequesterImpl->waitUntilConnected(2.0);
testOk1(monitorConnected);
Status status = monitor->start();
testOk1(status.isOK());
Expand Down Expand Up @@ -280,7 +286,7 @@ static void test()
pvRequest = CreateRequest::create()->createRequest(request);
cmRequesterImpl = TR1::shared_ptr<ChannelMonitorRequesterImpl>(new ChannelMonitorRequesterImpl(channel->getChannelName()));
monitor = channel->createMonitor(cmRequesterImpl, pvRequest);
monitorConnected = cmRequesterImpl->waitUntilConnected(1.0);
monitorConnected = cmRequesterImpl->waitUntilConnected(2.0);
testOk1(monitorConnected);
status = monitor->start();
testOk1(status.isOK());
Expand Down