Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc

Issue 344833005: [NaCl SDK] nacl_io: Fix bug in getaddrinfo() where service is "0" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc b/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
index fab3ec52d3e7020c90bd86667815ac8ff03944fb..b00d2d43d34766d7ad6863b8e76399d28e05ff68 100644
--- a/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/host_resolver_test.cc
@@ -107,6 +107,33 @@ TEST_F(HostResolverTest, Getaddrinfo_Numeric) {
ki_freeaddrinfo(ai);
}
+TEST_F(HostResolverTest, Getaddrinfo_Service) {
+ struct addrinfo* ai = NULL;
+ struct sockaddr_in* in;
+ struct addrinfo hints;
+
+ // Numberic only
binji 2014/06/19 20:00:32 Numeric
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+
+ ASSERT_EQ(0, ki_getaddrinfo("1.2.3.4", "0", &hints, &ai));
+ ASSERT_NE(NULL_INFO, ai);
+ ASSERT_NE(NULL_ADDR, ai->ai_addr);
+ in = (struct sockaddr_in*)ai->ai_addr;
+ ASSERT_EQ(htons(0), in->sin_port);
binji 2014/06/19 20:00:32 only testing the port? If so, maybe change the tes
Sam Clegg 2014/06/19 22:37:48 Done.. although the "Service" is really the port (
binji 2014/06/19 22:52:29 Sorry, I was confused. I've never heard a port cal
+ ASSERT_EQ(NULL_INFO, ai->ai_next);
+
+ ASSERT_EQ(0, ki_getaddrinfo("1.2.3.4", "65000", &hints, &ai));
+ ASSERT_NE(NULL_INFO, ai);
+ ASSERT_NE(NULL_ADDR, ai->ai_addr);
+ in = (struct sockaddr_in*)ai->ai_addr;
+ ASSERT_EQ(htons(65000), in->sin_port);
+ ASSERT_EQ(NULL_INFO, ai->ai_next);
+
+ ki_freeaddrinfo(ai);
+}
+
TEST_F(HostResolverTest, Getaddrinfo_MissingPPAPI) {
// Verify that full lookups fail due to lack of PPAPI interfaces
struct addrinfo* ai = NULL;

Powered by Google App Engine
This is Rietveld 408576698