blob: 438a920d8908381b118cfe6012777f2b68e2f78d [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/fuchsia/zircon.gni")
import("//build/testing/environments.gni")
group("src") {
testonly = true
deps = [
":tests",
"camera",
"cast",
"chromium",
"cobalt",
"connectivity",
"dart",
"developer",
"devices",
"diagnostics",
"experiences",
"factory",
"flutter",
"fonts",
"graphics",
"identity",
"ledger",
"lib",
"media",
"modular",
"recovery",
"speech",
"storage",
"sys",
"testing",
"ui",
"virtualization",
]
}
group("tests") {
testonly = true
deps = [
":zircon_host_tests",
"camera:tests",
"cobalt:tests",
"connectivity:tests",
"developer:tests",
"devices:tests",
"diagnostics:tests",
"experiences:tests",
"factory:tests",
"fonts:tests",
"graphics:tests",
"identity:tests",
"ledger:tests",
"lib:tests",
"media:tests",
"modular:tests",
"recovery:tests",
"session:tests",
"speech:tests",
"storage:tests",
"sys:tests",
"testing:tests",
"tests",
"ui:tests",
"virtualization:tests",
]
}
# We link host tests from the zircon build into the fuchsia build directory
# and synthesize test metadata for them so that these tests may be run as
# fuchsia tests.
zircon_host_test_deps = []
zircon_test_specs = read_file("$zircon_root_build_dir/tests.json", "json")
foreach(entry, zircon_test_specs) {
zircon_test = { # Clear from previous iteration.
}
zircon_test = entry.test
is_disabled = defined(zircon_test.disabled) && zircon_test.disabled != ""
if (!is_disabled &&
(zircon_test.os == host_os && zircon_test.cpu == host_cpu)) {
# We need a unique target name derived from the test entry, and slashes are
# bad.
copy_target_name =
string_replace("_zircon_host_tests.${zircon_test.path}", "/", "_")
copy_deps = []
if (defined(zircon_test.runtime_deps)) {
entries = read_file("$zircon_root_build_dir/${zircon_test.runtime_deps}",
"json")
foreach(entry, entries) {
# Same as above.
copy_dep_target_name =
string_replace("_zircon_host_tests.$entry", "/", "_")
copy(copy_dep_target_name) {
sources = [
"$zircon_root_build_dir/$entry",
]
outputs = [
"$root_build_dir/$entry",
]
}
copy_deps += [ ":$copy_dep_target_name" ]
}
runtime_deps_file = "$target_gen_dir/$copy_target_name.deps.json"
write_file(runtime_deps_file, entries, "json")
}
copy(copy_target_name) {
testonly = true
sources = [
"$zircon_root_build_dir/${zircon_test.path}",
]
outputs = [
"$root_build_dir/${zircon_test.path}",
]
deps = copy_deps
metadata = {
tests = [
{
test = {
forward_variables_from(zircon_test,
"*",
[
"disabled",
"name",
"runtime_deps",
])
label = string_replace(label, "//", "//zircon/")
# TODO(fxbug.dev/36436): deprecate name in favour of label
# and deps_file in favour of runtime_deps.
name = get_label_info(label, "label_no_toolchain")
if (defined(runtime_deps_file)) {
deps_file = rebase_path(runtime_deps_file, root_build_dir)
}
}
# We only run host tests from x64 builds to avoid duplication.
if (target_cpu == "x64") {
environments = [ host_env ]
} else {
environments = []
}
},
]
}
}
zircon_host_test_deps += [ ":$copy_target_name" ]
}
}
group("zircon_host_tests") {
testonly = true
deps = zircon_host_test_deps
}
group("host_tests") {
testonly = true
public_deps = [
"//src/ledger:host_tests",
]
}