/** * 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. */ #include #include #include #include #include #include #include #include #include #include #include "utilpvt.h" namespace { using namespace pvxs; void testNameServer() { testShow()<<__func__; auto pv(server::SharedPV::buildReadonly()); pv.open(nt::NTScalar{TypeCode::UInt32}.create() .update("value", 42u)); auto serv(server::Config::isolated() .build() .addPV("testpv", pv) .start()); testShow()<<"Server config\n"< std::exception_ptr { while(true) { if(auto var = mon->pop()) { throw std::runtime_error(SB()<<" Unexpected update\n"<pop()) { testEq(var["value"].as(), 42u); return; } if(!update.wait(500.0)) throw std::runtime_error(SB()<<" Timeout"); } catch(std::exception& e) { testTrue(false)<<" Unexpected update: "<([&popExc]() { popExc(); }); popVal(); testDiag("Stopping server"); serv.stop(); testThrows([&popExc]() { popExc(); }); testDiag("Restarting server"); serv.start(); testThrows([&popExc]() { popExc(); }); popVal(); } } // namespace MAIN(testnamesrv) { testPlan(5); testSetup(); logger_config_env(); testNameServer(); cleanup_for_valgrind(); return testDone(); }