@ -49,8 +49,8 @@ namespace ares {
namespace test {
namespace test {
bool verbose = false ;
bool verbose = false ;
static constexpr int dynamic_port = 0 ;
static constexpr uns ig ned shor t dynamic_port = 0 ;
int mock_port = dynamic_port ;
uns ig ned shor t mock_port = dynamic_port ;
const std : : vector < int > both_families = { AF_INET , AF_INET6 } ;
const std : : vector < int > both_families = { AF_INET , AF_INET6 } ;
const std : : vector < int > ipv4_family = { AF_INET } ;
const std : : vector < int > ipv4_family = { AF_INET } ;
@ -195,7 +195,7 @@ void DefaultChannelModeTest::Process() {
ProcessWork ( channel_ , NoExtraFDs , nullptr ) ;
ProcessWork ( channel_ , NoExtraFDs , nullptr ) ;
}
}
MockServer : : MockServer ( int family , int port )
MockServer : : MockServer ( int family , uns ig ned shor t port )
: udpport_ ( port ) , tcpport_ ( port ) , qid_ ( - 1 ) {
: udpport_ ( port ) , tcpport_ ( port ) , qid_ ( - 1 ) {
// Create a TCP socket to receive data on.
// Create a TCP socket to receive data on.
tcp_data_ = NULL ;
tcp_data_ = NULL ;
@ -456,11 +456,11 @@ void MockServer::ProcessRequest(ares_socket_t fd, struct sockaddr_storage* addr,
}
}
// static
// static
MockChannelOptsTest : : NiceMockServers MockChannelOptsTest : : BuildServers ( int count , int family , int base_port ) {
MockChannelOptsTest : : NiceMockServers MockChannelOptsTest : : BuildServers ( int count , int family , uns ig ned shor t base_port ) {
NiceMockServers servers ;
NiceMockServers servers ;
assert ( count > 0 ) ;
assert ( count > 0 ) ;
for ( int ii = 0 ; ii < count ; ii + + ) {
for ( uns ig ned shor t ii = 0 ; ii < count ; ii + + ) {
int port = base_port = = dynamic_port ? dynamic_port : base_port + ii ;
uns ig ned shor t port = base_port = = dynamic_port ? dynamic_port : base_port + ii ;
std : : unique_ptr < NiceMockServer > server ( new NiceMockServer ( family , port ) ) ;
std : : unique_ptr < NiceMockServer > server ( new NiceMockServer ( family , port ) ) ;
servers . push_back ( std : : move ( server ) ) ;
servers . push_back ( std : : move ( server ) ) ;
}
}
@ -483,9 +483,9 @@ MockChannelOptsTest::MockChannelOptsTest(int count,
}
}
// Point the library at the first mock server by default (overridden below).
// Point the library at the first mock server by default (overridden below).
opts . udp_port = ( unsigned short ) server_ . udpport ( ) ;
opts . udp_port = server_ . udpport ( ) ;
optmask | = ARES_OPT_UDP_PORT ;
optmask | = ARES_OPT_UDP_PORT ;
opts . tcp_port = ( unsigned short ) server_ . tcpport ( ) ;
opts . tcp_port = server_ . tcpport ( ) ;
optmask | = ARES_OPT_TCP_PORT ;
optmask | = ARES_OPT_TCP_PORT ;
// If not already overridden, set short-ish timeouts.
// If not already overridden, set short-ish timeouts.