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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <arpa/inet.h> 5 #include <arpa/inet.h>
6 #include <netinet/in.h> 6 #include <netinet/in.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 9
10 #include "fake_ppapi/fake_pepper_interface.h" 10 #include "fake_ppapi/fake_pepper_interface.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 ASSERT_NE(NULL_ADDR, ai->ai_addr); 100 ASSERT_NE(NULL_ADDR, ai->ai_addr);
101 ASSERT_EQ(AF_INET, ai->ai_family); 101 ASSERT_EQ(AF_INET, ai->ai_family);
102 ASSERT_EQ(SOCK_STREAM, ai->ai_socktype); 102 ASSERT_EQ(SOCK_STREAM, ai->ai_socktype);
103 in = (struct sockaddr_in*)ai->ai_addr; 103 in = (struct sockaddr_in*)ai->ai_addr;
104 ASSERT_EQ(expected_addr, in->sin_addr.s_addr); 104 ASSERT_EQ(expected_addr, in->sin_addr.s_addr);
105 ASSERT_EQ(NULL_INFO, ai->ai_next); 105 ASSERT_EQ(NULL_INFO, ai->ai_next);
106 106
107 ki_freeaddrinfo(ai); 107 ki_freeaddrinfo(ai);
108 } 108 }
109 109
110 TEST_F(HostResolverTest, Getaddrinfo_Service) {
111 struct addrinfo* ai = NULL;
112 struct sockaddr_in* in;
113 struct addrinfo hints;
114
115 // Numberic only
binji 2014/06/19 20:00:32 Numeric
116 memset(&hints, 0, sizeof(hints));
117 hints.ai_family = AF_INET;
118 hints.ai_socktype = SOCK_STREAM;
119
120 ASSERT_EQ(0, ki_getaddrinfo("1.2.3.4", "0", &hints, &ai));
121 ASSERT_NE(NULL_INFO, ai);
122 ASSERT_NE(NULL_ADDR, ai->ai_addr);
123 in = (struct sockaddr_in*)ai->ai_addr;
124 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
125 ASSERT_EQ(NULL_INFO, ai->ai_next);
126
127 ASSERT_EQ(0, ki_getaddrinfo("1.2.3.4", "65000", &hints, &ai));
128 ASSERT_NE(NULL_INFO, ai);
129 ASSERT_NE(NULL_ADDR, ai->ai_addr);
130 in = (struct sockaddr_in*)ai->ai_addr;
131 ASSERT_EQ(htons(65000), in->sin_port);
132 ASSERT_EQ(NULL_INFO, ai->ai_next);
133
134 ki_freeaddrinfo(ai);
135 }
136
110 TEST_F(HostResolverTest, Getaddrinfo_MissingPPAPI) { 137 TEST_F(HostResolverTest, Getaddrinfo_MissingPPAPI) {
111 // Verify that full lookups fail due to lack of PPAPI interfaces 138 // Verify that full lookups fail due to lack of PPAPI interfaces
112 struct addrinfo* ai = NULL; 139 struct addrinfo* ai = NULL;
113 ASSERT_EQ(EAI_SYSTEM, ki_getaddrinfo("google.com", NULL, NULL, &ai)); 140 ASSERT_EQ(EAI_SYSTEM, ki_getaddrinfo("google.com", NULL, NULL, &ai));
114 } 141 }
115 142
116 TEST_F(HostResolverTest, Getaddrinfo_Passive) { 143 TEST_F(HostResolverTest, Getaddrinfo_Passive) {
117 struct addrinfo* ai = NULL; 144 struct addrinfo* ai = NULL;
118 struct sockaddr_in* in; 145 struct sockaddr_in* in;
119 struct sockaddr_in6* in6; 146 struct sockaddr_in6* in6;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 393
367 TEST(SocketUtilityFunctions, Hstrerror) { 394 TEST(SocketUtilityFunctions, Hstrerror) {
368 EXPECT_STREQ("Unknown error in gethostbyname: 2718.", hstrerror(2718)); 395 EXPECT_STREQ("Unknown error in gethostbyname: 2718.", hstrerror(2718));
369 } 396 }
370 397
371 TEST(SocketUtilityFunctions, Gai_Strerror) { 398 TEST(SocketUtilityFunctions, Gai_Strerror) {
372 EXPECT_STREQ("Unknown error in getaddrinfo: 2719.", gai_strerror(2719)); 399 EXPECT_STREQ("Unknown error in getaddrinfo: 2719.", gai_strerror(2719));
373 } 400 }
374 401
375 #endif // !defined(__GLIBC__) 402 #endif // !defined(__GLIBC__)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698