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

Unified Diff: native_client_sdk/src/tests/nacl_io_test/event_test.cc

Issue 229863002: [NaCl SDK] nacl_io: Fix select() implementation so it doesn't assume entire fs_sets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/kernel_proxy.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_test/event_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/event_test.cc b/native_client_sdk/src/tests/nacl_io_test/event_test.cc
index 76f535961971ed566791b57452a5f4b7e7165873..8ca754da4808841c0466532e87f8c62ba041ff30 100644
--- a/native_client_sdk/src/tests/nacl_io_test/event_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/event_test.cc
@@ -312,3 +312,38 @@ TEST_F(SelectPollTest, SelectMemPipe) {
EXPECT_EQ(0, FD_ISSET(fds[1], &ex_set));
}
+/**
+ * Test that calling select() only writes the initial parts of the fd_sets
+ * passed in.
+ * We had an issue when select() was calling FD_ZERO() on the incoming fd_sets
+ * which was causing corruption in ssh which always allocates the fd_sets to be
+ * hold 'nfds' worth of descriptors.
+ */
+TEST_F(SelectPollTest, SelectPartialFdset) {
+ int fds[2];
+
+ // Both FDs for regular files should be read/write but not exception.
+ fds[0] = kp->open("/test.txt", O_CREAT | O_WRONLY);
+ fds[1] = kp->open("/test.txt", O_RDONLY);
+ ASSERT_GT(fds[0], -1);
+ ASSERT_GT(fds[1], -1);
+ ASSERT_LT(fds[1], 8);
+ SetFDs(fds, 2);
+
+ // Fill in all the remaining bytes in the fd_sets a constant value
+ static const char guard_value = 0xab;
+ for (int i = 1; i < sizeof(fd_set); i++) {
+ ((char*)&rd_set)[i] = guard_value;
+ ((char*)&wr_set)[i] = guard_value;
+ ((char*)&ex_set)[i] = guard_value;
+ }
+
+ ASSERT_EQ(4, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv));
+
+ // Verify guard values were not touched.
+ for (int i = 1; i < sizeof(fd_set); i++) {
+ ASSERT_EQ(guard_value, ((char*)&rd_set)[i]);
+ ASSERT_EQ(guard_value, ((char*)&wr_set)[i]);
+ ASSERT_EQ(guard_value, ((char*)&ex_set)[i]);
+ }
+}
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698