Limit the behavior of some tests to avoid OS X flake
R=viettrungluu@chromium.org
BUG=488258
Review URL: https://codereview.chromium.org/1152623006
diff --git a/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc b/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc
index 56540d7..107406e 100644
--- a/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc
+++ b/mojo/edk/embedder/platform_channel_pair_posix_unittest.cc
@@ -137,7 +137,14 @@
ScopedPlatformHandle server_handle = channel_pair.PassServerHandle().Pass();
ScopedPlatformHandle client_handle = channel_pair.PassClientHandle().Pass();
- for (size_t i = 1; i < kPlatformChannelMaxNumHandles; i++) {
+// Reduce the number of FDs opened on OS X to avoid test flake.
+#if defined(OS_MACOSX)
+ const size_t kNumHandlesToSend = kPlatformChannelMaxNumHandles / 2;
+#else
+ const size_t kNumHandlesToSend = kPlatformChannelMaxNumHandles;
+#endif
+
+ for (size_t i = 1; i < kNumHandlesToSend; i++) {
// Make |i| files, with the j-th file consisting of j copies of the digit
// |c|.
const char c = '0' + (i % 10);
@@ -178,7 +185,7 @@
received_handles.pop_front();
ASSERT_TRUE(fp);
rewind(fp.get());
- char read_buf[kPlatformChannelMaxNumHandles];
+ char read_buf[kNumHandlesToSend];
size_t bytes_read = fread(read_buf, 1, sizeof(read_buf), fp.get());
EXPECT_EQ(j + 1, bytes_read);
EXPECT_EQ(std::string(j + 1, c), std::string(read_buf, bytes_read));
diff --git a/mojo/edk/system/multiprocess_message_pipe_unittest.cc b/mojo/edk/system/multiprocess_message_pipe_unittest.cc
index dcdc500..3512868 100644
--- a/mojo/edk/system/multiprocess_message_pipe_unittest.cc
+++ b/mojo/edk/system/multiprocess_message_pipe_unittest.cc
@@ -512,7 +512,7 @@
#if defined(OS_POSIX) && !defined(OS_ANDROID)
INSTANTIATE_TEST_CASE_P(PipeCount,
MultiprocessMessagePipeTestWithPipeCount,
- testing::Values(1u, 128u, 255u));
+ testing::Values(1u, 128u, 140u));
#endif
} // namespace