Commit b68b558b authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

[fuchsia] Add webrunner unit tests, browsertests to Fuchsia bots.

* Fixed webrunner_unittests (tests were not being exercised, so the
  test code drifted from the impl)
* Added webrunner_unittests, webrunner_browsertests to Fuchsia test
  bot list.


Bug: 871594
Change-Id: I3f86f2f1d76534c51236a3dea43dc898d996b121
Reviewed-on: https://chromium-review.googlesource.com/1174868
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584669}
parent ac8b5ef7
...@@ -3129,6 +3129,18 @@ ...@@ -3129,6 +3129,18 @@
"can_use_on_swarming_builders": true "can_use_on_swarming_builders": true
}, },
"test": "ui_base_unittests" "test": "ui_base_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "webrunner_browsertests"
},
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "webrunner_unittests"
} }
] ]
}, },
...@@ -3280,6 +3292,28 @@ ...@@ -3280,6 +3292,28 @@
] ]
}, },
"test": "ui_base_unittests" "test": "ui_base_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1"
}
]
},
"test": "webrunner_browsertests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1"
}
]
},
"test": "webrunner_unittests"
} }
] ]
}, },
...@@ -3446,6 +3480,28 @@ ...@@ -3446,6 +3480,28 @@
] ]
}, },
"test": "ui_base_unittests" "test": "ui_base_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1"
}
]
},
"test": "webrunner_browsertests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1"
}
]
},
"test": "webrunner_unittests"
} }
] ]
}, },
......
...@@ -786,6 +786,28 @@ ...@@ -786,6 +786,28 @@
] ]
}, },
"test": "ui_base_unittests" "test": "ui_base_unittests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1"
}
]
},
"test": "webrunner_browsertests"
},
{
"swarming": {
"can_use_on_swarming_builders": true,
"dimension_sets": [
{
"kvm": "1"
}
]
},
"test": "webrunner_unittests"
} }
] ]
}, },
......
...@@ -1351,6 +1351,14 @@ ...@@ -1351,6 +1351,14 @@
"../../third_party/blink/tools/run_blinkpy_tests.py" "../../third_party/blink/tools/run_blinkpy_tests.py"
] ]
}, },
"webrunner_browsertests": {
"label": "//webrunner:webrunner_browsertests",
"type": "console_test_launcher",
},
"webrunner_unittests": {
"label": "//webrunner:webrunner_unittests",
"type": "console_test_launcher",
},
"webkit_unit_tests": { "webkit_unit_tests": {
"label": "//third_party/blink/renderer/controller:webkit_unit_tests", "label": "//third_party/blink/renderer/controller:webkit_unit_tests",
"type": "console_test_launcher", "type": "console_test_launcher",
......
...@@ -981,6 +981,8 @@ ...@@ -981,6 +981,8 @@
'--test-launcher-filter-file=../../testing/buildbot/filters/fuchsia.ui_base_unittests.filter', '--test-launcher-filter-file=../../testing/buildbot/filters/fuchsia.ui_base_unittests.filter',
], ],
}, },
'webrunner_browsertests': {},
'webrunner_unittests': {},
}, },
'goma_gtests': { 'goma_gtests': {
......
...@@ -190,8 +190,7 @@ test("webrunner_browsertests") { ...@@ -190,8 +190,7 @@ test("webrunner_browsertests") {
test("webrunner_unittests") { test("webrunner_unittests") {
sources = [ sources = [
# TODO(kmarshall): Uncomment this when the tests are fixed. "service/context_provider_impl_unittest.cc",
# "service/context_provider_impl_unittest.cc",
] ]
deps = [ deps = [
":fidl", ":fidl",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "webrunner/service/context_provider_impl.h" #include "webrunner/service/context_provider_impl.h"
#include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h>
#include <lib/async/default.h>
#include <lib/zx/job.h> #include <lib/zx/job.h>
#include <stdio.h> #include <stdio.h>
#include <zircon/processargs.h> #include <zircon/processargs.h>
...@@ -26,20 +27,36 @@ namespace webrunner { ...@@ -26,20 +27,36 @@ namespace webrunner {
namespace { namespace {
// Relaunches the current executable as a Context process. // Relaunches the current executable as a Context process.
base::Process LaunchContextProcess(base::CommandLine launch_command, base::Process LaunchContextProcess(const base::CommandLine& launch_command,
const base::LaunchOptions& launch_options) { const base::LaunchOptions& launch_options) {
base::CommandLine launch_command_modified = launch_command;
// TODO(crbug.com/867052): Remove this flag when GPU process works on Fuchsia. // TODO(crbug.com/867052): Remove this flag when GPU process works on Fuchsia.
launch_command.AppendSwitch(switches::kDisableGpu); launch_command_modified.AppendSwitch(switches::kDisableGpu);
return base::LaunchProcess(launch_command, launch_options); return base::LaunchProcess(launch_command_modified, launch_options);
} }
} // namespace } // namespace
ContextProviderImpl::ContextProviderImpl() ContextProviderImpl::ContextProviderImpl() : ContextProviderImpl(false) {}
: launch_(base::BindRepeating(&LaunchContextProcess)) {}
ContextProviderImpl::ContextProviderImpl(bool use_shared_tmp)
: launch_(base::BindRepeating(&LaunchContextProcess)),
use_shared_tmp_(use_shared_tmp) {}
ContextProviderImpl::~ContextProviderImpl() = default; ContextProviderImpl::~ContextProviderImpl() = default;
// static
std::unique_ptr<ContextProviderImpl> ContextProviderImpl::CreateForTest() {
// Bind the unique_ptr in a two step process.
// std::make_unique<> doesn't work well with private constructors,
// and the unique_ptr(raw_ptr*) constructor format isn't permitted as per
// PRESUBMIT.py policy.
std::unique_ptr<ContextProviderImpl> provider;
provider.reset(new ContextProviderImpl(true));
return provider;
}
void ContextProviderImpl::SetLaunchCallbackForTests( void ContextProviderImpl::SetLaunchCallbackForTests(
const LaunchContextProcessCallback& launch) { const LaunchContextProcessCallback& launch) {
launch_ = launch; launch_ = launch;
...@@ -57,9 +74,11 @@ void ContextProviderImpl::Create( ...@@ -57,9 +74,11 @@ void ContextProviderImpl::Create(
// Clone job because the context needs to be able to spawn child processes. // Clone job because the context needs to be able to spawn child processes.
launch_options.spawn_flags = FDIO_SPAWN_CLONE_JOB; launch_options.spawn_flags = FDIO_SPAWN_CLONE_JOB;
// Clone stderr to get logs in system debug log. // Clone stdout/stderr to get logs in system debug log.
launch_options.fds_to_remap.push_back( launch_options.fds_to_remap.push_back(
std::make_pair(STDERR_FILENO, STDERR_FILENO)); std::make_pair(STDERR_FILENO, STDERR_FILENO));
launch_options.fds_to_remap.push_back(
std::make_pair(STDOUT_FILENO, STDOUT_FILENO));
// Context and child processes need access to the read-only package files. // Context and child processes need access to the read-only package files.
launch_options.paths_to_clone.push_back(base::FilePath("/pkg")); launch_options.paths_to_clone.push_back(base::FilePath("/pkg"));
...@@ -67,6 +86,9 @@ void ContextProviderImpl::Create( ...@@ -67,6 +86,9 @@ void ContextProviderImpl::Create(
// Context needs access to the read-only SSL root certificates list. // Context needs access to the read-only SSL root certificates list.
launch_options.paths_to_clone.push_back(base::FilePath("/config/ssl")); launch_options.paths_to_clone.push_back(base::FilePath("/config/ssl"));
if (use_shared_tmp_)
launch_options.paths_to_clone.push_back(base::FilePath("/tmp"));
// Transfer the ContextRequest handle to a well-known location in the child // Transfer the ContextRequest handle to a well-known location in the child
// process' handle table. // process' handle table.
zx::channel context_handle(context_request.TakeChannel()); zx::channel context_handle(context_request.TakeChannel());
...@@ -91,8 +113,10 @@ void ContextProviderImpl::Create( ...@@ -91,8 +113,10 @@ void ContextProviderImpl::Create(
zx::job job; zx::job job;
zx_status_t status = zx::job::create(*base::GetDefaultJob(), 0, &job); zx_status_t status = zx::job::create(*base::GetDefaultJob(), 0, &job);
ZX_CHECK(status == ZX_OK, status) << "zx_job_create"; ZX_CHECK(status == ZX_OK, status) << "zx_job_create";
launch_options.job_handle = job.get();
ignore_result(launch_.Run(std::move(launch_command), launch_options)); ignore_result(launch_.Run(std::move(launch_command), launch_options));
ignore_result(context_handle.release()); ignore_result(context_handle.release());
ignore_result(job.release()); ignore_result(job.release());
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define WEBRUNNER_SERVICE_CONTEXT_PROVIDER_IMPL_H_ #define WEBRUNNER_SERVICE_CONTEXT_PROVIDER_IMPL_H_
#include <lib/fidl/cpp/binding_set.h> #include <lib/fidl/cpp/binding_set.h>
#include <memory>
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -26,6 +27,11 @@ class WEBRUNNER_EXPORT ContextProviderImpl ...@@ -26,6 +27,11 @@ class WEBRUNNER_EXPORT ContextProviderImpl
ContextProviderImpl(); ContextProviderImpl();
~ContextProviderImpl() override; ~ContextProviderImpl() override;
// Creates a ContextProviderImpl that shares its /tmp directory with its child
// processes. This is useful for GTest processes, which depend on a shared
// tmpdir for storing startup flags and retrieving test result files.
static std::unique_ptr<ContextProviderImpl> CreateForTest();
// Binds |this| object instance to |request|. // Binds |this| object instance to |request|.
// The service will persist and continue to serve other channels in the event // The service will persist and continue to serve other channels in the event
// that a bound channel is dropped. // that a bound channel is dropped.
...@@ -38,11 +44,13 @@ class WEBRUNNER_EXPORT ContextProviderImpl ...@@ -38,11 +44,13 @@ class WEBRUNNER_EXPORT ContextProviderImpl
private: private:
using LaunchContextProcessCallback = base::RepeatingCallback<base::Process( using LaunchContextProcessCallback = base::RepeatingCallback<base::Process(
base::CommandLine command, const base::CommandLine& command,
const base::LaunchOptions& options)>; const base::LaunchOptions& options)>;
friend class ContextProviderImplTest; friend class ContextProviderImplTest;
explicit ContextProviderImpl(bool use_shared_tmp);
// Overrides the default child process launching logic to call |launch| // Overrides the default child process launching logic to call |launch|
// instead. // instead.
void SetLaunchCallbackForTests(const LaunchContextProcessCallback& launch); void SetLaunchCallbackForTests(const LaunchContextProcessCallback& launch);
...@@ -50,6 +58,9 @@ class WEBRUNNER_EXPORT ContextProviderImpl ...@@ -50,6 +58,9 @@ class WEBRUNNER_EXPORT ContextProviderImpl
// Spawns a Context child process. // Spawns a Context child process.
LaunchContextProcessCallback launch_; LaunchContextProcessCallback launch_;
// If set, then the ContextProvider will share /tmp with its child processes.
bool use_shared_tmp_ = true;
fidl::BindingSet<chromium::web::ContextProvider> bindings_; fidl::BindingSet<chromium::web::ContextProvider> bindings_;
DISALLOW_COPY_AND_ASSIGN(ContextProviderImpl); DISALLOW_COPY_AND_ASSIGN(ContextProviderImpl);
......
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