/** * 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 #if EPICS_VERSION_INT>=VERSION_INT(3,15,6,0) && EPICS_VERSION_INT=VERSION_INT(7,0,2,0) # define HAVE_ENV_UNSET #endif using namespace pvxs; namespace std { ostream& operator<<(ostream& strm, const vector& v) { strm<<"["; bool first=true; for(auto& e : v) { if(first) first = false; else strm<<", "; strm<<'"'<({"1.2.1.2:1234", "4.3.2.1:1234"})); testEq(conf.interfaces, std::vector({"1.1.1.1", "1.2.3.4"})); } { server::Config::defs_t defs; server::Config conf; conf.udp_port = 1234; conf.tcp_port = 5678; conf.interfaces = {"1.2.3.4", "1.1.1.1"}; conf.beaconDestinations = {"1.2.1.2", "4.3.2.1:1234"}; conf.auto_beacon = false; conf.updateDefs(defs); testEq(defs["EPICS_PVA_BROADCAST_PORT"], "1234"); testEq(defs["EPICS_PVAS_BROADCAST_PORT"], "1234"); testEq(defs["EPICS_PVA_SERVER_PORT"], "5678"); testEq(defs["EPICS_PVAS_SERVER_PORT"], "5678"); testEq(defs["EPICS_PVA_AUTO_ADDR_LIST"], "NO"); testEq(defs["EPICS_PVAS_AUTO_BEACON_ADDR_LIST"], "NO"); testEq(defs["EPICS_PVA_ADDR_LIST"], "1.2.1.2 4.3.2.1:1234"); testEq(defs["EPICS_PVAS_BEACON_ADDR_LIST"], "1.2.1.2 4.3.2.1:1234"); testEq(defs["EPICS_PVA_INTF_ADDR_LIST"], "1.2.3.4 1.1.1.1"); testEq(defs["EPICS_PVAS_INTF_ADDR_LIST"], "1.2.3.4 1.1.1.1"); } { server::Config::defs_t defs; server::Config conf; defs["EPICS_PVAS_BROADCAST_PORT"] = "1234"; defs["EPICS_PVAS_SERVER_PORT"] = "5678"; defs["EPICS_PVAS_AUTO_BEACON_ADDR_LIST"] = "NO"; defs["EPICS_PVAS_BEACON_ADDR_LIST"] = "1.2.1.2 4.3.2.1:1234"; defs["EPICS_PVAS_INTF_ADDR_LIST"] = "1.2.3.4 1.1.1.1"; conf.applyDefs(defs); testEq(conf.udp_port, 1234); testEq(conf.tcp_port, 5678); testFalse(conf.auto_beacon); testEq(conf.beaconDestinations, std::vector({"1.2.1.2:1234", "4.3.2.1:1234"})); testEq(conf.interfaces, std::vector({"1.1.1.1:5678", "1.2.3.4:5678"})); } } void testServerAuto() { testShow()<<__func__; /* We assume that the test host has at least * one interface other than localhost configured. * It need not be usable (eg. due to firewall). */ server::Config conf; conf.expand(); testFalse(conf.interfaces.empty())<