Commit a47da1e4 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Fix flaky IPCMojoBootstrapTest fixture

If you don't install a connection error handler before an error can
signal, you're gonna have a bad time.

Bug: 826450
Change-Id: I1a1b16b66449d89783aa8a9fae34e57e91a1d4f9
Reviewed-on: https://chromium-review.googlesource.com/998994Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548610}
parent fbeb883a
...@@ -4,27 +4,18 @@ ...@@ -4,27 +4,18 @@
#include "ipc/ipc_mojo_bootstrap.h" #include "ipc/ipc_mojo_bootstrap.h"
#include <stdint.h> #include <cstdint>
#include <memory> #include <memory>
#include <utility>
#include "base/base_paths.h"
#include "base/files/file.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc.mojom.h" #include "ipc/ipc.mojom.h"
#include "ipc/ipc_test_base.h" #include "ipc/ipc_test_base.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/test/mojo_test_base.h"
#include "mojo/edk/test/multiprocess_test_helper.h" #include "mojo/edk/test/multiprocess_test_helper.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding.h"
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
#endif
namespace { namespace {
constexpr int32_t kTestServerPid = 42; constexpr int32_t kTestServerPid = 42;
...@@ -65,7 +56,10 @@ class PeerPidReceiver : public IPC::mojom::Channel { ...@@ -65,7 +56,10 @@ class PeerPidReceiver : public IPC::mojom::Channel {
MessageExpectation message_expectation = MessageExpectation::kNotExpected) MessageExpectation message_expectation = MessageExpectation::kNotExpected)
: binding_(this, std::move(request)), : binding_(this, std::move(request)),
on_peer_pid_set_(on_peer_pid_set), on_peer_pid_set_(on_peer_pid_set),
message_expectation_(message_expectation) {} message_expectation_(message_expectation) {
binding_.set_connection_error_handler(disconnect_run_loop_.QuitClosure());
}
~PeerPidReceiver() override { ~PeerPidReceiver() override {
bool expected_message = bool expected_message =
message_expectation_ != MessageExpectation::kNotExpected; message_expectation_ != MessageExpectation::kNotExpected;
...@@ -97,19 +91,15 @@ class PeerPidReceiver : public IPC::mojom::Channel { ...@@ -97,19 +91,15 @@ class PeerPidReceiver : public IPC::mojom::Channel {
int32_t peer_pid() const { return peer_pid_; } int32_t peer_pid() const { return peer_pid_; }
void RunUntilDisconnect() { void RunUntilDisconnect() { disconnect_run_loop_.Run(); }
base::RunLoop run_loop;
binding_.set_connection_error_handler(run_loop.QuitClosure());
run_loop.Run();
}
private: private:
mojo::AssociatedBinding<IPC::mojom::Channel> binding_; mojo::AssociatedBinding<IPC::mojom::Channel> binding_;
const base::Closure on_peer_pid_set_; const base::Closure on_peer_pid_set_;
MessageExpectation message_expectation_; MessageExpectation message_expectation_;
int32_t peer_pid_ = -1; int32_t peer_pid_ = -1;
bool received_message_ = false; bool received_message_ = false;
base::RunLoop disconnect_run_loop_;
DISALLOW_COPY_AND_ASSIGN(PeerPidReceiver); DISALLOW_COPY_AND_ASSIGN(PeerPidReceiver);
}; };
...@@ -165,8 +155,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP( ...@@ -165,8 +155,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP(
return 0; return 0;
} }
// TODO(https://crbug.com/826450): Fix flakiness and re-enable. TEST_F(IPCMojoBootstrapTest, ReceiveEmptyMessage) {
TEST_F(IPCMojoBootstrapTest, DISABLED_ReceiveEmptyMessage) {
base::MessageLoop message_loop; base::MessageLoop message_loop;
Connection connection( Connection connection(
IPC::MojoBootstrap::Create( IPC::MojoBootstrap::Create(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment