diff --git a/ipc/BUILD.gn b/ipc/BUILD.gn index 7f5429c6abd1c7..9964e590a4616f 100644 --- a/ipc/BUILD.gn +++ b/ipc/BUILD.gn @@ -176,7 +176,6 @@ test("ipc_tests") { "ipc_test_message_generator.cc", "ipc_test_message_generator.h", "ipc_test_messages.h", - "run_all_unittests.cc", "sync_socket_unittest.cc", "unix_domain_socket_util_unittest.cc", ] @@ -200,6 +199,7 @@ test("ipc_tests") { ":test_support", "//base", "//base:i18n", + "//base/test:run_all_unittests", "//base/test:test_support", "//crypto", "//testing/gtest", diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc index 0ed66797aa11e8..c76af5a8d9db6d 100644 --- a/ipc/ipc_channel_posix_unittest.cc +++ b/ipc/ipc_channel_posix_unittest.cc @@ -114,15 +114,6 @@ class IPCChannelPosixTest : public base::MultiProcessTest { static const std::string GetConnectionSocketName(); static const std::string GetChannelDirName(); - bool WaitForExit(base::Process& process, int* exit_code) { -#if defined(OS_ANDROID) - return AndroidWaitForChildExitWithTimeout( - process, base::TimeDelta::Max(), exit_code); -#else - return process.WaitForExit(exit_code); -#endif // defined(OS_ANDROID) - } - protected: void SetUp() override; void TearDown() override; @@ -267,7 +258,12 @@ TEST_F(IPCChannelPosixTest, AcceptHangTest) { ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, out_listener.status()); } -TEST_F(IPCChannelPosixTest, AdvancedConnected) { +#if defined(OS_ANDROID) +#define MAYBE_AdvancedConnected DISABLED_AdvancedConnected +#else +#define MAYBE_AdvancedConnected AdvancedConnected +#endif +TEST_F(IPCChannelPosixTest, MAYBE_AdvancedConnected) { // Test creating a connection to an external process. IPCChannelPosixTestListener listener(false); IPC::ChannelHandle chan_handle(GetConnectionSocketName()); @@ -289,14 +285,19 @@ TEST_F(IPCChannelPosixTest, AdvancedConnected) { channel->Send(message); SpinRunLoop(TestTimeouts::action_timeout()); int exit_code = 0; - EXPECT_TRUE(WaitForExit(process, &exit_code)); + EXPECT_TRUE(process.WaitForExit(&exit_code)); EXPECT_EQ(0, exit_code); ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); ASSERT_FALSE(channel->HasAcceptedConnection()); unlink(chan_handle.name.c_str()); } -TEST_F(IPCChannelPosixTest, ResetState) { +#if defined(OS_ANDROID) +#define MAYBE_ResetState DISABLED_ResetState +#else +#define MAYBE_ResetState ResetState +#endif +TEST_F(IPCChannelPosixTest, MAYBE_ResetState) { // Test creating a connection to an external process. Close the connection, // but continue to listen and make sure another external process can connect // to us. @@ -329,7 +330,7 @@ TEST_F(IPCChannelPosixTest, ResetState) { SpinRunLoop(TestTimeouts::action_timeout()); EXPECT_TRUE(process.Terminate(0, false)); int exit_code = 0; - EXPECT_TRUE(WaitForExit(process2, &exit_code)); + EXPECT_TRUE(process2.WaitForExit(&exit_code)); EXPECT_EQ(0, exit_code); ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); ASSERT_FALSE(channel->HasAcceptedConnection()); @@ -358,7 +359,12 @@ TEST_F(IPCChannelPosixTest, BadChannelName) { EXPECT_FALSE(channel2->Connect()); } -TEST_F(IPCChannelPosixTest, MultiConnection) { +#if defined(OS_ANDROID) +#define MAYBE_MultiConnection DISABLED_MultiConnection +#else +#define MAYBE_MultiConnection MultiConnection +#endif +TEST_F(IPCChannelPosixTest, MAYBE_MultiConnection) { // Test setting up a connection to an external process, and then have // another external process attempt to connect to us. IPCChannelPosixTestListener listener(false); @@ -379,7 +385,7 @@ TEST_F(IPCChannelPosixTest, MultiConnection) { ASSERT_TRUE(process2.IsValid()); SpinRunLoop(TestTimeouts::action_max_timeout()); int exit_code = 0; - EXPECT_TRUE(WaitForExit(process2, &exit_code)); + EXPECT_TRUE(process2.WaitForExit(&exit_code)); EXPECT_EQ(exit_code, 0); ASSERT_EQ(IPCChannelPosixTestListener::DENIED, listener.status()); ASSERT_TRUE(channel->HasAcceptedConnection()); @@ -388,7 +394,7 @@ TEST_F(IPCChannelPosixTest, MultiConnection) { IPC::Message::PRIORITY_NORMAL); channel->Send(message); SpinRunLoop(TestTimeouts::action_timeout()); - EXPECT_TRUE(WaitForExit(process, &exit_code)); + EXPECT_TRUE(process.WaitForExit(&exit_code)); EXPECT_EQ(exit_code, 0); ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); ASSERT_FALSE(channel->HasAcceptedConnection()); diff --git a/ipc/ipc_channel_proxy_unittest.cc b/ipc/ipc_channel_proxy_unittest.cc index 5367157ec40700..5997668f0f56a2 100644 --- a/ipc/ipc_channel_proxy_unittest.cc +++ b/ipc/ipc_channel_proxy_unittest.cc @@ -273,7 +273,12 @@ class IPCChannelProxyTest : public IPCTestBase { std::unique_ptr listener_; }; -TEST_F(IPCChannelProxyTest, MessageClassFilters) { +#if defined(OS_ANDROID) +#define MAYBE_MessageClassFilters DISABLED_MessageClassFilters +#else +#define MAYBE_MessageClassFilters MessageClassFilters +#endif +TEST_F(IPCChannelProxyTest, MAYBE_MessageClassFilters) { // Construct a filter per message class. std::vector > class_filters; class_filters.push_back(make_scoped_refptr( @@ -297,7 +302,12 @@ TEST_F(IPCChannelProxyTest, MessageClassFilters) { EXPECT_EQ(1U, class_filters[i]->messages_received()); } -TEST_F(IPCChannelProxyTest, GlobalAndMessageClassFilters) { +#if defined(OS_ANDROID) +#define MAYBE_GlobalAndMessageClassFilters DISABLED_GlobalAndMessageClassFilters +#else +#define MAYBE_GlobalAndMessageClassFilters GlobalAndMessageClassFilters +#endif +TEST_F(IPCChannelProxyTest, MAYBE_GlobalAndMessageClassFilters) { // Add a class and global filter. scoped_refptr class_filter( new MessageCountFilter(TestMsgStart)); @@ -326,7 +336,12 @@ TEST_F(IPCChannelProxyTest, GlobalAndMessageClassFilters) { EXPECT_EQ(3U, global_filter->messages_received()); } -TEST_F(IPCChannelProxyTest, FilterRemoval) { +#if defined(OS_ANDROID) +#define MAYBE_FilterRemoval DISABLED_FilterRemoval +#else +#define MAYBE_FilterRemoval FilterRemoval +#endif +TEST_F(IPCChannelProxyTest, MAYBE_FilterRemoval) { // Add a class and global filter. scoped_refptr class_filter( new MessageCountFilter(TestMsgStart)); diff --git a/ipc/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc index f197a6b8164261..00e91f3a25ecee 100644 --- a/ipc/ipc_fuzzing_tests.cc +++ b/ipc/ipc_fuzzing_tests.cc @@ -271,9 +271,14 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(FuzzServerClient) { class IPCFuzzingTest : public IPCTestBase { }; +#if defined(OS_ANDROID) +#define MAYBE_SanityTest DISABLED_SanityTest +#else +#define MAYBE_SanityTest SanityTest +#endif // This test makes sure that the FuzzerClientListener and FuzzerServerListener // are working properly by generating two well formed IPC calls. -TEST_F(IPCFuzzingTest, SanityTest) { +TEST_F(IPCFuzzingTest, MAYBE_SanityTest) { Init("FuzzServerClient"); FuzzerClientListener listener; @@ -296,12 +301,17 @@ TEST_F(IPCFuzzingTest, SanityTest) { DestroyChannel(); } +#if defined(OS_ANDROID) +#define MAYBE_MsgBadPayloadShort DISABLED_MsgBadPayloadShort +#else +#define MAYBE_MsgBadPayloadShort MsgBadPayloadShort +#endif // This test uses a payload that is smaller than expected. This generates an // error while unpacking the IPC buffer which in debug trigger an assertion and // in release is ignored (!). Right after we generate another valid IPC to make // sure framing is working properly. #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) -TEST_F(IPCFuzzingTest, MsgBadPayloadShort) { +TEST_F(IPCFuzzingTest, MAYBE_MsgBadPayloadShort) { Init("FuzzServerClient"); FuzzerClientListener listener; @@ -325,11 +335,16 @@ TEST_F(IPCFuzzingTest, MsgBadPayloadShort) { } #endif +#if defined(OS_ANDROID) +#define MAYBE_MsgBadPayloadArgs DISABLED_MsgBadPayloadArgs +#else +#define MAYBE_MsgBadPayloadArgs MsgBadPayloadArgs +#endif // This test uses a payload that has too many arguments, but so the payload size // is big enough so the unpacking routine does not generate an error as in the // case of MsgBadPayloadShort test. This test does not pinpoint a flaw (per se) // as by design we don't carry type information on the IPC message. -TEST_F(IPCFuzzingTest, MsgBadPayloadArgs) { +TEST_F(IPCFuzzingTest, MAYBE_MsgBadPayloadArgs) { Init("FuzzServerClient"); FuzzerClientListener listener; diff --git a/ipc/ipc_send_fds_test.cc b/ipc/ipc_send_fds_test.cc index 9480d0e62320e1..81a995dafd02ca 100644 --- a/ipc/ipc_send_fds_test.cc +++ b/ipc/ipc_send_fds_test.cc @@ -143,7 +143,12 @@ class IPCSendFdsTest : public IPCTestBase { } }; -TEST_F(IPCSendFdsTest, DescriptorTest) { +#if defined(OS_ANDROID) +#define MAYBE_DescriptorTest DISABLED_DescriptorTest +#else +#define MAYBE_DescriptorTest DescriptorTest +#endif +TEST_F(IPCSendFdsTest, MAYBE_DescriptorTest) { Init("SendFdsClient"); RunServer(); } diff --git a/ipc/ipc_test_base.cc b/ipc/ipc_test_base.cc index 757d9f5bb626e8..831a59ad98ee51 100644 --- a/ipc/ipc_test_base.cc +++ b/ipc/ipc_test_base.cc @@ -144,13 +144,8 @@ bool IPCTestBase::WaitForClientShutdown() { DCHECK(client_process_.IsValid()); int exit_code; -#if defined(OS_ANDROID) - bool rv = AndroidWaitForChildExitWithTimeout( - client_process_, base::TimeDelta::FromSeconds(5), &exit_code); -#else bool rv = client_process_.WaitForExitWithTimeout( base::TimeDelta::FromSeconds(5), &exit_code); -#endif // defined(OS_ANDROID) client_process_.Close(); return rv; } diff --git a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc index 4fa52e2a1c5717..dcf68bd2b14c3f 100644 --- a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc +++ b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc @@ -59,7 +59,13 @@ void TestingDelegate::OnBootstrapError() { quit_callback_.Run(); } -TEST_F(IPCMojoBootstrapTest, Connect) { +// Times out on Android; see http://crbug.com/502290 +#if defined(OS_ANDROID) +#define MAYBE_Connect DISABLED_Connect +#else +#define MAYBE_Connect Connect +#endif +TEST_F(IPCMojoBootstrapTest, MAYBE_Connect) { base::MessageLoop message_loop; base::RunLoop run_loop; TestingDelegate delegate(run_loop.QuitClosure()); diff --git a/ipc/run_all_unittests.cc b/ipc/run_all_unittests.cc index 5f9cc16755f7f5..26a73955eaf422 100644 --- a/ipc/run_all_unittests.cc +++ b/ipc/run_all_unittests.cc @@ -4,7 +4,6 @@ #include "base/bind.h" #include "base/test/launcher/unit_test_launcher.h" -#include "base/test/multiprocess_test.h" #include "base/test/test_suite.h" #include "build/build_config.h" @@ -15,8 +14,6 @@ int main(int argc, char** argv) { #if defined(OS_ANDROID) - base::InitAndroidMultiProcessTestHelper(main); - JNIEnv* env = base::android::AttachCurrentThread(); base::RegisterContentUriTestUtils(env); #endif diff --git a/ipc/sync_socket_unittest.cc b/ipc/sync_socket_unittest.cc index 3385646bd70dd5..7c83b247974711 100644 --- a/ipc/sync_socket_unittest.cc +++ b/ipc/sync_socket_unittest.cc @@ -167,7 +167,12 @@ class SyncSocketClientListener : public IPC::Listener { class SyncSocketTest : public IPCTestBase { }; -TEST_F(SyncSocketTest, SanityTest) { +#if defined(OS_ANDROID) +#define MAYBE_SanityTest DISABLED_SanityTest +#else +#define MAYBE_SanityTest SanityTest +#endif +TEST_F(SyncSocketTest, MAYBE_SanityTest) { Init("SyncSocketServerClient"); SyncSocketClientListener listener; @@ -249,8 +254,13 @@ TEST_F(SyncSocketTest, DisconnectTest) { EXPECT_EQ(0U, received); } +#if defined(OS_ANDROID) +#define MAYBE_BlockingReceiveTest DISABLED_BlockingReceiveTest +#else +#define MAYBE_BlockingReceiveTest BlockingReceiveTest +#endif // Tests that read is a blocking operation. -TEST_F(SyncSocketTest, BlockingReceiveTest) { +TEST_F(SyncSocketTest, MAYBE_BlockingReceiveTest) { base::CancelableSyncSocket pair[2]; ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&pair[0], &pair[1]));