| OLD | NEW |
| 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 <arpa/inet.h> | 5 #include <arpa/inet.h> |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <netinet/in.h> | 8 #include <netinet/in.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 int len2 = | 167 int len2 = |
| 168 recvfrom(sock2, inbuf, sizeof(inbuf), 0, (sockaddr *) &addr, &addrlen); | 168 recvfrom(sock2, inbuf, sizeof(inbuf), 0, (sockaddr *) &addr, &addrlen); |
| 169 EXPECT_EQ(sizeof(outbuf), len2); | 169 EXPECT_EQ(sizeof(outbuf), len2); |
| 170 EXPECT_EQ(sizeof(sockaddr_in), addrlen); | 170 EXPECT_EQ(sizeof(sockaddr_in), addrlen); |
| 171 EXPECT_EQ(PORT1, htons(addr.sin_port)); | 171 EXPECT_EQ(PORT1, htons(addr.sin_port)); |
| 172 | 172 |
| 173 // Now they should be the same | 173 // Now they should be the same |
| 174 EXPECT_EQ(0, memcmp(outbuf, inbuf, sizeof(outbuf))); | 174 EXPECT_EQ(0, memcmp(outbuf, inbuf, sizeof(outbuf))); |
| 175 } | 175 } |
| 176 | 176 |
| 177 #if 0 | |
| 178 TEST_F(SocketTestTCP, Connect) { | 177 TEST_F(SocketTestTCP, Connect) { |
| 178 char outbuf[256]; |
| 179 char inbuf[512]; |
| 180 |
| 181 memset(outbuf, 1, sizeof(outbuf)); |
| 182 memset(inbuf, 0, sizeof(inbuf)); |
| 183 |
| 179 int sock = socket(AF_INET, SOCK_STREAM, 0); | 184 int sock = socket(AF_INET, SOCK_STREAM, 0); |
| 180 EXPECT_NE(-1, sock); | 185 EXPECT_NE(-1, sock); |
| 181 | 186 |
| 182 sockaddr_in addr; | 187 sockaddr_in addr; |
| 183 socklen_t addrlen = sizeof(addr); | 188 socklen_t addrlen = sizeof(addr); |
| 184 | 189 |
| 185 IP4ToSockAddr(LOCAL_HOST, PORT1, &addr); | 190 IP4ToSockAddr(LOCAL_HOST, PORT1, &addr); |
| 186 int err = connect(sock, (sockaddr*) &addr, addrlen); | 191 int err = connect(sock, (sockaddr*) &addr, addrlen); |
| 192 |
| 187 EXPECT_EQ(ENONE, err) << "Failed with errno: " << errno << "\n"; | 193 EXPECT_EQ(ENONE, err) << "Failed with errno: " << errno << "\n"; |
| 194 |
| 195 EXPECT_EQ(sizeof(outbuf), write(sock, outbuf, sizeof(outbuf))); |
| 196 EXPECT_EQ(sizeof(outbuf), read(sock, inbuf, sizeof(inbuf))); |
| 197 |
| 198 // Now they should be the same |
| 199 EXPECT_EQ(0, memcmp(outbuf, inbuf, sizeof(outbuf))); |
| 188 } | 200 } |
| 189 #endif | |
| 190 | 201 |
| 191 #endif // PROVIDES_SOCKETPAIR_API | 202 #endif // PROVIDES_SOCKET_API |
| OLD | NEW |