OSDN Git Service

bionic/tests: migrate gethostbyname bionic test from system/extra to bionic/tests
authorDerek Xue <derek.xue@linaro.org>
Wed, 13 Aug 2014 13:19:17 +0000 (14:19 +0100)
committerElliott Hughes <enh@google.com>
Wed, 22 Oct 2014 21:30:01 +0000 (14:30 -0700)
this change migrate the gethostbyname test defined in the old file
system/extras/tests/bionic/libc/common/test_gethostbyname.c
to the new place bionic/tests/netdb_test.cpp

Change-Id: I342171090f681581fb54d68ea4a09adf61f52081
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
tests/netdb_test.cpp

index 33f6c01..cc08715 100644 (file)
@@ -55,3 +55,13 @@ TEST(netdb, getnameinfo_salen) {
   ASSERT_STREQ("::", tmp);
   ASSERT_EQ(EAI_FAMILY, getnameinfo(sa, too_little, tmp, sizeof(tmp), NULL, 0, NI_NUMERICHOST));
 }
+
+TEST(netdb, gethostbyname) {
+  hostent* hent = gethostbyname("localhost");
+  ASSERT_TRUE(hent != NULL);
+  ASSERT_EQ(hent->h_addrtype, AF_INET);
+  ASSERT_EQ(hent->h_addr[0], 127);
+  ASSERT_EQ(hent->h_addr[1], 0);
+  ASSERT_EQ(hent->h_addr[2], 0);
+  ASSERT_EQ(hent->h_addr[3], 1);
+}