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

Side by Side Diff: native_client_sdk/src/tests/nacl_io_test/event_test.cc

Issue 565763002: Plumbing though mode parameter to open, since fusefs can make use of it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 6 years, 3 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
OLDNEW
1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 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 5
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 fd_set rd_set; 266 fd_set rd_set;
267 fd_set wr_set; 267 fd_set wr_set;
268 fd_set ex_set; 268 fd_set ex_set;
269 struct pollfd pollfds[MAX_FDS]; 269 struct pollfd pollfds[MAX_FDS];
270 }; 270 };
271 271
272 TEST_F(SelectPollTest, PollMemPipe) { 272 TEST_F(SelectPollTest, PollMemPipe) {
273 int fds[2]; 273 int fds[2];
274 274
275 // Both FDs for regular files should be read/write but not exception. 275 // Both FDs for regular files should be read/write but not exception.
276 fds[0] = kp->open("/test.txt", O_CREAT | O_WRONLY); 276 fds[0] = kp->open("/test.txt", O_CREAT | O_WRONLY, 0777);
277 fds[1] = kp->open("/test.txt", O_RDONLY); 277 fds[1] = kp->open("/test.txt", O_RDONLY, 0);
278 ASSERT_GT(fds[0], -1); 278 ASSERT_GT(fds[0], -1);
279 ASSERT_GT(fds[1], -1); 279 ASSERT_GT(fds[1], -1);
280 280
281 SetFDs(fds, 2); 281 SetFDs(fds, 2);
282 282
283 ASSERT_EQ(2, kp->poll(pollfds, 2, 0)); 283 ASSERT_EQ(2, kp->poll(pollfds, 2, 0));
284 ASSERT_EQ(POLLIN | POLLOUT, pollfds[0].revents); 284 ASSERT_EQ(POLLIN | POLLOUT, pollfds[0].revents);
285 ASSERT_EQ(POLLIN | POLLOUT, pollfds[1].revents); 285 ASSERT_EQ(POLLIN | POLLOUT, pollfds[1].revents);
286 CloseFDs(fds, 2); 286 CloseFDs(fds, 2);
287 287
288 // The write FD should select for write-only, read FD should not select 288 // The write FD should select for write-only, read FD should not select
289 ASSERT_EQ(0, kp->pipe(fds)); 289 ASSERT_EQ(0, kp->pipe(fds));
290 SetFDs(fds, 2); 290 SetFDs(fds, 2);
291 291
292 ASSERT_EQ(2, kp->poll(pollfds, 2, 0)); 292 ASSERT_EQ(2, kp->poll(pollfds, 2, 0));
293 // TODO(noelallen) fix poll based on open mode 293 // TODO(noelallen) fix poll based on open mode
294 // EXPECT_EQ(0, pollfds[0].revents); 294 // EXPECT_EQ(0, pollfds[0].revents);
295 // Bug 291018 295 // Bug 291018
296 ASSERT_EQ(POLLOUT, pollfds[1].revents); 296 ASSERT_EQ(POLLOUT, pollfds[1].revents);
297 297
298 CloseFDs(fds, 2); 298 CloseFDs(fds, 2);
299 } 299 }
300 300
301 TEST_F(SelectPollTest, SelectMemPipe) { 301 TEST_F(SelectPollTest, SelectMemPipe) {
302 int fds[2]; 302 int fds[2];
303 303
304 // Both FDs for regular files should be read/write but not exception. 304 // Both FDs for regular files should be read/write but not exception.
305 fds[0] = kp->open("/test.txt", O_CREAT | O_WRONLY); 305 fds[0] = kp->open("/test.txt", O_CREAT | O_WRONLY, 0777);
306 fds[1] = kp->open("/test.txt", O_RDONLY); 306 fds[1] = kp->open("/test.txt", O_RDONLY, 0);
307 ASSERT_GT(fds[0], -1); 307 ASSERT_GT(fds[0], -1);
308 ASSERT_GT(fds[1], -1); 308 ASSERT_GT(fds[1], -1);
309 SetFDs(fds, 2); 309 SetFDs(fds, 2);
310 310
311 ASSERT_EQ(4, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv)); 311 ASSERT_EQ(4, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv));
312 EXPECT_NE(0, FD_ISSET(fds[0], &rd_set)); 312 EXPECT_NE(0, FD_ISSET(fds[0], &rd_set));
313 EXPECT_NE(0, FD_ISSET(fds[1], &rd_set)); 313 EXPECT_NE(0, FD_ISSET(fds[1], &rd_set));
314 EXPECT_NE(0, FD_ISSET(fds[0], &wr_set)); 314 EXPECT_NE(0, FD_ISSET(fds[0], &wr_set));
315 EXPECT_NE(0, FD_ISSET(fds[1], &wr_set)); 315 EXPECT_NE(0, FD_ISSET(fds[1], &wr_set));
316 EXPECT_EQ(0, FD_ISSET(fds[0], &ex_set)); 316 EXPECT_EQ(0, FD_ISSET(fds[0], &ex_set));
(...skipping 20 matching lines...) Expand all
337 * Test that calling select() only writes the initial parts of the fd_sets 337 * Test that calling select() only writes the initial parts of the fd_sets
338 * passed in. 338 * passed in.
339 * We had an issue when select() was calling FD_ZERO() on the incoming fd_sets 339 * We had an issue when select() was calling FD_ZERO() on the incoming fd_sets
340 * which was causing corruption in ssh which always allocates the fd_sets to be 340 * which was causing corruption in ssh which always allocates the fd_sets to be
341 * hold 'nfds' worth of descriptors. 341 * hold 'nfds' worth of descriptors.
342 */ 342 */
343 TEST_F(SelectPollTest, SelectPartialFdset) { 343 TEST_F(SelectPollTest, SelectPartialFdset) {
344 int fds[2]; 344 int fds[2];
345 345
346 // Both FDs for regular files should be read/write but not exception. 346 // Both FDs for regular files should be read/write but not exception.
347 fds[0] = kp->open("/test.txt", O_CREAT | O_WRONLY); 347 fds[0] = kp->open("/test.txt", O_CREAT | O_WRONLY, 0777);
348 fds[1] = kp->open("/test.txt", O_RDONLY); 348 fds[1] = kp->open("/test.txt", O_RDONLY, 0);
349 ASSERT_GT(fds[0], -1); 349 ASSERT_GT(fds[0], -1);
350 ASSERT_GT(fds[1], -1); 350 ASSERT_GT(fds[1], -1);
351 ASSERT_LT(fds[1], 8); 351 ASSERT_LT(fds[1], 8);
352 SetFDs(fds, 2); 352 SetFDs(fds, 2);
353 353
354 // Fill in all the remaining bytes in the fd_sets a constant value 354 // Fill in all the remaining bytes in the fd_sets a constant value
355 static const char guard_value = 0xab; 355 static const char guard_value = 0xab;
356 for (int i = 1; i < sizeof(fd_set); i++) { 356 for (int i = 1; i < sizeof(fd_set); i++) {
357 ((char*)&rd_set)[i] = guard_value; 357 ((char*)&rd_set)[i] = guard_value;
358 ((char*)&wr_set)[i] = guard_value; 358 ((char*)&wr_set)[i] = guard_value;
359 ((char*)&ex_set)[i] = guard_value; 359 ((char*)&ex_set)[i] = guard_value;
360 } 360 }
361 361
362 ASSERT_EQ(4, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv)); 362 ASSERT_EQ(4, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv));
363 363
364 // Verify guard values were not touched. 364 // Verify guard values were not touched.
365 for (int i = 1; i < sizeof(fd_set); i++) { 365 for (int i = 1; i < sizeof(fd_set); i++) {
366 ASSERT_EQ(guard_value, ((char*)&rd_set)[i]); 366 ASSERT_EQ(guard_value, ((char*)&rd_set)[i]);
367 ASSERT_EQ(guard_value, ((char*)&wr_set)[i]); 367 ASSERT_EQ(guard_value, ((char*)&wr_set)[i]);
368 ASSERT_EQ(guard_value, ((char*)&ex_set)[i]); 368 ASSERT_EQ(guard_value, ((char*)&ex_set)[i]);
369 } 369 }
370 } 370 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/stream/stream_fs.cc ('k') | native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698