Commit e703384b authored by Yuke Liao's avatar Yuke Liao Committed by Commit Bot

[lacros] Generate a test runner wrapper for lacros

This CL generates a wrapper for each test target of format:
"bin/run_{target}", and the wrapper then invokes the lacros test
runner.

Bug: 1104318
Change-Id: I0e33e745068fe08173e077a593a3c83501bf9fb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2295925
Commit-Queue: Yuke Liao <liaoyuke@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@google.com>
Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Reviewed-by: default avatarSven Zheng <svenzheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788823}
parent 1a460bd6
svenzheng@chromium.org
liaoyuke@chromium.org
erikchen@chromium.org
#!/usr/bin/env vpython
#
# Copyright 2020 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.
"""This script facilitates running tests for lacros.
WARNING: currently, this script only supports running test targets that do not
require a display server, such as base_unittests and url_unittests.
TODO(crbug.com/1104318): Support test targets that require a display server by
using ash_chrome.
"""
import argparse
import subprocess
import sys
def _ParseArguments():
arg_parser = argparse.ArgumentParser()
arg_parser.usage = __doc__
arg_parser.add_argument(
'command',
help='Command to execute the tests. For example: "./url_unittests')
args = arg_parser.parse_known_args()
return args[0], args[1]
def Main():
args, forward_args = _ParseArguments()
return subprocess.call([args.command] + forward_args)
if __name__ == '__main__':
sys.exit(Main())
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# TEST SETUP # TEST SETUP
# ============================================================================== # ==============================================================================
import("//build/config/chromeos/ui_mode.gni")
if (is_android) { if (is_android) {
import("//build/config/android/config.gni") import("//build/config/android/config.gni")
import("//build/config/android/extract_unwind_tables.gni") import("//build/config/android/extract_unwind_tables.gni")
...@@ -29,7 +31,8 @@ if (is_ios) { ...@@ -29,7 +31,8 @@ if (is_ios) {
import("//build/config/ios/rules.gni") import("//build/config/ios/rules.gni")
} }
if ((is_linux && !is_chromeos) || is_mac || is_win) { if ((is_linux && !is_chromeos) || is_mac || is_win ||
chromeos_is_browser_only) {
import("//build/config/sanitizers/sanitizers.gni") import("//build/config/sanitizers/sanitizers.gni")
import("//build/util/generate_wrapper.gni") import("//build/util/generate_wrapper.gni")
} }
...@@ -376,6 +379,48 @@ template("test") { ...@@ -376,6 +379,48 @@ template("test") {
"//build/win:default_exe_manifest", "//build/win:default_exe_manifest",
] ]
} }
} else if (chromeos_is_browser_only) {
_runtime_deps_file = "$root_out_dir/${target_name}.runtime_deps"
_executable = target_name
_gen_runner_target = "${target_name}__runner"
generate_wrapper(_gen_runner_target) {
testonly = true
wrapper_script = "$root_build_dir/bin/run_" + _executable
executable = "//build/lacros/test_runner.py"
executable_args = [
"@WrappedPath(./${_executable})",
"--test-launcher-bot-mode",
]
if (is_asan) {
executable_args += [ "--asan=true" ]
}
if (is_msan) {
executable_args += [ "--msan=true" ]
}
if (is_tsan) {
executable_args += [ "--tsan=true" ]
}
if (use_cfi_diag) {
executable_args += [ "--cfi-diag=true" ]
}
data = [
"//testing/test_env.py",
"//.vpython",
]
}
executable(target_name) {
forward_variables_from(invoker, "*")
if (!defined(deps)) {
deps = []
}
testonly = true
write_runtime_deps = _runtime_deps_file
deps += [ ":$_gen_runner_target" ]
}
} else { } else {
if ((is_linux && !is_chromeos) || is_mac || is_win) { if ((is_linux && !is_chromeos) || is_mac || is_win) {
_runtime_deps_file = "$root_out_dir/${target_name}.runtime_deps" _runtime_deps_file = "$root_out_dir/${target_name}.runtime_deps"
......
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