Commit 1688203b authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

Refactor chromeos GN test configs. Consolidate vm_sanity_test's targets.

We're planning on adding more non-gtest tests. The cleanup here will make
that simpler/easier.

Bug: 876587
Change-Id: Ie23bd9ed1e38a3dc9df90a087cd8637557683c8a
Reviewed-on: https://chromium-review.googlesource.com/1227148Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593040}
parent c551571f
......@@ -17,31 +17,46 @@ is_chromeos_chrome = cros_board != ""
# Creates a script at $generated_script that can be used to launch a cros VM
# and optionally run a test within it.
# Args:
# test_exe: Name of test binary located in the out dir. This will get copied
# to the VM and executed there.
# generated_script: Path to place the generated script.
# deploy_chrome: If true, deploys a locally built chrome located in the root
# build dir to the VM after launching it.
# runtime_deps_file: Path to file listing runtime deps for the test. If set,
# all files listed will be copied to the VM before testing.
template("generate_vm_runner_script") {
_cache_path_prefix =
"//build/cros_cache/chrome-sdk/tarballs/${cros_board}+${cros_sdk_version}"
_vm_image_path = "${_cache_path_prefix}+chromiumos_qemu_image.tar.xz/"
_qemu_dir = "${_cache_path_prefix}+qemu/"
action(target_name) {
forward_variables_from(invoker,
[
"deploy_chrome",
"generated_script",
"runtime_deps_file",
"testonly",
"need_toolchain",
"test_exe",
])
if (!defined(deploy_chrome)) {
deploy_chrome = false
}
assert(defined(generated_script),
"Must specify where to place generated test launcher script via " +
"'generated_script'")
action(target_name) {
script = "//build/chromeos/create_vm_test_script.py"
outputs = [
invoker.generated_script,
generated_script,
]
deps = [
"//testing/buildbot/filters:chromeos_filters",
]
deps = [ "//testing/buildbot/filters:chromeos_filters" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
data = [
# We use android test-runner's results libs to construct gtest output
......@@ -49,7 +64,7 @@ template("generate_vm_runner_script") {
"//build/android/pylib/__init__.py",
"//build/android/pylib/base/",
"//build/android/pylib/results/",
invoker.generated_script,
generated_script,
"//build/chromeos/",
"//build/cros_cache/chrome-sdk/misc/",
......@@ -63,14 +78,18 @@ template("generate_vm_runner_script") {
_vm_image_path,
_qemu_dir,
]
if (defined(need_toolchain) && need_toolchain) {
data += [ "${_cache_path_prefix}+target_toolchain/" ]
if (defined(invoker.data)) {
deps += invoker.data
}
if (defined(invoker.data_deps)) {
data_deps = invoker.data_deps
}
# Required arguments used at build time by the runner script generator.
args = [
"--script-output-path",
rebase_path(invoker.generated_script, root_build_dir),
rebase_path(generated_script, root_build_dir),
"--cros-cache",
rebase_path("//build/cros_cache/", root_build_dir),
"--board",
......@@ -79,22 +98,27 @@ template("generate_vm_runner_script") {
rebase_path(root_out_dir, root_build_dir),
]
if (defined(invoker.deploy_chrome) && invoker.deploy_chrome) {
if (deploy_chrome) {
args += [ "--deploy-chrome" ]
# To deploy chrome to the VM, it needs to be stripped down to fit into
# the VM. This is done by using binutils in the toolchain. So add the
# toolchain to the data.
data += [ "${_cache_path_prefix}+target_toolchain/" ]
}
# When --test-exe is specified, run_vm_test will push the exe to the VM and
# execute it. Otherwise it wraps a host-side command and just takes care
# launching & tearing-down the VM.
if (defined(invoker.test_exe)) {
if (defined(test_exe)) {
args += [
"--test-exe",
rebase_path(invoker.test_exe, root_build_dir),
test_exe,
]
if (defined(invoker.runtime_deps_file)) {
if (defined(runtime_deps_file)) {
args += [
"--runtime-deps-path",
rebase_path(invoker.runtime_deps_file, root_build_dir),
rebase_path(runtime_deps_file, root_build_dir),
]
}
}
......
......@@ -766,14 +766,15 @@ if (is_chromeos_chrome) {
# The sanity test's actual binary is baked into the vm image. All we need to
# do is build the test wrapper and build our own browser to push to the VM
# before testing it.
generate_vm_runner_script("cros_vm_sanity_test_wrapper") {
test_exe = "$root_out_dir/cros_vm_sanity_test"
generate_vm_runner_script("cros_vm_sanity_test") {
testonly = true
test_exe = "cros_vm_sanity_test"
generated_script = "$root_build_dir/bin/run_cros_vm_sanity_test"
# The sanity test needs to strip down Chrome and its deps to fit it into
# the VM. It does so by using binutils in the toolchain. So signal that we
# need the toolchain in the data.
need_toolchain = true
data_deps = [
":cros_chrome_deploy",
"//:chromiumos_preflight", # Builds the browser.
]
}
group("cros_chrome_deploy") {
......@@ -795,16 +796,6 @@ if (is_chromeos_chrome) {
"$root_out_dir/resources/chromeos/",
]
}
group("cros_vm_sanity_test") {
testonly = true
write_runtime_deps = "$root_out_dir/cros_vm_sanity_test.runtime_deps"
data_deps = [
":cros_chrome_deploy",
"//:chromiumos_preflight", # Builds the browser.
":cros_vm_sanity_test_wrapper", # Builds the test wrapper.
]
}
}
fuzzer_test("variable_expander_fuzzer") {
......
......@@ -322,9 +322,8 @@ template("test") {
}
bundle_deps += [ ":$_resources_bundle_data" ]
}
} else if (is_chromeos && cros_board != "") {
# When the arg cros_board is set, assume we're in the cros chrome-sdk
# building simplechrome.
} else if (is_chromeos && is_chromeos_chrome) {
# Building for a cros board (ie: not linux-chromeos).
_gen_runner_target = "${target_name}__runner"
_runtime_deps_file =
......@@ -334,7 +333,7 @@ template("test") {
generate_vm_runner_script(_gen_runner_target) {
testonly = true
generated_script = "$root_build_dir/bin/run_" + invoker.target_name
test_exe = "$root_out_dir/" + get_label_info(invoker.target_name, "name")
test_exe = invoker.target_name
runtime_deps_file = _runtime_deps_file
}
......
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