Commit 7de8580b authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Add layout_test_proxy

When running layout tests on Fuchsia the test runner and content_shell
will run on separate machines. The tests still expect to be loaded from
localhost, so HTTP connections need to be proxied from the Fuchsia
to the host that runs http server. Potentially this can be done with
SSH, but TCP forwarding is broken in sshd on Fuchsia at the moment
due to select() limitations (see ZX-1555).

This CL adds a new executable that will be used proxy connections for
layout tests. The implementation is based on the socket proxy
that's currently used to proxy test_server connections in
net_unittests. That code is also being moved from
net/test/spawned_test_server to net/test.


Bug: 778467
Change-Id: I9c86cf5f27cbfd01b0c475ec242c6262bf7c6b57
Reviewed-on: https://chromium-review.googlesource.com/858289
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530587}
parent 60916ba1
......@@ -947,7 +947,10 @@ if (!is_ios) {
}
if (is_fuchsia) {
data_deps += [ "//content/shell:content_shell_fuchsia" ]
data_deps += [
"//content/shell:content_shell_fuchsia",
"//build/fuchsia/layout_test_proxy:layout_test_proxy_runner",
]
}
data = [
......
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
assert(is_fuchsia)
import("//testing/test.gni")
# Binary used to proxy TCP connections from a Fuchsia process. Potentially SSH
# can be used to forward TCP, but this feature is currently broken on Fuchsia,
# see ZX-1555. layout_test_proxy can be removed once that issue with sshd is
# fixed and layout tests are updated to use SSH.
executable("layout_test_proxy") {
testonly = true
sources = [
"layout_test_proxy.cc",
]
deps = [
"//net",
"//net:test_support",
]
}
fuchsia_executable_runner("layout_test_proxy_runner") {
testonly = true
exe_target = ":layout_test_proxy"
}
include_rules = [
"+net",
]
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "net/base/ip_endpoint.h"
#include "net/test/tcp_socket_proxy.h"
const char kPortsSwitch[] = "ports";
const char kRemoteAddressSwitch[] = "remote-address";
int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(kPortsSwitch)) {
LOG(ERROR) << "--" << kPortsSwitch << " was not specified.";
return 1;
}
std::vector<std::string> ports_strings =
base::SplitString(command_line->GetSwitchValueASCII(kPortsSwitch), ",",
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
if (ports_strings.empty()) {
LOG(ERROR) << "At least one port must be specified with --" << kPortsSwitch;
return 1;
}
std::vector<int> ports;
for (auto& port_string : ports_strings) {
int port;
if (!base::StringToInt(port_string, &port) || port <= 0 || port > 65535) {
LOG(ERROR) << "Invalid value specified for --" << kPortsSwitch << ": "
<< port_string;
return 1;
}
ports.push_back(port);
}
if (!command_line->HasSwitch(kRemoteAddressSwitch)) {
LOG(ERROR) << "--" << kRemoteAddressSwitch << " was not specified.";
return 1;
}
std::string remote_address_str =
command_line->GetSwitchValueASCII(kRemoteAddressSwitch);
net::IPAddress remote_address;
if (!remote_address.AssignFromIPLiteral(remote_address_str)) {
LOG(ERROR) << "Invalid value specified for --" << kRemoteAddressSwitch
<< ": " << remote_address_str;
return 1;
}
base::MessageLoopForIO message_loop;
std::vector<std::unique_ptr<net::TcpSocketProxy>> proxies;
for (int port : ports) {
auto test_server_proxy =
std::make_unique<net::TcpSocketProxy>(message_loop.task_runner());
if (!test_server_proxy->Initialize(port)) {
LOG(ERROR) << "Can't bind proxy to port " << port;
return 1;
}
LOG(INFO) << "Listening on port " << test_server_proxy->local_port();
test_server_proxy->Start(net::IPEndPoint(remote_address, port));
proxies.push_back(std::move(test_server_proxy));
}
// Run the message loop indefinitely.
base::RunLoop().Run();
return 0;
}
\ No newline at end of file
......@@ -2629,6 +2629,8 @@ static_library("test_support") {
"test/net_test_suite.h",
"test/scoped_disable_exit_on_dfatal.cc",
"test/scoped_disable_exit_on_dfatal.h",
"test/tcp_socket_proxy.cc",
"test/tcp_socket_proxy.h",
"test/test_certificate_data.h",
"test/test_data_directory.cc",
"test/test_data_directory.h",
......@@ -2687,26 +2689,24 @@ static_library("test_support") {
"test/spawned_test_server/base_test_server.h",
"test/spawned_test_server/spawned_test_server.h",
]
}
if (use_remote_test_server) {
sources += [
"test/spawned_test_server/remote_test_server.cc",
"test/spawned_test_server/remote_test_server.h",
"test/spawned_test_server/remote_test_server_config.cc",
"test/spawned_test_server/remote_test_server_config.h",
"test/spawned_test_server/remote_test_server_proxy.cc",
"test/spawned_test_server/remote_test_server_proxy.h",
"test/spawned_test_server/remote_test_server_spawner_request.cc",
"test/spawned_test_server/remote_test_server_spawner_request.h",
]
} else {
sources += [
"test/spawned_test_server/local_test_server.cc",
"test/spawned_test_server/local_test_server.h",
"test/spawned_test_server/local_test_server_posix.cc",
"test/spawned_test_server/local_test_server_win.cc",
]
}
if (use_remote_test_server) {
sources += [
"test/spawned_test_server/remote_test_server.cc",
"test/spawned_test_server/remote_test_server.h",
"test/spawned_test_server/remote_test_server_config.cc",
"test/spawned_test_server/remote_test_server_config.h",
"test/spawned_test_server/remote_test_server_spawner_request.cc",
"test/spawned_test_server/remote_test_server_spawner_request.h",
]
} else if (!is_ios) {
sources += [
"test/spawned_test_server/local_test_server.cc",
"test/spawned_test_server/local_test_server.h",
"test/spawned_test_server/local_test_server_posix.cc",
"test/spawned_test_server/local_test_server_win.cc",
]
}
if (enable_python_utils) {
......@@ -5265,6 +5265,7 @@ test("net_unittests") {
"test/embedded_test_server/http_request_unittest.cc",
"test/embedded_test_server/http_response_unittest.cc",
"test/run_all_unittests.cc",
"test/tcp_socket_proxy_unittest.cc",
"third_party/nist-pkits/pkits_testcases-inl.h",
"tools/content_decoder_tool/content_decoder_tool.cc",
"tools/content_decoder_tool/content_decoder_tool.h",
......@@ -5436,11 +5437,6 @@ test("net_unittests") {
]
}
if (use_remote_test_server) {
sources +=
[ "test/spawned_test_server/remote_test_server_proxy_unittests.cc" ]
}
if (enable_python_utils) {
sources += [ "test/python_utils_unittest.cc" ]
}
......
......@@ -23,8 +23,8 @@
#include "net/base/host_port_pair.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/test/spawned_test_server/remote_test_server_proxy.h"
#include "net/test/spawned_test_server/remote_test_server_spawner_request.h"
#include "net/test/tcp_socket_proxy.h"
#include "url/gurl.h"
namespace net {
......@@ -96,8 +96,9 @@ bool RemoteTestServer::StartInBackground() {
SSLOptions::CERT_AUTO_AIA_INTERMEDIATE ||
!ssl_options().GetOCSPArgument().empty());
if (config_.address() != IPAddress::IPv4Localhost() && ocsp_server_enabled) {
ocsp_proxy_ =
std::make_unique<RemoteTestServerProxy>(io_thread_.task_runner());
ocsp_proxy_ = std::make_unique<TcpSocketProxy>(io_thread_.task_runner());
bool initialized = !ocsp_proxy_->Initialize();
CHECK(initialized);
arguments_dict.SetKey("ocsp-proxy-port-number",
base::Value(ocsp_proxy_->local_port()));
}
......@@ -135,7 +136,9 @@ bool RemoteTestServer::BlockUntilStarted() {
// forward connections to the server.
if (config_.address() != IPAddress::IPv4Localhost()) {
test_server_proxy_ =
std::make_unique<RemoteTestServerProxy>(io_thread_.task_runner());
std::make_unique<TcpSocketProxy>(io_thread_.task_runner());
bool initialized = !test_server_proxy_->Initialize();
CHECK(initialized);
test_server_proxy_->Start(IPEndPoint(config_.address(), remote_port_));
if (ocsp_proxy_) {
......
......@@ -15,7 +15,7 @@
namespace net {
class RemoteTestServerSpawnerRequest;
class RemoteTestServerProxy;
class TcpSocketProxy;
// The RemoteTestServer runs an external Python-based test server in another
// machine that is different from the machine that executes the tests. It is
......@@ -92,8 +92,8 @@ class RemoteTestServer : public BaseTestServer {
// Server port. Non-zero when the server is running.
int remote_port_ = 0;
std::unique_ptr<RemoteTestServerProxy> test_server_proxy_;
std::unique_ptr<RemoteTestServerProxy> ocsp_proxy_;
std::unique_ptr<TcpSocketProxy> test_server_proxy_;
std::unique_ptr<TcpSocketProxy> ocsp_proxy_;
DISALLOW_COPY_AND_ASSIGN(RemoteTestServer);
};
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/test/spawned_test_server/remote_test_server_proxy.h"
#include "net/test/tcp_socket_proxy.h"
#include <memory>
#include <vector>
......@@ -112,13 +112,13 @@ class ConnectionProxy {
explicit ConnectionProxy(std::unique_ptr<StreamSocket> local_socket);
~ConnectionProxy();
void Start(const IPEndPoint& remote_address,
void Start(const IPEndPoint& remote_endpoint,
base::OnceClosure on_done_callback);
private:
void Close();
void HandleConnectResult(const IPEndPoint& remote_address, int result);
void HandleConnectResult(const IPEndPoint& remote_endpoint, int result);
base::OnceClosure on_done_callback_;
......@@ -142,28 +142,28 @@ ConnectionProxy::~ConnectionProxy() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
void ConnectionProxy::Start(const IPEndPoint& remote_address,
void ConnectionProxy::Start(const IPEndPoint& remote_endpoint,
base::OnceClosure on_done_callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
on_done_callback_ = std::move(on_done_callback);
remote_socket_ = std::make_unique<TCPClientSocket>(
AddressList(remote_address), nullptr, nullptr, NetLogSource());
AddressList(remote_endpoint), nullptr, nullptr, NetLogSource());
int result = remote_socket_->Connect(
base::Bind(&ConnectionProxy::HandleConnectResult, base::Unretained(this),
remote_address));
remote_endpoint));
if (result != ERR_IO_PENDING)
HandleConnectResult(remote_address, result);
HandleConnectResult(remote_endpoint, result);
}
void ConnectionProxy::HandleConnectResult(const IPEndPoint& remote_address,
void ConnectionProxy::HandleConnectResult(const IPEndPoint& remote_endpoint,
int result) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!incoming_pump_);
DCHECK(!outgoing_pump_);
if (result < 0) {
LOG(ERROR) << "Connection to " << remote_address.ToString()
LOG(ERROR) << "Connection to " << remote_endpoint.ToString()
<< " failed: " << ErrorToString(result);
Close();
return;
......@@ -194,20 +194,14 @@ void ConnectionProxy::Close() {
} // namespace
// RemoteTestServerProxy implementation that runs on a background IO thread.
class RemoteTestServerProxy::Core {
// TcpSocketProxy implementation that runs on a background IO thread.
class TcpSocketProxy::Core {
public:
Core();
~Core();
// Creates local socket for accepting incoming connections and binds it to a
// port. local_port() comes valid after this call is complete.
void Initialize(base::WaitableEvent* initialized_event);
// Starts accepting incoming connections and redirecting them to
// remote_address. Must be called only after Initialize().
void Start(const IPEndPoint& remote_address);
void Initialize(int local_port, base::WaitableEvent* initialized_event);
void Start(const IPEndPoint& remote_endpoint);
uint16_t local_port() const { return local_port_; }
private:
......@@ -216,11 +210,11 @@ class RemoteTestServerProxy::Core {
void HandleAcceptResult(int result);
void OnConnectionClosed(ConnectionProxy* connection);
IPEndPoint remote_address_;
IPEndPoint remote_endpoint_;
std::unique_ptr<TCPServerSocket> socket_;
uint16_t local_port_;
uint16_t local_port_ = 0;
std::vector<std::unique_ptr<ConnectionProxy>> connections_;
std::unique_ptr<StreamSocket> accepted_socket_;
......@@ -228,35 +222,46 @@ class RemoteTestServerProxy::Core {
DISALLOW_COPY_AND_ASSIGN(Core);
};
RemoteTestServerProxy::Core::Core() {}
TcpSocketProxy::Core::Core() {}
void RemoteTestServerProxy::Core::Initialize(
base::WaitableEvent* initialized_event) {
CHECK(!socket_);
void TcpSocketProxy::Core::Initialize(int local_port,
base::WaitableEvent* initialized_event) {
DCHECK(!socket_);
socket_ = std::make_unique<TCPServerSocket>(nullptr, net::NetLogSource());
int result = socket_->Listen(IPEndPoint(IPAddress::IPv4Localhost(), 0), 5);
CHECK_EQ(result, OK);
local_port_ = 0;
// Get local port number.
IPEndPoint address;
result = socket_->GetLocalAddress(&address);
CHECK_EQ(result, OK);
local_port_ = address.port();
socket_ = std::make_unique<TCPServerSocket>(nullptr, net::NetLogSource());
int result =
socket_->Listen(IPEndPoint(IPAddress::IPv4Localhost(), local_port), 5);
if (result != OK) {
LOG(ERROR) << "TcpServerSocket::Listen() returned "
<< ErrorToString(result);
} else {
// Get local port number.
IPEndPoint address;
result = socket_->GetLocalAddress(&address);
if (result != OK) {
LOG(ERROR) << "TcpServerSocket::GetLocalAddress() returned "
<< ErrorToString(result);
} else {
local_port_ = address.port();
}
}
initialized_event->Signal();
if (initialized_event)
initialized_event->Signal();
}
void RemoteTestServerProxy::Core::Start(const IPEndPoint& remote_address) {
CHECK(socket_);
void TcpSocketProxy::Core::Start(const IPEndPoint& remote_endpoint) {
DCHECK(socket_);
remote_address_ = remote_address;
remote_endpoint_ = remote_endpoint;
DoAcceptLoop();
}
RemoteTestServerProxy::Core::~Core() {}
TcpSocketProxy::Core::~Core() {}
void RemoteTestServerProxy::Core::DoAcceptLoop() {
void TcpSocketProxy::Core::DoAcceptLoop() {
int result = OK;
while (result == OK) {
result = socket_->Accept(
......@@ -267,13 +272,13 @@ void RemoteTestServerProxy::Core::DoAcceptLoop() {
}
}
void RemoteTestServerProxy::Core::OnAcceptResult(int result) {
void TcpSocketProxy::Core::OnAcceptResult(int result) {
HandleAcceptResult(result);
if (result == OK)
DoAcceptLoop();
}
void RemoteTestServerProxy::Core::HandleAcceptResult(int result) {
void TcpSocketProxy::Core::HandleAcceptResult(int result) {
DCHECK_NE(result, ERR_IO_PENDING);
if (result < 0) {
......@@ -290,13 +295,12 @@ void RemoteTestServerProxy::Core::HandleAcceptResult(int result) {
// Start() may invoke the callback so it needs to be called after the
// connection is pushed to connections_.
connection_proxy_ptr->Start(
remote_address_,
remote_endpoint_,
base::BindOnce(&Core::OnConnectionClosed, base::Unretained(this),
connection_proxy_ptr));
}
void RemoteTestServerProxy::Core::OnConnectionClosed(
ConnectionProxy* connection) {
void TcpSocketProxy::Core::OnConnectionClosed(ConnectionProxy* connection) {
for (auto it = connections_.begin(); it != connections_.end(); ++it) {
if (it->get() == connection) {
connections_.erase(it);
......@@ -306,30 +310,40 @@ void RemoteTestServerProxy::Core::OnConnectionClosed(
NOTREACHED();
}
RemoteTestServerProxy::RemoteTestServerProxy(
TcpSocketProxy::TcpSocketProxy(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
: io_task_runner_(io_task_runner), core_(std::make_unique<Core>()) {
base::WaitableEvent intialized_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
io_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&Core::Initialize, base::Unretained(core_.get()),
&intialized_event));
intialized_event.Wait();
: io_task_runner_(io_task_runner), core_(std::make_unique<Core>()) {}
bool TcpSocketProxy::Initialize(int local_port) {
DCHECK(!local_port_);
if (io_task_runner_->BelongsToCurrentThread()) {
core_->Initialize(local_port, nullptr);
} else {
base::WaitableEvent initialized_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
io_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&Core::Initialize, base::Unretained(core_.get()),
local_port, &initialized_event));
initialized_event.Wait();
}
local_port_ = core_->local_port();
return local_port_ != 0;
}
RemoteTestServerProxy::~RemoteTestServerProxy() {
TcpSocketProxy::~TcpSocketProxy() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
io_task_runner_->DeleteSoon(FROM_HERE, core_.release());
io_task_runner_->DeleteSoon(FROM_HERE, std::move(core_));
}
void RemoteTestServerProxy::Start(const IPEndPoint& remote_address) {
void TcpSocketProxy::Start(const IPEndPoint& remote_endpoint) {
io_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&Core::Start, base::Unretained(core_.get()),
remote_address));
remote_endpoint));
}
} // namespace net
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_TEST_SPAWNED_TEST_SERVER_REMOTE_TEST_SERVER_PROXY_H_
#define NET_TEST_SPAWNED_TEST_SERVER_REMOTE_TEST_SERVER_PROXY_H_
#ifndef NET_TEST_TCP_SOCKET_PROXY_H_
#define NET_TEST_TCP_SOCKET_PROXY_H_
#include <stdint.h>
......@@ -20,19 +20,27 @@ namespace net {
class IPEndPoint;
// RemoteTestServerProxy proxies TCP connection from localhost to a remote IP
// address.
class RemoteTestServerProxy {
// TcpSocketProxy proxies TCP connection from localhost to a remote IP address.
class TcpSocketProxy {
public:
explicit RemoteTestServerProxy(
explicit TcpSocketProxy(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
~RemoteTestServerProxy();
~TcpSocketProxy();
// Initializes local socket for the proxy. If |local_port| is not 0 then the
// proxy will listen on that port. Otherwise the socket will be bound to an
// available port and local_port() should be used to get the port number.
// Returns false if initialization fails.
bool Initialize(int local_port = 0);
// Local port number for the proxy or 0 if the proxy is not initialized.
uint16_t local_port() const { return local_port_; }
// Starts the proxy for the specified |remote_address|. Must be called before
// any incoming connection on local_port() are initiated.
void Start(const IPEndPoint& remote_address);
// Starts the proxy for the specified |remote_endpoint|. Must be called after
// a successful Initialize() call and before any incoming connection on
// local_port() are initiated. Port number in |remote_endpoint| may be
// different from local_port().
void Start(const IPEndPoint& remote_endpoint);
private:
class Core;
......@@ -42,13 +50,13 @@ class RemoteTestServerProxy {
// Core implements the proxy functionality. It runs on |io_task_runner_|.
std::unique_ptr<Core> core_;
uint16_t local_port_;
uint16_t local_port_ = 0;
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(RemoteTestServerProxy);
DISALLOW_COPY_AND_ASSIGN(TcpSocketProxy);
};
} // namespace net
#endif // NET_TEST_SPAWNED_TEST_SERVER_REMOTE_TEST_SERVER_PROXY_H_
#endif // NET_TEST_TCP_SOCKET_PROXY_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/test/spawned_test_server/remote_test_server_proxy.h"
#include "net/test/tcp_socket_proxy.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h"
......@@ -18,9 +18,9 @@ using net::test::IsOk;
namespace net {
class RemoteTestServerProxyTest : public testing::Test {
class TcpSocketProxyTest : public testing::Test {
public:
RemoteTestServerProxyTest() : io_thread_("RemoteTestServer IO Thread") {
TcpSocketProxyTest() : io_thread_("TcpSocketProxyTest IO Thread") {
EXPECT_TRUE(io_thread_.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0)));
......@@ -35,7 +35,9 @@ class RemoteTestServerProxyTest : public testing::Test {
result = listen_socket_->GetLocalAddress(&address);
EXPECT_THAT(result, IsOk());
proxy_ = std::make_unique<RemoteTestServerProxy>(io_thread_.task_runner());
proxy_ = std::make_unique<TcpSocketProxy>(io_thread_.task_runner());
EXPECT_TRUE(proxy_->Initialize());
proxy_address_ =
IPEndPoint(IPAddress::IPv4Localhost(), proxy_->local_port());
proxy_->Start(address);
......@@ -94,15 +96,15 @@ class RemoteTestServerProxyTest : public testing::Test {
protected:
base::Thread io_thread_;
// Server socket that simulates testserver that RemoteTestServerProxy normally
// Server socket that simulates testserver that TcpSocketProxy normally
// would connect to.
std::unique_ptr<TCPServerSocket> listen_socket_;
std::unique_ptr<RemoteTestServerProxy> proxy_;
std::unique_ptr<TcpSocketProxy> proxy_;
IPEndPoint proxy_address_;
};
TEST_F(RemoteTestServerProxyTest, SendAndReceive) {
TEST_F(TcpSocketProxyTest, SendAndReceive) {
std::unique_ptr<StreamSocket> client_socket;
std::unique_ptr<StreamSocket> server_socket;
MakeConnection(&client_socket, &server_socket);
......@@ -110,7 +112,7 @@ TEST_F(RemoteTestServerProxyTest, SendAndReceive) {
SendAndReceiveData(server_socket.get(), client_socket.get());
}
TEST_F(RemoteTestServerProxyTest, TwoConnections) {
TEST_F(TcpSocketProxyTest, TwoConnections) {
std::unique_ptr<StreamSocket> client_socket1;
std::unique_ptr<StreamSocket> server_socket1;
MakeConnection(&client_socket1, &server_socket1);
......@@ -127,7 +129,7 @@ TEST_F(RemoteTestServerProxyTest, TwoConnections) {
// Close socket on the server side and verify that it's closed on the client
// side.
TEST_F(RemoteTestServerProxyTest, DisconnectServer) {
TEST_F(TcpSocketProxyTest, DisconnectServer) {
std::unique_ptr<StreamSocket> client_socket;
std::unique_ptr<StreamSocket> server_socket;
MakeConnection(&client_socket, &server_socket);
......@@ -137,7 +139,7 @@ TEST_F(RemoteTestServerProxyTest, DisconnectServer) {
// Close socket on the client side and verify that it's closed on the server
// side.
TEST_F(RemoteTestServerProxyTest, DisconnectClient) {
TEST_F(TcpSocketProxyTest, DisconnectClient) {
std::unique_ptr<StreamSocket> client_socket;
std::unique_ptr<StreamSocket> server_socket;
MakeConnection(&client_socket, &server_socket);
......@@ -145,4 +147,11 @@ TEST_F(RemoteTestServerProxyTest, DisconnectClient) {
ExpectClosed(server_socket.get());
}
// Initialize() must fail if the port is in use.
TEST_F(TcpSocketProxyTest, PortInUse) {
// Try initializing second proxy on the same port.
auto proxy2 = std::make_unique<TcpSocketProxy>(io_thread_.task_runner());
EXPECT_FALSE(proxy2->Initialize(proxy_->local_port()));
}
} // namespace net
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