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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io_test/socket_test.cc

Issue 22587003: [NaCl SDK] Add UDP and TCP Sockets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to browser tester fix. Created 7 years, 4 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
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io_socket_test/socket_test.cc ('k') | no next file » | 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
5 #include <arpa/inet.h>
4 #include <errno.h> 6 #include <errno.h>
5 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <netinet/in.h>
6 #include <pthread.h> 9 #include <pthread.h>
10 #include <sys/types.h>
11 #include <sys/socket.h>
7 #include <sys/stat.h> 12 #include <sys/stat.h>
8 13
9 #include <map> 14 #include <map>
10 #include <string> 15 #include <string>
11 16
12 #include "gmock/gmock.h" 17 #include "gmock/gmock.h"
13 #include "gtest/gtest.h" 18 #include "gtest/gtest.h"
14 19
15 #include "nacl_io/kernel_intercept.h" 20 #include "nacl_io/kernel_intercept.h"
16 #include "nacl_io/kernel_proxy.h" 21 #include "nacl_io/kernel_proxy.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 EXPECT_EQ(errno, EBADF); 233 EXPECT_EQ(errno, EBADF);
229 EXPECT_LT(ki_shutdown(0, SHUT_RDWR), 0); 234 EXPECT_LT(ki_shutdown(0, SHUT_RDWR), 0);
230 EXPECT_EQ(errno, ENOTSOCK); 235 EXPECT_EQ(errno, ENOTSOCK);
231 } 236 }
232 237
233 TEST_F(SocketTest, Socket) { 238 TEST_F(SocketTest, Socket) {
234 EXPECT_LT(ki_socket(AF_UNIX, SOCK_STREAM, 0), 0); 239 EXPECT_LT(ki_socket(AF_UNIX, SOCK_STREAM, 0), 0);
235 EXPECT_EQ(errno, EAFNOSUPPORT); 240 EXPECT_EQ(errno, EAFNOSUPPORT);
236 EXPECT_LT(ki_socket(AF_INET, SOCK_RAW, 0), 0); 241 EXPECT_LT(ki_socket(AF_INET, SOCK_RAW, 0), 0);
237 EXPECT_EQ(errno, EPROTONOSUPPORT); 242 EXPECT_EQ(errno, EPROTONOSUPPORT);
238
239 // These four af/protocol combinations should be supported.
240 EXPECT_LT(ki_socket(AF_INET, SOCK_STREAM, 0), 0);
241 EXPECT_EQ(errno, EACCES);
242 EXPECT_LT(ki_socket(AF_INET, SOCK_DGRAM, 0), 0);
243 EXPECT_EQ(errno, EACCES);
244 EXPECT_LT(ki_socket(AF_INET6, SOCK_STREAM, 0), 0);
245 EXPECT_EQ(errno, EACCES);
246 EXPECT_LT(ki_socket(AF_INET6, SOCK_DGRAM, 0), 0);
247 EXPECT_EQ(errno, EACCES);
248 } 243 }
249 244
250 TEST_F(SocketTest, Socketpair) { 245 TEST_F(SocketTest, Socketpair) {
251 int sv[2]; 246 int sv[2];
252 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, NULL), 0); 247 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, NULL), 0);
253 EXPECT_EQ(errno, EFAULT); 248 EXPECT_EQ(errno, EFAULT);
254 EXPECT_LT(ki_socketpair(AF_UNIX, SOCK_STREAM, 0, sv), 0); 249 EXPECT_LT(ki_socketpair(AF_UNIX, SOCK_STREAM, 0, sv), 0);
255 EXPECT_EQ(errno, EAFNOSUPPORT); 250 EXPECT_EQ(errno, EAFNOSUPPORT);
256 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, sv), 0); 251 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, sv), 0);
257 EXPECT_EQ(errno, EPROTONOSUPPORT); 252 EXPECT_EQ(errno, EPROTONOSUPPORT);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 TEST(SocketUtilityFunctions, Ntohl) { 400 TEST(SocketUtilityFunctions, Ntohl) {
406 uint8_t network_bytes[4] = { 0x44, 0x33, 0x22, 0x11 }; 401 uint8_t network_bytes[4] = { 0x44, 0x33, 0x22, 0x11 };
407 uint32_t network_long; 402 uint32_t network_long;
408 memcpy(&network_long, network_bytes, 4); 403 memcpy(&network_long, network_bytes, 4);
409 uint32_t host_long = ntohl(network_long); 404 uint32_t host_long = ntohl(network_long);
410 EXPECT_EQ(host_long, 0x44332211); 405 EXPECT_EQ(host_long, 0x44332211);
411 } 406 }
412 407
413 #endif // !defined(__GLIBC__) 408 #endif // !defined(__GLIBC__)
414 #endif // PROVIDES_SOCKETPAIR_API 409 #endif // PROVIDES_SOCKETPAIR_API
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io_socket_test/socket_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698