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

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
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/host_resolver.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3aaec27b32a275f709a482c8f355d9137ee1a5bd 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
@@ -89,7 +89,7 @@ TEST_F(HostResolverTest, Getaddrinfo_Numeric) {
struct sockaddr_in* in;
struct addrinfo hints;
- // Numberic only
+ // Numeric only
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
@@ -107,6 +107,34 @@ TEST_F(HostResolverTest, Getaddrinfo_Numeric) {
ki_freeaddrinfo(ai);
}
+TEST_F(HostResolverTest, Getaddrinfo_NumericService) {
+ struct addrinfo* ai = NULL;
+ struct sockaddr_in* in;
+ struct addrinfo hints;
+
+ 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;
+ uint16_t expected_port = htons(0);
+ ASSERT_EQ(expected_port, in->sin_port);
+ ASSERT_EQ(NULL_INFO, ai->ai_next);
+ ki_freeaddrinfo(ai);
+
+ 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;
+ expected_port = htons(65000);
+ ASSERT_EQ(expected_port, 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;
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/host_resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698