Skip to content

Commit

Permalink
update tests not marked as Live to use 127.0.0.1 as DNS server so OS …
Browse files Browse the repository at this point in the history
…doesn't immediately reject test due to knowing the route to the DNS server doesn't exist during connect()
  • Loading branch information
bradh352 committed Jan 3, 2025
1 parent d10a714 commit 5b1e796
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/ares-test-live.cc
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,11 @@ VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetNameInfoAllocFail) {

VIRT_NONVIRT_TEST_F(DefaultChannelTest, GetSock) {
ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD};
int bitmask = ares_getsock(channel_, socks, 3);
int bitmask;

EXPECT_EQ(ARES_SUCCESS, (ares_status_t)ares_set_servers_csv(channel_, "127.0.0.1"));

bitmask = ares_getsock(channel_, socks, 3);
EXPECT_EQ(0, bitmask);
bitmask = ares_getsock(channel_, nullptr, 0);
EXPECT_EQ(0, bitmask);
Expand Down Expand Up @@ -708,6 +712,8 @@ TEST_F(LibraryTest, GetTCPSock) {
EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &opts, optmask));
EXPECT_NE(nullptr, channel);

EXPECT_EQ(ARES_SUCCESS, (ares_status_t)ares_set_servers_csv(channel, "127.0.0.1"));

ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD};
int bitmask = ares_getsock(channel, socks, 3);
EXPECT_EQ(0, bitmask);
Expand Down Expand Up @@ -744,6 +750,8 @@ TEST_F(DefaultChannelTest, VerifySocketFunctionCallback) {
auto my_functions = VirtualizeIO::default_functions;
size_t count = 0;

EXPECT_EQ(ARES_SUCCESS, (ares_status_t)ares_set_servers_csv(channel_, "127.0.0.1"));

my_functions.asocket = [](int af, int type, int protocol, void * p) -> ares_socket_t {
EXPECT_NE(nullptr, p);
(*reinterpret_cast<size_t *>(p))++;
Expand Down

0 comments on commit 5b1e796

Please sign in to comment.