| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/embedder/platform_channel_pair.h" | 5 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <poll.h> | 8 #include <poll.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <sys/socket.h> | 12 #include <sys/socket.h> |
| 13 #include <sys/types.h> | 13 #include <sys/types.h> |
| 14 #include <sys/uio.h> | 14 #include <sys/uio.h> |
| 15 #include <unistd.h> | 15 #include <unistd.h> |
| 16 #include <deque> | 16 #include <deque> |
| 17 #include <utility> | 17 #include <utility> |
| 18 | 18 |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
| 21 #include "base/files/scoped_file.h" | 21 #include "base/files/scoped_file.h" |
| 22 #include "base/files/scoped_temp_dir.h" | 22 #include "base/files/scoped_temp_dir.h" |
| 23 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "base/macros.h" |
| 24 #include "mojo/edk/embedder/platform_channel_utils_posix.h" | 25 #include "mojo/edk/embedder/platform_channel_utils_posix.h" |
| 25 #include "mojo/edk/embedder/platform_handle.h" | 26 #include "mojo/edk/embedder/platform_handle.h" |
| 26 #include "mojo/edk/embedder/platform_handle_vector.h" | 27 #include "mojo/edk/embedder/platform_handle_vector.h" |
| 27 #include "mojo/edk/embedder/scoped_platform_handle.h" | 28 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 28 #include "mojo/edk/test/test_utils.h" | 29 #include "mojo/edk/test/test_utils.h" |
| 29 #include "mojo/public/cpp/system/macros.h" | 30 #include "mojo/public/cpp/system/macros.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 32 |
| 32 namespace mojo { | 33 namespace mojo { |
| 33 namespace edk { | 34 namespace edk { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 } | 54 } |
| 54 | 55 |
| 55 void TearDown() override { | 56 void TearDown() override { |
| 56 // Restore the |SIGPIPE| handler. | 57 // Restore the |SIGPIPE| handler. |
| 57 ASSERT_EQ(0, sigaction(SIGPIPE, &old_action_, nullptr)); | 58 ASSERT_EQ(0, sigaction(SIGPIPE, &old_action_, nullptr)); |
| 58 } | 59 } |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 struct sigaction old_action_; | 62 struct sigaction old_action_; |
| 62 | 63 |
| 63 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformChannelPairPosixTest); | 64 DISALLOW_COPY_AND_ASSIGN(PlatformChannelPairPosixTest); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 TEST_F(PlatformChannelPairPosixTest, NoSigPipe) { | 67 TEST_F(PlatformChannelPairPosixTest, NoSigPipe) { |
| 67 PlatformChannelPair channel_pair; | 68 PlatformChannelPair channel_pair; |
| 68 ScopedPlatformHandle server_handle = channel_pair.PassServerHandle(); | 69 ScopedPlatformHandle server_handle = channel_pair.PassServerHandle(); |
| 69 ScopedPlatformHandle client_handle = channel_pair.PassClientHandle(); | 70 ScopedPlatformHandle client_handle = channel_pair.PassClientHandle(); |
| 70 | 71 |
| 71 // Write to the client. | 72 // Write to the client. |
| 72 static const char kHello[] = "hello"; | 73 static const char kHello[] = "hello"; |
| 73 EXPECT_EQ(static_cast<ssize_t>(sizeof(kHello)), | 74 EXPECT_EQ(static_cast<ssize_t>(sizeof(kHello)), |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 char read_buf[100]; | 253 char read_buf[100]; |
| 253 size_t bytes_read = fread(read_buf, 1, sizeof(read_buf), fp.get()); | 254 size_t bytes_read = fread(read_buf, 1, sizeof(read_buf), fp.get()); |
| 254 EXPECT_EQ(file_contents.size(), bytes_read); | 255 EXPECT_EQ(file_contents.size(), bytes_read); |
| 255 EXPECT_EQ(file_contents, std::string(read_buf, bytes_read)); | 256 EXPECT_EQ(file_contents, std::string(read_buf, bytes_read)); |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 | 259 |
| 259 } // namespace | 260 } // namespace |
| 260 } // namespace edk | 261 } // namespace edk |
| 261 } // namespace mojo | 262 } // namespace mojo |
| OLD | NEW |