/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #ifndef TESTIOC_H #define TESTIOC_H #include #include #include #include #include #include #include #include struct TestClient : pvxs::client::Context { TestClient() : pvxs::client::Context(pvxs::ioc::server().clientConfig().build()) {} }; struct TestSubscription { epicsEvent evt; const std::shared_ptr sub; TestSubscription(pvxs::client::MonitorBuilder b) :sub(b.event([this](pvxs::client::Subscription& subscription) { testDiag("%s update event occurred", subscription.name().c_str()); evt.signal(); }).exec()) {} pvxs::Value waitForUpdate() { while (true) { if (auto value = sub->pop()) { testDiag("Update %s", sub->name().c_str()); return value; } else if (!evt.wait(5.0)) { testFail("timeout waiting for event for %s", sub->name().c_str()); return {}; } } } void testEmpty() { while (true) { if (auto value = sub->pop()) { testTrue(false)<<" Unexpected update for "<name()<<"\n" <name().c_str()); return; } } } }; template void testFldEq(const pvxs::Value& top, const char* fldname, const T& expect) { if(auto fld = top[fldname]) { T actual; if(fld.as(actual)) { testEq(expect, actual); } else { testFalse(false)<<" unable to convert "< %ld", pv, dbrType, count, status); done: if(chan) dbChannelDelete(chan); } #endif #endif // TESTIOC_H