@ -66,7 +66,7 @@ TEST(LibraryInit, Nested) {
TEST ( LibraryInit , BasicChannelInit ) {
EXPECT_EQ ( ARES_SUCCESS , ares_library_init ( ARES_LIB_INIT_ALL ) ) ;
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
EXPECT_NE ( nullptr , channel ) ;
ares_destroy ( channel ) ;
@ -112,11 +112,11 @@ TEST_F(LibraryTest, OptionsChannelInit) {
opts . hosts_path = strdup ( " /etc/hosts " ) ;
optmask | = ARES_OPT_HOSTS_FILE ;
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init_options ( & channel , & opts , optmask ) ) ;
EXPECT_NE ( nullptr , channel ) ;
ares_channel channel2 = nullptr ;
ares_channel_t * channel2 = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_dup ( & channel2 , channel ) ) ;
EXPECT_NE ( nullptr , channel2 ) ;
@ -148,7 +148,7 @@ TEST_F(LibraryTest, OptionsChannelInit) {
}
TEST_F ( LibraryTest , ChannelAllocFail ) {
ares_channel channel ;
ares_channel_t * channel ;
for ( int ii = 1 ; ii < = 25 ; ii + + ) {
ClearFails ( ) ;
SetAllocFail ( ii ) ;
@ -202,7 +202,7 @@ TEST_F(LibraryTest, OptionsChannelAllocFail) {
opts . hosts_path = strdup ( " /etc/hosts " ) ;
optmask | = ARES_OPT_HOSTS_FILE ;
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
for ( int ii = 1 ; ii < = 8 ; ii + + ) {
ClearFails ( ) ;
SetAllocFail ( ii ) ;
@ -225,7 +225,7 @@ TEST_F(LibraryTest, OptionsChannelAllocFail) {
ares_set_servers_csv ( channel , " 1.2.3.4,0102:0304:0506:0708:0910:1112:1314:1516,2.3.4.5 " ) ) ;
EXPECT_EQ ( ARES_SUCCESS , ares_set_sortlist ( channel , " 1.2.3.4 2.3.4.5 " ) ) ;
ares_channel channel2 = nullptr ;
ares_channel_t * channel2 = nullptr ;
for ( int ii = 1 ; ii < = 18 ; ii + + ) {
ClearFails ( ) ;
SetAllocFail ( ii ) ;
@ -254,7 +254,7 @@ TEST_F(LibraryTest, FailChannelInit) {
& LibraryTest : : afree ,
& LibraryTest : : arealloc ) ) ;
SetAllocFail ( 1 ) ;
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_ENOMEM , ares_init ( & channel ) ) ;
EXPECT_EQ ( nullptr , channel ) ;
ares_library_cleanup ( ) ;
@ -262,7 +262,7 @@ TEST_F(LibraryTest, FailChannelInit) {
# ifndef WIN32
TEST_F ( LibraryTest , EnvInit ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EnvValue v1 ( " LOCALDOMAIN " , " this.is.local " ) ;
EnvValue v2 ( " RES_OPTIONS " , " options debug ndots:3 retry:3 rotate retrans:2 " ) ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
@ -270,7 +270,7 @@ TEST_F(LibraryTest, EnvInit) {
}
TEST_F ( LibraryTest , EnvInitAllocFail ) {
ares_channel channel ;
ares_channel_t * channel ;
EnvValue v1 ( " LOCALDOMAIN " , " this.is.local " ) ;
EnvValue v2 ( " RES_OPTIONS " , " options debug ndots:3 retry:3 rotate retrans:2 " ) ;
for ( int ii = 1 ; ii < = 10 ; ii + + ) {
@ -324,7 +324,7 @@ TEST_F(DefaultChannelTest, SetSortlistAllocFail) {
# ifdef USE_WINSOCK
TEST ( Init , NoLibraryInit ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_ENOTINITIALIZED , ares_init ( & channel ) ) ;
}
# endif
@ -364,7 +364,7 @@ NameContentList filelist = {
{ " /etc/nsswitch.conf " , " hosts: files \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerChannelInit ,
" myhostname " , " mydomainname.org " , filelist ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
std : : vector < std : : string > actual = GetNameServers ( channel ) ;
std : : vector < std : : string > expected = { " 1.2.3.4:53 " } ;
@ -388,7 +388,7 @@ CONTAINED_TEST_F(LibraryTest, ContainerChannelInit,
CONTAINED_TEST_F ( LibraryTest , ContainerSortlistOptionInit ,
" myhostname " , " mydomainname.org " , filelist ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
struct ares_options opts = { 0 } ;
int optmask = 0 ;
optmask | = ARES_OPT_SORTLIST ;
@ -412,7 +412,7 @@ NameContentList fullresolv = {
" sortlist 1.2.3.4/16 2.3.4.5 \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerFullResolvInit ,
" myhostname " , " mydomainname.org " , fullresolv ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
EXPECT_EQ ( std : : string ( " b " ) , std : : string ( channel - > lookups ) ) ;
@ -432,7 +432,7 @@ NameContentList myresolvconf = {
CONTAINED_TEST_F ( LibraryTest , ContainerMyResolvConfInit ,
" myhostname " , " mydomain.org " , myresolvconf ) {
char filename [ ] = " /tmp/myresolv.cnf " ;
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
struct ares_options options = { 0 } ;
options . resolvconf_path = strdup ( filename ) ;
int optmask = ARES_OPT_RESOLVCONF ;
@ -458,7 +458,7 @@ NameContentList myhosts = {
CONTAINED_TEST_F ( LibraryTest , ContainerMyHostsInit ,
" myhostname " , " mydomain.org " , myhosts ) {
char filename [ ] = " /tmp/hosts " ;
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
struct ares_options options = { 0 } ;
options . hosts_path = strdup ( filename ) ;
int optmask = ARES_OPT_HOSTS_FILE ;
@ -484,7 +484,7 @@ NameContentList hostconf = {
{ " /etc/host.conf " , " order bind hosts \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerHostConfInit ,
" myhostname " , " mydomainname.org " , hostconf ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
EXPECT_EQ ( std : : string ( " bf " ) , std : : string ( channel - > lookups ) ) ;
@ -499,7 +499,7 @@ NameContentList svcconf = {
{ " /etc/svc.conf " , " hosts= bind \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerSvcConfInit ,
" myhostname " , " mydomainname.org " , svcconf ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
EXPECT_EQ ( std : : string ( " b " ) , std : : string ( channel - > lookups ) ) ;
@ -513,7 +513,7 @@ NameContentList malformedresolvconflookup = {
" lookup garbage \n " } } ; // malformed line
CONTAINED_TEST_F ( LibraryTest , ContainerMalformedResolvConfLookup ,
" myhostname " , " mydomainname.org " , malformedresolvconflookup ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
EXPECT_EQ ( std : : string ( " fb " ) , std : : string ( channel - > lookups ) ) ;
@ -536,7 +536,7 @@ class MakeUnreadable {
CONTAINED_TEST_F ( LibraryTest , ContainerResolvConfNotReadable ,
" myhostname " , " mydomainname.org " , filelist ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
MakeUnreadable hide ( " /etc/resolv.conf " ) ;
// Unavailable /etc/resolv.conf falls back to defaults
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
@ -544,7 +544,7 @@ CONTAINED_TEST_F(LibraryTest, ContainerResolvConfNotReadable,
}
CONTAINED_TEST_F ( LibraryTest , ContainerNsswitchConfNotReadable ,
" myhostname " , " mydomainname.org " , filelist ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
// Unavailable /etc/nsswitch.conf falls back to defaults.
MakeUnreadable hide ( " /etc/nsswitch.conf " ) ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
@ -556,7 +556,7 @@ CONTAINED_TEST_F(LibraryTest, ContainerNsswitchConfNotReadable,
}
CONTAINED_TEST_F ( LibraryTest , ContainerHostConfNotReadable ,
" myhostname " , " mydomainname.org " , hostconf ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
// Unavailable /etc/host.conf falls back to defaults.
MakeUnreadable hide ( " /etc/host.conf " ) ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
@ -565,7 +565,7 @@ CONTAINED_TEST_F(LibraryTest, ContainerHostConfNotReadable,
}
CONTAINED_TEST_F ( LibraryTest , ContainerSvcConfNotReadable ,
" myhostname " , " mydomainname.org " , svcconf ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
// Unavailable /etc/svc.conf falls back to defaults.
MakeUnreadable hide ( " /etc/svc.conf " ) ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
@ -579,7 +579,7 @@ NameContentList rotateenv = {
" options rotate \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerRotateInit ,
" myhostname " , " mydomainname.org " , rotateenv ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
EXPECT_EQ ( ARES_TRUE , channel - > rotate ) ;
@ -590,7 +590,7 @@ CONTAINED_TEST_F(LibraryTest, ContainerRotateInit,
CONTAINED_TEST_F ( LibraryTest , ContainerRotateOverride ,
" myhostname " , " mydomainname.org " , rotateenv ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
struct ares_options opts = { 0 } ;
int optmask = ARES_OPT_NOROTATE ;
EXPECT_EQ ( ARES_SUCCESS , ares_init_options ( & channel , & opts , optmask ) ) ;
@ -613,7 +613,7 @@ NameContentList blacklistedIpv6 = {
{ " /etc/nsswitch.conf " , " hosts: files \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerBlacklistedIpv6 ,
" myhostname " , " mydomainname.org " , blacklistedIpv6 ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
std : : vector < std : : string > actual = GetNameServers ( channel ) ;
std : : vector < std : : string > expected = {
@ -635,7 +635,7 @@ NameContentList multiresolv = {
{ " /etc/nsswitch.conf " , " hosts: files \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerMultiResolvInit ,
" myhostname " , " mydomainname.org " , multiresolv ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
std : : vector < std : : string > actual = GetNameServers ( channel ) ;
std : : vector < std : : string > expected = { " [0001:0000:0000:0000:0000:0000:0000:0002]:53 " } ;
@ -654,7 +654,7 @@ NameContentList systemdresolv = {
{ " /etc/nsswitch.conf " , " hosts: junk resolve files \n " } } ;
CONTAINED_TEST_F ( LibraryTest , ContainerSystemdResolvInit ,
" myhostname " , " mydomainname.org " , systemdresolv ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
EXPECT_EQ ( std : : string ( " bf " ) , std : : string ( channel - > lookups ) ) ;
@ -666,7 +666,7 @@ CONTAINED_TEST_F(LibraryTest, ContainerSystemdResolvInit,
NameContentList empty = { } ; // no files
CONTAINED_TEST_F ( LibraryTest , ContainerEmptyInit ,
" host.domain.org " , " domain.org " , empty ) {
ares_channel channel = nullptr ;
ares_channel_t * channel = nullptr ;
EXPECT_EQ ( ARES_SUCCESS , ares_init ( & channel ) ) ;
std : : vector < std : : string > actual = GetNameServers ( channel ) ;
std : : vector < std : : string > expected = { " 127.0.0.1:53 " } ;