/** * 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. */ #define PVXS_ENABLE_EXPERT_API #include #include #include #include #include #include #include #include #include #include #include #include "evhelper.h" namespace { using namespace pvxs; void testBeacon() { testShow()<<__func__; auto serv(server::Config::isolated().build()); auto guid(serv.config().guid); auto cli(serv.clientConfig().build()); MPMCFIFO q1; auto op1(cli.discover([&q1](const client::Discovered& evt){ testDiag("Event"); q1.push(evt); }).pingAll(false).exec()); serv.start(); MPMCFIFO q2; auto op2(cli.discover([&q2](const client::Discovered& evt){ testDiag("Event"); q2.push(evt); }).pingAll(true).exec()); testDiag("Waiting for discoveries"); { auto evt(q1.pop()); testEq(evt.event, client::Discovered::Online); testEq(evt.guid, guid); } { auto evt(q2.pop()); testEq(evt.event, client::Discovered::Online); testEq(evt.guid, guid); } serv.stop(); testDiag("Wait for timeouts"); { auto evt(q1.pop()); testEq(evt.event, client::Discovered::Timeout); testEq(evt.guid, guid); } { auto evt(q2.pop()); testEq(evt.event, client::Discovered::Timeout); testEq(evt.guid, guid); } } } // namespace MAIN(testdiscover) { testPlan(8); logger_config_env(); testSetup(); testBeacon(); logger_config_env(); cleanup_for_valgrind(); return testDone(); }