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

Unified Diff: native_client_sdk/src/tests/nacl_io_socket_test/socket_test.cc

Issue 304373008: Add support for modifying TCP and UDP socket buffer size in nacl_io (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected the unit tests Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/tests/nacl_io_socket_test/socket_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_socket_test/socket_test.cc b/native_client_sdk/src/tests/nacl_io_socket_test/socket_test.cc
index 5dfe0046fc166424f76b5f33e2af73f37ba95f5a..1d609bdae3486b7ef8e0a512bb01785d8fec24f3 100644
--- a/native_client_sdk/src/tests/nacl_io_socket_test/socket_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_socket_test/socket_test.cc
@@ -584,6 +584,17 @@ TEST_F(SocketTestUDP, Listen) {
EXPECT_EQ(errno, ENOTSUP);
}
+TEST_F(SocketTestUDP, Sockopt_BUFSIZE) {
+ int option = 1024*1024;
+ socklen_t len = sizeof(option);
+
+ ASSERT_EQ(0, Bind(sock1_, LOCAL_HOST, ANY_PORT));
+ ASSERT_EQ(0, ki_setsockopt(sock1_, SOL_SOCKET, SO_RCVBUF, &option, len))
+ << "failed with: " << strerror(errno);
+ ASSERT_EQ(0, ki_setsockopt(sock1_, SOL_SOCKET, SO_SNDBUF, &option, len))
+ << "failed with: " << strerror(errno);
Sam Clegg 2014/06/03 00:07:54 Can you verify the result with getsockopt()?
mbajpai 2014/06/03 05:11:07 It is not clear to me how to do it. Unlike SetOpti
+}
+
TEST_F(SocketTestTCP, Listen) {
sockaddr_in addr;
socklen_t addrlen = sizeof(addr);
@@ -812,4 +823,33 @@ TEST_F(SocketTestTCP, SendBufferedDataAfterShutdown) {
ASSERT_EQ(0, ki_close(new_sock));
}
+TEST_F(SocketTestTCP, Sockopt_BUFSIZE) {
+ int option = 1024*1024;
+ socklen_t len = sizeof(option);
+ sockaddr_in addr;
+ socklen_t addrlen = sizeof(addr);
+
+ int server_sock = sock1_;
+ int client_sock = sock2_;
+
+ // bind and listen
+ ASSERT_EQ(0, Bind(server_sock, LOCAL_HOST, ANY_PORT));
+ ASSERT_EQ(0, ki_listen(server_sock, 10))
+ << "listen failed with: " << strerror(errno);
+
+ // connect to listening socket
+ IP4ToSockAddr(LOCAL_HOST, PORT1, &addr);
+ ASSERT_EQ(0, ki_connect(client_sock, (sockaddr*)&addr, addrlen))
+ << "Failed with " << errno << ": " << strerror(errno);
+
+ addrlen = sizeof(addr);
+ int new_sock = accept(server_sock, (sockaddr*)&addr, &addrlen);
+ ASSERT_NE(-1, new_sock);
+
+ ASSERT_EQ(0, ki_setsockopt(sock2_, SOL_SOCKET, SO_RCVBUF, &option, len))
+ << "failed with: " << strerror(errno);
+ ASSERT_EQ(0, ki_setsockopt(sock2_, SOL_SOCKET, SO_SNDBUF, &option, len))
+ << "failed with: " << strerror(errno);
Sam Clegg 2014/06/03 00:07:54 ditto.
+}
+
#endif // PROVIDES_SOCKET_API
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698