From 3e0748d488f308e986030cc035f9051580c93425 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 26 May 2018 13:23:04 -0400 Subject: [PATCH] testCa: Adjust test output The DEBUG flag must be 0 when running under a test harness to remove extraneous output which can confuse the output parser. This commit also converts some throws into tests, and adds more test diagnostic messages. --- testCa/testCaProvider.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/testCa/testCaProvider.cpp b/testCa/testCaProvider.cpp index 4f623aa..52c37ac 100644 --- a/testCa/testCaProvider.cpp +++ b/testCa/testCaProvider.cpp @@ -26,6 +26,9 @@ #include #include +// DEBUG must be 0 to run under the automated test harness +#define DEBUG 0 + using namespace epics::pvData; using namespace epics::pvAccess; using namespace epics::pvAccess::ca; @@ -584,7 +587,7 @@ void TestClient::getDone( testOk(pvStructure->getSubField("value")!=NULL,"value not null"); testOk(pvStructure->getSubField("timeStamp")!=NULL,"timeStamp not null"); testOk(pvStructure->getSubField("alarm")!=NULL,"alarm not null"); - std::cout << testChannel->getChannelName() + " TestClient::getDone" + if (DEBUG) std::cout << testChannel->getChannelName() + " TestClient::getDone" << " bitSet " << *bitSet << " pvStructure\n" << pvStructure << "\n"; waitForGet.signal(); @@ -599,35 +602,38 @@ void TestClient::monitorEvent( PVStructure::shared_pointer const & pvStructure, BitSet::shared_pointer const & bitSet) { - std::cout << testChannel->getChannelName() + " TestClient::monitorEvent" + if (DEBUG) std::cout << testChannel->getChannelName() + " TestClient::monitorEvent" << " bitSet " << *bitSet << " pvStructure\n" << pvStructure << "\n"; } void TestClient::get() { -cout << "TestClient::get() calling get\n"; + testDiag("TestClient::get %s", + testChannel->getChannelName().c_str()); testChannelGet->get(); -cout << "TestClient::get() calling waitGet\n"; + if (DEBUG) cout << "TestClient::get() calling waitGet\n"; waitGet(5.0); } void TestClient::waitGet(double timeout) { - if(waitForGet.wait(timeout)) return; - throw std::runtime_error(testChannel->getChannelName() + " TestClient::waitGet failed "); + testOk(waitForGet.wait(timeout), + "waitGet(%s) succeeded", testChannel->getChannelName().c_str()); } void TestClient::put(string const & value) { + testDiag("TestClient::put %s := %s", + testChannel->getChannelName().c_str(), value.c_str()); testChannelPut->put(value); waitPut(5.0); } void TestClient::waitPut(double timeout) { - if(waitForPut.wait(timeout)) return; - throw std::runtime_error(testChannel->getChannelName() + " TestClient::waitPut failed "); + testOk(waitForPut.wait(timeout), + "waitPut(%s) succeeded", testChannel->getChannelName().c_str()); } void TestClient::stopEvents() @@ -686,7 +692,7 @@ MAIN(testCaProvider) TestIocPtr testIoc(new TestIoc()); testIoc->start(); - testPlan(56); + testPlan(84); testDiag("===Test caProvider==="); CAClientFactory::start(); ChannelProviderRegistry::shared_pointer reg(ChannelProviderRegistry::clients());