From bd9fcd8586b8ae72d4813a3095d70a8be77d4d65 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 30 Nov 2021 10:40:58 -0800 Subject: [PATCH] add testwild test behavior when binding to ipv4/6 wildcard interfaces --- test/Makefile | 4 ++ test/testwild.cpp | 111 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 test/testwild.cpp diff --git a/test/Makefile b/test/Makefile index 1a4b541..13ebb95 100644 --- a/test/Makefile +++ b/test/Makefile @@ -62,6 +62,10 @@ TESTPROD_HOST += testconfig testconfig_SRCS += testconfig.cpp TESTS += testconfig +TESTPROD_HOST += testwild +testwild_SRCS += testwild.cpp +TESTS += testwild + TESTPROD_HOST += testpvreq testpvreq_SRCS += testpvreq.cpp TESTS += testpvreq diff --git a/test/testwild.cpp b/test/testwild.cpp new file mode 100644 index 0000000..dc11797 --- /dev/null +++ b/test/testwild.cpp @@ -0,0 +1,111 @@ +/** + * 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; + +// Ensure we can setup a server and client on the wildcard interface(s). +// bind()ing sockets and similar. +// No operations are attempted as the default interface on some test systems +// may have firewall rules blocking PVA traffic in and/or out. +void testwildcard(const std::string& addr1, const std::string& addr2) +{ + testDiag("%s(%s, %s)", __func__,addr1.c_str(), addr2.c_str()); + + server::Config sconf; + sconf.tcp_port = sconf.udp_port = 0u; // choose randomly + + if(!addr1.empty()) + sconf.interfaces.push_back(addr1); + if(!addr2.empty()) + sconf.interfaces.push_back(addr2); + + auto serv(sconf.build()); + sconf = serv.config(); + testShow()<<"Server Config\n"<