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

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: Running tests on package 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
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 EXPECT_EQ(errno, EBADF); 238 EXPECT_EQ(errno, EBADF);
234 EXPECT_LT(ki_shutdown(0, SHUT_RDWR), 0); 239 EXPECT_LT(ki_shutdown(0, SHUT_RDWR), 0);
235 EXPECT_EQ(errno, ENOTSOCK); 240 EXPECT_EQ(errno, ENOTSOCK);
236 } 241 }
237 242
238 TEST_F(SocketTest, Socket) { 243 TEST_F(SocketTest, Socket) {
239 EXPECT_LT(ki_socket(AF_UNIX, SOCK_STREAM, 0), 0); 244 EXPECT_LT(ki_socket(AF_UNIX, SOCK_STREAM, 0), 0);
240 EXPECT_EQ(errno, EAFNOSUPPORT); 245 EXPECT_EQ(errno, EAFNOSUPPORT);
241 EXPECT_LT(ki_socket(AF_INET, SOCK_RAW, 0), 0); 246 EXPECT_LT(ki_socket(AF_INET, SOCK_RAW, 0), 0);
242 EXPECT_EQ(errno, EPROTONOSUPPORT); 247 EXPECT_EQ(errno, EPROTONOSUPPORT);
243
244 // These four af/protocol combinations should be supported.
245 EXPECT_LT(ki_socket(AF_INET, SOCK_STREAM, 0), 0);
246 EXPECT_EQ(errno, EACCES);
247 EXPECT_LT(ki_socket(AF_INET, SOCK_DGRAM, 0), 0);
248 EXPECT_EQ(errno, EACCES);
249 EXPECT_LT(ki_socket(AF_INET6, SOCK_STREAM, 0), 0);
250 EXPECT_EQ(errno, EACCES);
251 EXPECT_LT(ki_socket(AF_INET6, SOCK_DGRAM, 0), 0);
252 EXPECT_EQ(errno, EACCES);
253 } 248 }
254 249
255 TEST_F(SocketTest, Socketpair) { 250 TEST_F(SocketTest, Socketpair) {
256 int sv[2]; 251 int sv[2];
257 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, NULL), 0); 252 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, NULL), 0);
258 EXPECT_EQ(errno, EFAULT); 253 EXPECT_EQ(errno, EFAULT);
259 EXPECT_LT(ki_socketpair(AF_UNIX, SOCK_STREAM, 0, sv), 0); 254 EXPECT_LT(ki_socketpair(AF_UNIX, SOCK_STREAM, 0, sv), 0);
260 EXPECT_EQ(errno, EAFNOSUPPORT); 255 EXPECT_EQ(errno, EAFNOSUPPORT);
261 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, sv), 0); 256 EXPECT_LT(ki_socketpair(AF_INET, SOCK_STREAM, 0, sv), 0);
262 EXPECT_EQ(errno, EPROTONOSUPPORT); 257 EXPECT_EQ(errno, EPROTONOSUPPORT);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 addr_name, INET_ADDRSTRLEN - 1)); 362 addr_name, INET_ADDRSTRLEN - 1));
368 EXPECT_EQ(errno, ENOSPC); 363 EXPECT_EQ(errno, ENOSPC);
369 364
370 EXPECT_TRUE(NULL == inet_ntop(AF_INET6, &ipv6_addr, 365 EXPECT_TRUE(NULL == inet_ntop(AF_INET6, &ipv6_addr,
371 addr_name, INET6_ADDRSTRLEN - 1)); 366 addr_name, INET6_ADDRSTRLEN - 1));
372 EXPECT_EQ(errno, ENOSPC); 367 EXPECT_EQ(errno, ENOSPC);
373 } 368 }
374 369
375 #endif // !defined(__GLIBC__) 370 #endif // !defined(__GLIBC__)
376 #endif // PROVIDES_SOCKETPAIR_API 371 #endif // PROVIDES_SOCKETPAIR_API
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698