| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "mojo/edk/test/multiprocess_test_helper.h" | 5 #include "mojo/edk/test/multiprocess_test_helper.h" |
| 6 | 6 |
| 7 #include <fcntl.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 9 #include "mojo/edk/embedder/scoped_platform_handle.h" | 11 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 10 #include "mojo/edk/test/test_utils.h" | 12 #include "mojo/edk/test/test_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 #if defined(OS_POSIX) | |
| 14 #include <fcntl.h> | |
| 15 #endif | |
| 16 | |
| 17 namespace mojo { | 15 namespace mojo { |
| 18 namespace test { | 16 namespace test { |
| 19 namespace { | 17 namespace { |
| 20 | 18 |
| 21 bool IsNonBlocking(const embedder::PlatformHandle& handle) { | 19 bool IsNonBlocking(const embedder::PlatformHandle& handle) { |
| 22 #if defined(OS_WIN) | |
| 23 // Haven't figured out a way to query whether a HANDLE was created with | |
| 24 // FILE_FLAG_OVERLAPPED. | |
| 25 return true; | |
| 26 #else | |
| 27 return fcntl(handle.fd, F_GETFL) & O_NONBLOCK; | 20 return fcntl(handle.fd, F_GETFL) & O_NONBLOCK; |
| 28 #endif | |
| 29 } | 21 } |
| 30 | 22 |
| 31 bool WriteByte(const embedder::PlatformHandle& handle, char c) { | 23 bool WriteByte(const embedder::PlatformHandle& handle, char c) { |
| 32 size_t bytes_written = 0; | 24 size_t bytes_written = 0; |
| 33 BlockingWrite(handle, &c, 1, &bytes_written); | 25 BlockingWrite(handle, &c, 1, &bytes_written); |
| 34 return bytes_written == 1; | 26 return bytes_written == 1; |
| 35 } | 27 } |
| 36 | 28 |
| 37 bool ReadByte(const embedder::PlatformHandle& handle, char* c) { | 29 bool ReadByte(const embedder::PlatformHandle& handle, char* c) { |
| 38 size_t bytes_read = 0; | 30 size_t bytes_read = 0; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 EXPECT_FALSE(MultiprocessTestHelper::client_platform_handle.is_valid()) | 177 EXPECT_FALSE(MultiprocessTestHelper::client_platform_handle.is_valid()) |
| 186 << "DISREGARD: Expected failure #1 in child process"; | 178 << "DISREGARD: Expected failure #1 in child process"; |
| 187 EXPECT_FALSE( | 179 EXPECT_FALSE( |
| 188 IsNonBlocking(MultiprocessTestHelper::client_platform_handle.get())) | 180 IsNonBlocking(MultiprocessTestHelper::client_platform_handle.get())) |
| 189 << "DISREGARD: Expected failure #2 in child process"; | 181 << "DISREGARD: Expected failure #2 in child process"; |
| 190 } | 182 } |
| 191 | 183 |
| 192 } // namespace | 184 } // namespace |
| 193 } // namespace test | 185 } // namespace test |
| 194 } // namespace mojo | 186 } // namespace mojo |
| OLD | NEW |