OLD | NEW |
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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(bradnelson) 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 |
(...skipping 14 matching lines...) Expand all Loading... |
318 | 318 |
319 CloseFDs(fds, 2); | 319 CloseFDs(fds, 2); |
320 | 320 |
321 // The write FD should select for write-only, read FD should not select | 321 // The write FD should select for write-only, read FD should not select |
322 ASSERT_EQ(0, kp->pipe(fds)); | 322 ASSERT_EQ(0, kp->pipe(fds)); |
323 SetFDs(fds, 2); | 323 SetFDs(fds, 2); |
324 | 324 |
325 ASSERT_EQ(2, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv)); | 325 ASSERT_EQ(2, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv)); |
326 EXPECT_EQ(0, FD_ISSET(fds[0], &rd_set)); | 326 EXPECT_EQ(0, FD_ISSET(fds[0], &rd_set)); |
327 EXPECT_EQ(0, FD_ISSET(fds[1], &rd_set)); | 327 EXPECT_EQ(0, FD_ISSET(fds[1], &rd_set)); |
328 // TODO(noelallen) fix poll based on open mode | 328 // TODO(bradnelson) fix poll based on open mode |
329 // EXPECT_EQ(0, FD_ISSET(fds[0], &wr_set)); | 329 // EXPECT_EQ(0, FD_ISSET(fds[0], &wr_set)); |
330 // Bug 291018 | 330 // Bug 291018 |
331 EXPECT_NE(0, FD_ISSET(fds[1], &wr_set)); | 331 EXPECT_NE(0, FD_ISSET(fds[1], &wr_set)); |
332 EXPECT_EQ(0, FD_ISSET(fds[0], &ex_set)); | 332 EXPECT_EQ(0, FD_ISSET(fds[0], &ex_set)); |
333 EXPECT_EQ(0, FD_ISSET(fds[1], &ex_set)); | 333 EXPECT_EQ(0, FD_ISSET(fds[1], &ex_set)); |
334 } | 334 } |
335 | 335 |
336 /** | 336 /** |
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. |
(...skipping 22 matching lines...) Expand all Loading... |
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 } |
OLD | NEW |