Skip to content

Commit 44f3c2a

Browse files
authored
Update test_gethostbyname. NFC (#21066)
This test now outputs the result of the lookup and verifies it. The IP address reported here is the result of hardcoded values in our fake DNS resolver.
1 parent eacfddf commit 44f3c2a

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

test/sockets/test_gethostbyname.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int main() {
2626
const char *res;
2727
char buffer[2048];
2828
int err;
29-
29+
3030
// gethostbyname_r calls the same stuff as gethostbyname, so we'll test the
3131
// more complicated one.
3232
// resolve the hostname to an actual address
@@ -38,6 +38,7 @@ int main() {
3838
char **raw_addr_list = host->h_addr_list;
3939
int *raw_addr = (int*)*raw_addr_list;
4040
res = inet_ntop(host->h_addrtype, raw_addr, str, INET_ADDRSTRLEN);
41+
printf("gethostbyname -> %s\n", res);
4142
assert(res);
4243

4344
// convert the string to an in_addr structure
@@ -46,6 +47,7 @@ int main() {
4647

4748
// do a reverse lookup on the ip address
4849
struct hostent *host1 = gethostbyaddr(&addr, sizeof(addr), host->h_addrtype);
50+
printf("gethostbyaddr -> %s\n", host1->h_name);
4951
assert(strstr(host1->h_name, "slashdot.org"));
5052

5153
puts("success");

test/sockets/test_gethostbyname.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gethostbyname -> 172.29.1.0
2+
gethostbyaddr -> slashdot.org
3+
success

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10423,7 +10423,7 @@ def test_getnameinfo(self):
1042310423
self.do_runf('sockets/test_getnameinfo.c', 'success')
1042410424

1042510425
def test_gethostbyname(self):
10426-
self.do_runf('sockets/test_gethostbyname.c', 'success')
10426+
self.do_run_in_out_file_test('sockets/test_gethostbyname.c')
1042710427

1042810428
def test_getprotobyname(self):
1042910429
self.do_runf('sockets/test_getprotobyname.c', 'success')

0 commit comments

Comments
 (0)