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

Side by Side Diff: net/tools/quic/platform/impl/quic_socket_utils_test.cc

Issue 2611613003: Add quic_logging (Closed)
Patch Set: fix failed test? Created 3 years, 11 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
« no previous file with comments | « net/tools/quic/platform/impl/quic_socket_utils.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/tools/quic/platform/impl/quic_socket_utils.h" 5 #include "net/tools/quic/platform/impl/quic_socket_utils.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include <array> 9 #include <array>
10 10
11 #include "net/quic/platform/api/quic_logging.h"
11 #include "net/quic/platform/api/quic_socket_address.h" 12 #include "net/quic/platform/api/quic_socket_address.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace net { 15 namespace net {
15 namespace test { 16 namespace test {
16 namespace { 17 namespace {
17 18
18 // A test fixture is used to ensure that all sockets are closed down gracefully 19 // A test fixture is used to ensure that all sockets are closed down gracefully
19 // upon test completion. Also provides a convenient API to Bind not presently 20 // upon test completion. Also provides a convenient API to Bind not presently
20 // available in QuicSocketUtils. 21 // available in QuicSocketUtils.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 socklen_t bind_addr_size = 0; 57 socklen_t bind_addr_size = 0;
57 58
58 switch (address.host().address_family()) { 59 switch (address.host().address_family()) {
59 case IpAddressFamily::IP_V4: 60 case IpAddressFamily::IP_V4:
60 bind_addr_size = sizeof(struct sockaddr_in); 61 bind_addr_size = sizeof(struct sockaddr_in);
61 break; 62 break;
62 case IpAddressFamily::IP_V6: 63 case IpAddressFamily::IP_V6:
63 bind_addr_size = sizeof(struct sockaddr_in6); 64 bind_addr_size = sizeof(struct sockaddr_in6);
64 break; 65 break;
65 case IpAddressFamily::IP_UNSPEC: 66 case IpAddressFamily::IP_UNSPEC:
66 LOG(FATAL) << "Unspecified IP address family"; 67 QUIC_LOG(FATAL) << "Unspecified IP address family";
67 } 68 }
68 69
69 int rc = bind(fd, reinterpret_cast<sockaddr*>(&bind_addr_native), 70 int rc = bind(fd, reinterpret_cast<sockaddr*>(&bind_addr_native),
70 bind_addr_size); 71 bind_addr_size);
71 if (rc != 0) { 72 if (rc != 0) {
72 LOG(ERROR) << "Failed to bind socket to " << address.ToString() << ": " 73 QUIC_LOG(ERROR) << "Failed to bind socket to " << address.ToString()
73 << strerror(errno); 74 << ": " << strerror(errno);
74 return bound_address; 75 return bound_address;
75 } 76 }
76 77
77 rc = bound_address.FromSocket(fd); 78 rc = bound_address.FromSocket(fd);
78 if (rc != 0) { 79 if (rc != 0) {
79 LOG(ERROR) << "Failed to get bound socket address from fd: " 80 QUIC_LOG(ERROR) << "Failed to get bound socket address from fd: "
80 << strerror(errno); 81 << strerror(errno);
81 bound_address = QuicSocketAddress(); 82 bound_address = QuicSocketAddress();
82 } 83 }
83 return bound_address; 84 return bound_address;
84 } 85 }
85 86
86 private: 87 private:
87 std::vector<int> open_sockets_; 88 std::vector<int> open_sockets_;
88 }; 89 };
89 90
90 // This test verifies that QuicSocketUtils creates a non-blocking socket 91 // This test verifies that QuicSocketUtils creates a non-blocking socket
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 EXPECT_EQ(512, bytes_read); 164 EXPECT_EQ(512, bytes_read);
164 for (int i = 0; i < bytes_read; i++) { 165 for (int i = 0; i < bytes_read; i++) {
165 EXPECT_EQ(static_cast<char>(i), read_buffer[i]); 166 EXPECT_EQ(static_cast<char>(i), read_buffer[i]);
166 } 167 }
167 } 168 }
168 } 169 }
169 170
170 } // namespace 171 } // namespace
171 } // namespace test 172 } // namespace test
172 } // namespace net 173 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/platform/impl/quic_socket_utils.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698