blob: 678289bad907a6a7f72b1dad10ea91dfa753e6cf [file] [log] [blame]
qsrc6c612c2015-01-13 22:07:481# Copyright 2015 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
qsrfb5251d12015-01-21 15:57:224
5# ==============================================================================
6# TEST SETUP
7# ==============================================================================
8
Yuke Liaoe703384b2020-07-16 01:05:249import("//build/config/chromeos/ui_mode.gni")
10
jcivellif4462a352017-01-10 04:45:5911if (is_android) {
12 import("//build/config/android/config.gni")
James Cook209256f2018-12-07 18:40:5013 import("//build/config/android/extract_unwind_tables.gni")
jcivellif4462a352017-01-10 04:45:5914 import("//build/config/android/rules.gni")
Abhishek Arya2f5f7342018-06-13 16:59:4415 import("//build/config/sanitizers/sanitizers.gni")
jcivellif4462a352017-01-10 04:45:5916}
17
Scott Graham4c4cdc52017-05-29 20:45:0318if (is_fuchsia) {
Kevin Marshall184e9092018-02-07 21:09:0619 import("//build/config/chromecast_build.gni")
Kevin Marshall55fd8522019-10-04 22:47:0120 import("//build/config/fuchsia/generate_runner_scripts.gni")
Kevin Marshallf35fa5f2018-01-29 19:24:4221 import("//build/config/fuchsia/package.gni")
Scott Graham4c4cdc52017-05-29 20:45:0322}
23
Ben Pastene4c35c572018-04-30 23:21:4824if (is_chromeos) {
25 import("//build/config/chromeos/rules.gni")
26}
27
Jeff Yoonf7f4eb42020-03-06 18:55:3628if (is_ios) {
29 import("//build/config/ios/ios_sdk.gni")
30 import("//build/config/ios/ios_test_runner_wrapper.gni")
31 import("//build/config/ios/rules.gni")
32}
33
Yuke Liaoe703384b2020-07-16 01:05:2434if ((is_linux && !is_chromeos) || is_mac || is_win ||
35 chromeos_is_browser_only) {
Dirk Pranke31e346e2020-07-15 00:54:0636 import("//build/config/sanitizers/sanitizers.gni")
37 import("//build/util/generate_wrapper.gni")
38}
39
qsrfb5251d12015-01-21 15:57:2240# Define a test as an executable (or apk on Android) with the "testonly" flag
41# set.
agrieve62ab00282016-04-05 02:03:4542# Variable:
43# use_raw_android_executable: Use executable() rather than android_apk().
ynovikov389d9e442016-05-27 02:34:5644# use_native_activity: Test implements ANativeActivity_onCreate().
Will Harrisc218db232020-07-21 20:20:5745# win_test_enable_cfi_linker: (Win) Enable CFI linker for this test binary.
Yuke Liao240816d2020-07-22 00:10:3946# use_ash_chrome: Use ash-chrome to run tests, only applicable to lacros.
qsrfb5251d12015-01-21 15:57:2247template("test") {
48 if (is_android) {
agrieve62ab00282016-04-05 02:03:4549 _use_raw_android_executable = defined(invoker.use_raw_android_executable) &&
50 invoker.use_raw_android_executable
qsrfb5251d12015-01-21 15:57:2251
agrieve67855de2016-03-30 14:46:0152 # output_name is used to allow targets with the same name but in different
53 # packages to still produce unique runner scripts.
54 _output_name = invoker.target_name
mikecase56d80d72015-06-03 00:57:2655 if (defined(invoker.output_name)) {
agrieve67855de2016-03-30 14:46:0156 _output_name = invoker.output_name
mikecase56d80d72015-06-03 00:57:2657 }
agrieve62ab00282016-04-05 02:03:4558
agrieveb355ad152016-04-19 03:45:2359 _test_runner_target = "${_output_name}__test_runner_script"
jbudorickd29ecfa72016-11-18 22:45:4260 _wrapper_script_vars = [
agrievee41ae190d2016-04-25 14:12:5161 "ignore_all_data_deps",
jbudorickd29ecfa72016-11-18 22:45:4262 "shard_timeout",
agrievee41ae190d2016-04-25 14:12:5163 ]
agrieve3ac557f02016-04-12 15:52:0064
jbudorickced2a252016-06-09 16:38:5465 assert(_use_raw_android_executable || enable_java_templates)
66
agrieve62ab00282016-04-05 02:03:4567 if (_use_raw_android_executable) {
68 _exec_target = "${target_name}__exec"
69 _dist_target = "${target_name}__dist"
70 _exec_output =
71 "$target_out_dir/${invoker.target_name}/${invoker.target_name}"
72
73 executable(_exec_target) {
74 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
75 configs = []
76 data_deps = []
jbudorickd29ecfa72016-11-18 22:45:4277 forward_variables_from(invoker,
78 "*",
79 _wrapper_script_vars + [ "extra_dist_files" ])
agrieve62ab00282016-04-05 02:03:4580 testonly = true
81
82 # Thanks to the set_defaults() for test(), configs are initialized with
83 # the default shared_library configs rather than executable configs.
Thomas Anderson11c1d9822019-01-15 06:32:5984 configs -= [
85 "//build/config:shared_library_config",
86 "//build/config/android:hide_all_but_jni",
87 ]
agrieve62ab00282016-04-05 02:03:4588 configs += [ "//build/config:executable_config" ]
89
90 # Don't output to the root or else conflict with the group() below.
91 output_name = rebase_path(_exec_output, root_out_dir)
agrieve62ab00282016-04-05 02:03:4592 }
93
94 create_native_executable_dist(_dist_target) {
95 testonly = true
96 dist_dir = "$root_out_dir/$target_name"
97 binary = _exec_output
Nico Weber852532f2020-01-28 18:17:2298 deps = [ ":$_exec_target" ]
agrieve62ab00282016-04-05 02:03:4599 if (defined(invoker.extra_dist_files)) {
100 extra_files = invoker.extra_dist_files
101 }
102 }
103 } else {
Andrew Grievec61b8dff2019-10-21 16:32:02104 _library_target = "${target_name}__library"
105 _apk_target = "${target_name}__apk"
agrieve62ab00282016-04-05 02:03:45106 _apk_specific_vars = [
107 "android_manifest",
agrievec6811b422016-06-23 02:25:09108 "android_manifest_dep",
Clark DuVall1bee5322020-06-10 05:51:55109 "app_as_shared_lib",
agrieve62ab00282016-04-05 02:03:45110 "enable_multidex",
Benoît Lizéd8b8f742019-11-07 12:50:07111 "product_config_java_packages",
Tibor Goldschwendt95db95d2019-06-17 20:32:02112 "min_sdk_version",
huapenglc35ba6e2016-05-25 23:08:07113 "proguard_configs",
114 "proguard_enabled",
Fred Mello0cc91c62019-08-24 01:53:45115 "srcjar_deps",
Tibor Goldschwendt95db95d2019-06-17 20:32:02116 "target_sdk_version",
agrieve62ab00282016-04-05 02:03:45117 "use_default_launcher",
ynovikov389d9e442016-05-27 02:34:56118 "use_native_activity",
agrieve62ab00282016-04-05 02:03:45119 ]
Siddhartha764226b2018-03-13 02:32:55120
121 # Adds the unwind tables from unstripped binary as an asset file in the
122 # apk, if |add_unwind_tables_in_apk| is specified by the test.
123 if (defined(invoker.add_unwind_tables_in_apk) &&
124 invoker.add_unwind_tables_in_apk) {
125 _unwind_table_asset_name = "${target_name}_unwind_assets"
126 unwind_table_asset(_unwind_table_asset_name) {
127 testonly = true
128 library_target = _library_target
Nico Weber852532f2020-01-28 18:17:22129 deps = [ ":$_library_target" ]
Siddhartha764226b2018-03-13 02:32:55130 }
131 }
132
agrieve62ab00282016-04-05 02:03:45133 shared_library(_library_target) {
134 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
135 configs = [] # Prevent list overwriting warning.
136 configs = invoker.configs
137 testonly = true
138
139 deps = []
jbudorickd29ecfa72016-11-18 22:45:42140 forward_variables_from(
141 invoker,
142 "*",
143 _apk_specific_vars + _wrapper_script_vars + [ "visibility" ])
agrieve62ab00282016-04-05 02:03:45144
145 if (!defined(invoker.use_default_launcher) ||
146 invoker.use_default_launcher) {
Tom Andersonce772fa2018-05-30 22:20:37147 deps += [ "//testing/android/native_test:native_test_native_code" ]
agrieve62ab00282016-04-05 02:03:45148 }
149 }
150 unittest_apk(_apk_target) {
Daniel Bratellfdda4652019-01-31 15:45:54151 forward_variables_from(invoker, _apk_specific_vars)
agrieve48bd27e2016-06-22 21:04:07152 shared_library = ":$_library_target"
agrieve62ab00282016-04-05 02:03:45153 apk_name = invoker.target_name
154 if (defined(invoker.output_name)) {
155 apk_name = invoker.output_name
agrieve62ab00282016-04-05 02:03:45156 install_script_name = "install_${invoker.output_name}"
157 }
agrieveb355ad152016-04-19 03:45:23158
Daniel Bratellfdda4652019-01-31 15:45:54159 if (defined(invoker.deps)) {
160 deps = invoker.deps
161 } else {
162 deps = []
163 }
164
jcivellif4462a352017-01-10 04:45:59165 # Add the Java classes so that each target does not have to do it.
166 deps += [ "//base/test:test_support_java" ]
167
Siddhartha764226b2018-03-13 02:32:55168 if (defined(_unwind_table_asset_name)) {
169 deps += [ ":${_unwind_table_asset_name}" ]
170 }
agrieve62ab00282016-04-05 02:03:45171 }
Andrew Grievee1dc23f2019-10-22 16:26:36172 }
agrieve62ab00282016-04-05 02:03:45173
Andrew Grievee1dc23f2019-10-22 16:26:36174 test_runner_script(_test_runner_target) {
175 forward_variables_from(invoker, _wrapper_script_vars)
estevensonce8443922016-12-15 19:57:57176
Andrew Grievee1dc23f2019-10-22 16:26:36177 if (_use_raw_android_executable) {
178 executable_dist_dir = "$root_out_dir/$_dist_target"
John Budorickd5dccb22020-02-01 02:16:34179 data_deps = [ ":$_exec_target" ]
Andrew Grievee1dc23f2019-10-22 16:26:36180 } else {
181 apk_target = ":$_apk_target"
182 incremental_apk = incremental_install
Andrew Grieve7ca6de32019-10-18 03:57:47183
184 # Dep needed for the test runner .runtime_deps file to pick up data
185 # deps from the forward_variables_from(invoker, "*") on the library.
Nico Weber852532f2020-01-28 18:17:22186 data_deps = [ ":$_library_target" ]
agrieve62ab00282016-04-05 02:03:45187 }
Andrew Grievee1dc23f2019-10-22 16:26:36188 test_name = _output_name
189 test_suite = _output_name
190 test_type = "gtest"
mikecase56d80d72015-06-03 00:57:26191 }
192
Andrew Grieve7ca6de32019-10-18 03:57:47193 # Create a wrapper script rather than using a group() in order to ensure
194 # "ninja $target_name" always works. If this was a group(), then GN would
195 # not create a top-level alias for it if a target exists in another
196 # directory with the same $target_name.
197 # Also - bots run this script directly for "components_perftests".
198 generate_wrapper(target_name) {
199 testonly = true
200 executable = "$root_build_dir/bin/run_$_output_name"
201 wrapper_script = "$root_build_dir/$_output_name"
Nico Weber852532f2020-01-28 18:17:22202 deps = [ ":$_test_runner_target" ]
jbudorick686094f62017-05-04 21:52:40203 if (_use_raw_android_executable) {
Andrew Grieve7ca6de32019-10-18 03:57:47204 deps += [ ":$_dist_target" ]
jbudorick686094f62017-05-04 21:52:40205 } else {
Andrew Grieve7ca6de32019-10-18 03:57:47206 # Dep needed for the swarming .isolate file to pick up data
207 # deps from the forward_variables_from(invoker, "*") on the library.
208 deps += [
209 ":$_apk_target",
210 ":$_library_target",
211 ]
agrieve62ab00282016-04-05 02:03:45212 }
agrieve1a02e582015-10-15 21:35:39213 }
Scott Graham4c4cdc52017-05-29 20:45:03214 } else if (is_fuchsia) {
215 _output_name = invoker.target_name
Kevin Marshallf35fa5f2018-01-29 19:24:42216 _pkg_target = "${_output_name}_pkg"
Kevin Marshallf35fa5f2018-01-29 19:24:42217 _exec_target = "${_output_name}__exec"
Scott Graham4c4cdc52017-05-29 20:45:03218
Kevin Marshall39b4aa82018-06-23 00:12:15219 fuchsia_package_runner(target_name) {
Kevin Marshallf35fa5f2018-01-29 19:24:42220 testonly = true
Fabrice de Gans-Riberi041a6522018-12-11 00:20:53221 forward_variables_from(invoker,
222 [
223 "use_test_server",
224 "package_deps",
225 ])
Kevin Marshall39b4aa82018-06-23 00:12:15226 runner_script = "//build/fuchsia/test_runner.py"
227 package = ":$_pkg_target"
228 package_name_override = _output_name
Dimitri Glazkovc95e6dd2018-08-24 23:39:42229
Wezdd593a52020-04-08 17:09:46230 data_deps = [ "//testing/buildbot/filters:fuchsia_filters" ]
Kevin Marshallf35fa5f2018-01-29 19:24:42231 }
232
Wezabe2d752020-02-11 17:12:23233 cr_fuchsia_package(_pkg_target) {
Fabrice de Gans-Riberia16cac82019-06-03 19:03:20234 testonly = true
Fabrice de Gans-Ribericc810d32019-07-08 22:44:16235 forward_variables_from(invoker, [ "manifest" ])
Fabrice de Gans-Riberia16cac82019-06-03 19:03:20236 binary = ":$_exec_target"
237 package_name_override = _output_name
238 }
239
Kevin Marshallf35fa5f2018-01-29 19:24:42240 executable(_exec_target) {
Scott Graham4c4cdc52017-05-29 20:45:03241 forward_variables_from(invoker, "*")
Kevin Marshall39b4aa82018-06-23 00:12:15242 testonly = true
Kevin Marshallf35fa5f2018-01-29 19:24:42243 output_name = _exec_target
Scott Graham4c4cdc52017-05-29 20:45:03244 }
dpranke2a294622015-08-07 05:23:01245 } else if (is_ios) {
Rohit Raof9b096d2019-09-09 22:26:23246 declare_args() {
247 # Keep the unittest-as-xctest functionality defaulted to off until the
248 # bots are updated to handle it properly.
249 # TODO(crbug.com/1001667): Remove this arg once the iOS test runner
250 # supports running unittests with xctest.
251 enable_run_ios_unittests_with_xctest = false
252 }
253
sdefresne012857872016-03-16 10:55:37254 _test_target = target_name
Jeff Yoonf7f4eb42020-03-06 18:55:36255 _wrapper_output_name = "run_${target_name}"
256 ios_test_runner_wrapper(_wrapper_output_name) {
257 forward_variables_from(invoker,
258 [
259 "data",
260 "data_deps",
261 "deps",
262 "executable_args",
263 "retries",
264 "shards",
265 ])
266
267 _root_build_dir = rebase_path("${root_build_dir}", root_build_dir)
268
269 if (!defined(executable_args)) {
270 executable_args = []
271 }
272 executable_args += [
273 "--app",
274 "@WrappedPath(${_root_build_dir}/${_test_target}.app)",
275 ]
276
277 wrapper_output_name = "${_wrapper_output_name}"
278 }
279
sdefresne012857872016-03-16 10:55:37280 _resources_bundle_data = target_name + "_resources_bundle_data"
281
282 bundle_data(_resources_bundle_data) {
sdefresne047490e2016-07-22 08:49:34283 visibility = [ ":$_test_target" ]
Nico Weber852532f2020-01-28 18:17:22284 sources = [ "//testing/gtest_ios/Default.png" ]
285 outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
dpranke2a294622015-08-07 05:23:01286 }
287
Rohit Raof9b096d2019-09-09 22:26:23288 if (enable_run_ios_unittests_with_xctest) {
289 ios_test_target_type = "ios_xctest_test"
290 } else {
291 ios_test_target_type = "ios_app_bundle"
292 }
293
294 target(ios_test_target_type, _test_target) {
dpranke2a294622015-08-07 05:23:01295 testonly = true
sdefresnea828c282016-05-30 18:04:20296
Rohit Raof9b096d2019-09-09 22:26:23297 if (enable_run_ios_unittests_with_xctest) {
298 xctest_module_target = "//base/test:google_test_runner"
299 }
300
sdefresne9e147e02016-06-07 00:10:13301 # See above call.
302 set_sources_assignment_filter([])
303 forward_variables_from(invoker, "*", [ "testonly" ])
304
305 # Provide sensible defaults in case invoker did not define any of those
306 # required variables.
sdefresne05b97ca2016-06-08 07:19:46307 if (!defined(info_plist) && !defined(info_plist_target)) {
sdefresne9e147e02016-06-07 00:10:13308 info_plist = "//testing/gtest_ios/unittest-Info.plist"
309 }
sdefresne9e147e02016-06-07 00:10:13310
Olivier Robin9689c562020-04-17 14:03:57311 _gtest_bundle_id_suffix = "${target_name}"
312 xcode_product_bundle_id = "gtest.$_gtest_bundle_id_suffix"
Justin Cohena819c112019-08-17 02:19:19313
sdefresne9e147e02016-06-07 00:10:13314 if (!defined(extra_substitutions)) {
315 extra_substitutions = []
316 }
Olivier Robin9689c562020-04-17 14:03:57317 extra_substitutions +=
318 [ "GTEST_BUNDLE_ID_SUFFIX=$_gtest_bundle_id_suffix" ]
dpranke2a294622015-08-07 05:23:01319
sdefresne047490e2016-07-22 08:49:34320 if (!defined(bundle_deps)) {
321 bundle_deps = []
322 }
323 bundle_deps += [ ":$_resources_bundle_data" ]
Jeff Yoonf7f4eb42020-03-06 18:55:36324
325 if (!defined(data_deps)) {
326 data_deps = []
327 }
328
329 # Include the generate_wrapper as part of data_deps
330 data_deps += [ ":${_wrapper_output_name}" ]
dpranke2a294622015-08-07 05:23:01331 }
George Burgess IVe62d7c52020-02-22 01:22:42332 } else if (is_chromeos && cros_board != "") {
Ben Pastene16882032018-09-21 01:16:39333 # Building for a cros board (ie: not linux-chromeos).
Benjamin Pastene3bce864e2018-04-14 01:16:32334
Benjamin Pastene3bce864e2018-04-14 01:16:32335 _gen_runner_target = "${target_name}__runner"
336 _runtime_deps_file =
337 "$root_out_dir/gen.runtime/" + get_label_info(target_name, "dir") +
338 "/" + get_label_info(target_name, "name") + ".runtime_deps"
339
Ben Pastene4ab98652018-12-17 18:33:18340 generate_runner_script(_gen_runner_target) {
Benjamin Pastene3bce864e2018-04-14 01:16:32341 testonly = true
342 generated_script = "$root_build_dir/bin/run_" + invoker.target_name
Ben Pastene16882032018-09-21 01:16:39343 test_exe = invoker.target_name
Benjamin Pastene3bce864e2018-04-14 01:16:32344 runtime_deps_file = _runtime_deps_file
345 }
346
347 executable(target_name) {
348 forward_variables_from(invoker, "*")
349 if (!defined(deps)) {
350 deps = []
351 }
352 if (!defined(data)) {
353 data = []
354 }
355
Ben Pastene41041782019-02-16 04:21:58356 # We use a special trigger script for CrOS hardware tests.
357 data += [ "//testing/trigger_scripts/chromeos_device_trigger.py" ]
358
Benjamin Pastene3bce864e2018-04-14 01:16:32359 testonly = true
360 output_name = target_name
361 write_runtime_deps = _runtime_deps_file
362 data += [ _runtime_deps_file ]
Tom Andersonce772fa2018-05-30 22:20:37363 deps += [ ":$_gen_runner_target" ]
Benjamin Pastene3bce864e2018-04-14 01:16:32364 }
Dirk Pranke31e346e2020-07-15 00:54:06365 } else if (is_chromeos && cros_board == "") {
Dirk Pranke956c4dc2020-07-02 00:54:27366 executable(target_name) {
367 forward_variables_from(invoker, "*")
368 if (!defined(deps)) {
369 deps = []
370 }
371
Dirk Pranke956c4dc2020-07-02 00:54:27372 testonly = true
Dirk Pranke956c4dc2020-07-02 00:54:27373 }
Yuke Liaoe703384b2020-07-16 01:05:24374 } else if (chromeos_is_browser_only) {
375 _runtime_deps_file = "$root_out_dir/${target_name}.runtime_deps"
376 _executable = target_name
377 _gen_runner_target = "${target_name}__runner"
378
Yuke Liao32af4242020-07-16 21:48:02379 if (defined(invoker.use_xvfb)) {
380 _use_xvfb = invoker.use_xvfb
381 } else {
382 _use_xvfb = false
383 }
384
Yuke Liaoe703384b2020-07-16 01:05:24385 generate_wrapper(_gen_runner_target) {
386 testonly = true
387 wrapper_script = "$root_build_dir/bin/run_" + _executable
Yuke Liao32af4242020-07-16 21:48:02388
389 if (_use_xvfb) {
390 executable = "//testing/xvfb.py"
391 } else {
392 executable = "//testing/test_env.py"
393 }
394
Yuke Liaoe703384b2020-07-16 01:05:24395 executable_args = [
Yuke Liao32af4242020-07-16 21:48:02396 "@WrappedPath(../../build/lacros/test_runner.py)",
Yuke Liao240816d2020-07-22 00:10:39397 "test",
Yuke Liaoe703384b2020-07-16 01:05:24398 "@WrappedPath(./${_executable})",
399 "--test-launcher-bot-mode",
400 ]
Yuke Liao32af4242020-07-16 21:48:02401
Yuke Liao240816d2020-07-22 00:10:39402 if (defined(invoker.use_ash_chrome) && invoker.use_ash_chrome) {
403 executable_args += [ "--ash-chrome-version=for_bots" ]
404 }
405
Yuke Liaoe703384b2020-07-16 01:05:24406 if (is_asan) {
407 executable_args += [ "--asan=true" ]
408 }
409 if (is_msan) {
410 executable_args += [ "--msan=true" ]
411 }
412 if (is_tsan) {
413 executable_args += [ "--tsan=true" ]
414 }
415 if (use_cfi_diag) {
416 executable_args += [ "--cfi-diag=true" ]
417 }
418
419 data = [
Yuke Liao240816d2020-07-22 00:10:39420 "//build/lacros/test_runner.py",
Yuke Liaoe703384b2020-07-16 01:05:24421 "//testing/test_env.py",
422 "//.vpython",
423 ]
Yuke Liao240816d2020-07-22 00:10:39424 if (defined(invoker.use_ash_chrome) && invoker.use_ash_chrome) {
425 data += [ "//build/lacros/prebuilt_ash_chrome/for_bots" ]
426 }
Yuke Liaoe703384b2020-07-16 01:05:24427 }
428
429 executable(target_name) {
430 forward_variables_from(invoker, "*")
431 if (!defined(deps)) {
432 deps = []
433 }
434
435 testonly = true
436 write_runtime_deps = _runtime_deps_file
437 deps += [ ":$_gen_runner_target" ]
438 }
Dirk Pranke31e346e2020-07-15 00:54:06439 } else {
440 if ((is_linux && !is_chromeos) || is_mac || is_win) {
441 _runtime_deps_file = "$root_out_dir/${target_name}.runtime_deps"
442 _executable = target_name
443 _gen_runner_target = "${target_name}__runner"
444
445 if (is_linux && defined(invoker.use_xvfb)) {
446 _use_xvfb = invoker.use_xvfb
447 } else {
448 _use_xvfb = false
449 }
450
Will Harrisc218db232020-07-21 20:20:57451 if (is_win) {
452 if (defined(invoker.win_test_enable_cfi_linker)) {
453 _win_test_enable_cfi_linker = invoker.win_test_enable_cfi_linker
454 } else {
455 _win_test_enable_cfi_linker = false
456 }
457 }
458
Dirk Pranke31e346e2020-07-15 00:54:06459 generate_wrapper(_gen_runner_target) {
460 testonly = true
461 wrapper_script = "$root_build_dir/bin/run_" + _executable
462
463 if (_use_xvfb) {
464 executable = "//testing/xvfb.py"
465 } else {
466 executable = "//testing/test_env.py"
467 }
468
469 executable_args = [
470 "@WrappedPath(./${_executable})",
471 "--test-launcher-bot-mode",
472 ]
473 if (is_asan) {
474 executable_args += [ "--asan=true" ]
475 }
476 if (is_msan) {
477 executable_args += [ "--msan=true" ]
478 }
479 if (is_tsan) {
480 executable_args += [ "--tsan=true" ]
481 }
482 if (use_cfi_diag) {
483 executable_args += [ "--cfi-diag=true" ]
484 }
485
486 data = [
487 "//testing/test_env.py",
488 "//.vpython",
489 ]
490 }
491 }
492
493 executable(target_name) {
494 forward_variables_from(invoker, "*")
495 if (!defined(deps)) {
496 deps = []
497 }
498
499 if (is_win) {
Will Harrisc218db232020-07-21 20:20:57500 if (!_win_test_enable_cfi_linker) {
501 # Initializing CFG data during process creation is a significant
502 # bottleneck for large test binaries, and CFG is not needed for
503 # most tests, so disable it. See https://crbug.com/950923 for
504 # details. This can be overridden by specifying
505 # win_test_enable_cfi_linker.
506 configs -= [ "//build/config/win:cfi_linker" ]
507 }
Dirk Pranke31e346e2020-07-15 00:54:06508 }
509 testonly = true
510 deps += [
511 # Give tests the default manifest on Windows (a no-op elsewhere).
512 "//build/win:default_exe_manifest",
513 ]
514
515 if (is_linux || is_mac || is_win) {
516 write_runtime_deps = _runtime_deps_file
517 deps += [ ":$_gen_runner_target" ]
518 }
519 }
qsrfb5251d12015-01-21 15:57:22520 }
521}
brettwedb6ecc2016-07-14 23:37:03522
523# Test defaults.
524set_defaults("test") {
525 if (is_android) {
526 configs = default_shared_library_configs
Yipeng Wang158dbc5c2017-06-30 18:16:41527 configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
Thomas Anderson11c1d9822019-01-15 06:32:59528 configs += [ "//build/config/android:hide_all_but_jni" ]
brettwedb6ecc2016-07-14 23:37:03529 } else {
530 configs = default_executable_configs
531 }
532}