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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Expect to time out on input. | 167 // Expect to time out on input. |
168 { | 168 { |
169 EventListenerLock locker(&pipe); | 169 EventListenerLock locker(&pipe); |
170 EXPECT_EQ(ETIMEDOUT, locker.WaitOnEvent(POLLIN, 0)); | 170 EXPECT_EQ(ETIMEDOUT, locker.WaitOnEvent(POLLIN, 0)); |
171 } | 171 } |
172 | 172 |
173 // Output should be ready to go. | 173 // Output should be ready to go. |
174 { | 174 { |
175 EventListenerLock locker(&pipe); | 175 EventListenerLock locker(&pipe); |
176 EXPECT_EQ(0, locker.WaitOnEvent(POLLOUT, 0)); | 176 EXPECT_EQ(0, locker.WaitOnEvent(POLLOUT, 0)); |
177 EXPECT_EQ(sizeof(hello), pipe.Write_Locked(hello, sizeof(hello))); | 177 int out_bytes = 0; |
| 178 EXPECT_EQ(0, pipe.Write_Locked(hello, sizeof(hello), &out_bytes)); |
| 179 EXPECT_EQ(sizeof(hello), out_bytes); |
178 } | 180 } |
179 | 181 |
180 // We should now be able to poll | 182 // We should now be able to poll |
181 { | 183 { |
182 EventListenerLock locker(&pipe); | 184 EventListenerLock locker(&pipe); |
183 EXPECT_EQ(0, locker.WaitOnEvent(POLLIN, 0)); | 185 EXPECT_EQ(0, locker.WaitOnEvent(POLLIN, 0)); |
184 EXPECT_EQ(sizeof(hello), pipe.Read_Locked(tmp, sizeof(tmp))); | 186 int out_bytes = -1; |
| 187 EXPECT_EQ(0, pipe.Read_Locked(tmp, sizeof(tmp), &out_bytes)); |
| 188 EXPECT_EQ(sizeof(hello), out_bytes); |
185 } | 189 } |
186 | 190 |
187 // Verify we can read it correctly. | 191 // Verify we can read it correctly. |
188 EXPECT_EQ(0, strcmp(hello, tmp)); | 192 EXPECT_EQ(0, strcmp(hello, tmp)); |
189 } | 193 } |
190 | 194 |
191 class StreamFsForTesting : public StreamFs { | 195 class StreamFsForTesting : public StreamFs { |
192 public: | 196 public: |
193 StreamFsForTesting() {} | 197 StreamFsForTesting() {} |
194 }; | 198 }; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 344 |
341 ASSERT_EQ(4, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv)); | 345 ASSERT_EQ(4, kp->select(fds[1] + 1, &rd_set, &wr_set, &ex_set, &tv)); |
342 | 346 |
343 // Verify guard values were not touched. | 347 // Verify guard values were not touched. |
344 for (int i = 1; i < sizeof(fd_set); i++) { | 348 for (int i = 1; i < sizeof(fd_set); i++) { |
345 ASSERT_EQ(guard_value, ((char*)&rd_set)[i]); | 349 ASSERT_EQ(guard_value, ((char*)&rd_set)[i]); |
346 ASSERT_EQ(guard_value, ((char*)&wr_set)[i]); | 350 ASSERT_EQ(guard_value, ((char*)&wr_set)[i]); |
347 ASSERT_EQ(guard_value, ((char*)&ex_set)[i]); | 351 ASSERT_EQ(guard_value, ((char*)&ex_set)[i]); |
348 } | 352 } |
349 } | 353 } |
OLD | NEW |