Skip to content

Commit df47ba7

Browse files
ihuh0CQ Bot
authored andcommitted
[fuchsia_test_package] Add package_deps to fuchsia_test_package targets.
These tests depend on other fuchsia packages that are not included as subpackages but are needed at runtime and thus need to be forwarded through the package_deps to the test_spec. Also add debug_agent by default because most target tests use it for getting backtraces. Bug: 407117303 Fixed: 406571868 Change-Id: I0b230f9f54a1483425d8ada58af8b7164afcc9c1 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1254636 Reviewed-by: Aaron Wood <[email protected]> Reviewed-by: Dale Sather <[email protected]> Fuchsia-Auto-Submit: Ina Huh <[email protected]> Commit-Queue: Auto-Submit <auto-submit-builder@fuchsia-internal-service-accts.iam.gserviceaccount.com> Reviewed-by: Christopher Johnson <[email protected]>
1 parent 886c35b commit df47ba7

File tree

11 files changed

+49
-4
lines changed

11 files changed

+49
-4
lines changed

build/components/fuchsia_package.gni

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ template("fuchsia_package") {
391391
])
392392
public_deps = [ ":$_package_build_target" ]
393393
deps = main_target_deps
394+
if (defined(invoker.package_deps)) {
395+
deps += invoker.package_deps
396+
}
394397
if (_is_driver_package) {
395398
metadata = {
396399
# Allow exclusion of driver packages by assembly

build/components/fuchsia_test_package.gni

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ _log_severity_allowed_val = [
9797
# details.
9898
# Type: list of targets
9999
#
100+
# package_deps (optional)
101+
# A list of `fuchsia_package` targets that are not subpackages but needed
102+
# by the test at runtime. This will get forwarded to the test_spec. See
103+
# //build/testing/test_spec.gni for more details. If using this instead of
104+
# `subpackages`, please add a comment explaining why.
105+
# Type: list of targets
106+
#
100107
# is_bootfs (optional)
101108
# ONLY to be used by |fuchsia_bootfs_test_package| to indicate a bootfs based package.
102109
#
@@ -321,6 +328,7 @@ template("fuchsia_test_package") {
321328
"deps",
322329
"disable_elf_binaries_checks",
323330
"metadata",
331+
"package_deps",
324332
"visibility",
325333
])
326334
package_name = package_name

build/testing/test_spec.gni

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# found in the LICENSE file.
44

55
import("//build/board.gni")
6+
import("//build/config/fuchsia/target_api_level.gni")
67
import("//build/group_with_inputs.gni")
78
import("//build/testing/environments.gni")
89
import("//build/testing/platforms.gni")
@@ -410,6 +411,7 @@ template("test_spec") {
410411
}
411412

412413
target_name_deps = []
414+
target_name_data_deps = []
413415

414416
# Rely on metadata reachable through deps to determine any runtime
415417
# dependencies of the test; record them to a file.
@@ -440,15 +442,28 @@ template("test_spec") {
440442
# Some tests depend on other packages so get the paths to the
441443
# package_manifests of those package dependencies to attach to
442444
# the test_spec of the test so we know what blobs it depends on.
445+
# Most target tests use debug_agent to get backtraces so include
446+
# it by default. A target test can be defined by a test that has a
447+
# package_manifests field.
443448
pkg_manifest_deps_file = ""
444-
if (defined(invoker.package_deps) && invoker.package_deps != []) {
449+
package_deps = []
450+
if (defined(invoker.package_deps)) {
451+
package_deps = invoker.package_deps
452+
}
453+
if (package_deps != [] || defined(invoker.package_label)) {
454+
if (target_cpu != "riscv64" &&
455+
current_build_target_api_level == "PLATFORM") {
456+
# TODO(https://fxbug.dev/42074048): Remove conditional once
457+
# debug_agent works for riscv64.
458+
package_deps += [ "//src/developer/debug/debug_agent" ]
459+
}
445460
pkg_manifest_deps_file = "$target_gen_dir/${target_name}.pkg_manifests.json"
446461
pkg_manifest_deps_target_name = "${target_name}_pkg_manifest_deps"
447462

448463
_manifest_entries = []
449464
_manifest_inputs = []
450465
_package_deps_with_toolchain = []
451-
foreach(package_dep, invoker.package_deps) {
466+
foreach(package_dep, package_deps) {
452467
_package_deps_with_toolchain +=
453468
[ get_label_info(package_dep, "label_no_toolchain") +
454469
"(${target_toolchain})" ]
@@ -474,7 +489,7 @@ template("test_spec") {
474489
deps = _package_deps_with_toolchain
475490
inputs = _manifest_inputs
476491
}
477-
target_name_deps += [
492+
target_name_data_deps += [
478493
":${pkg_manifest_deps_inputs_name}",
479494
":${pkg_manifest_deps_target_name}",
480495
]
@@ -616,6 +631,7 @@ template("test_spec") {
616631
tests = [ test_spec ]
617632
}
618633
deps = target_name_deps
634+
data_deps = target_name_data_deps
619635
if (defined(invoker.isolated) && invoker.isolated &&
620636
# Tests that use product bundles, primarily boot tests, must necessarily
621637
# run in isolated mode, so they need not be explicitly included in the

src/graphics/tests/vkvalidation/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ fuchsia_test_component("vkvalidation_external_cmp") {
6060

6161
fuchsia_test_package("vkvalidation-external-pkg") {
6262
package_name = "vkvalidation-external"
63+
package_deps =
64+
[ "//src/lib/vulkan/vulkan-validation-pkg:validation-server-pkg" ]
6365
test_components = [ ":vkvalidation_external_cmp" ]
6466
test_specs = {
6567
environments = magma_libvulkan_hardware_envs

src/lib/testing/sharding/tests/integration/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ fuchsia_test_package("sharding-integration-tests") {
4646
# from universe via the subpackaged test manager.
4747
# TODO(http://b/301507292): Stop requiring use of the system resolver in
4848
# test manager tests.
49-
deps = [ "//src/lib/testing/sharding/tests/example_sharded_test:example-sharded-test" ]
49+
package_deps = [ "//src/lib/testing/sharding/tests/example_sharded_test:example-sharded-test" ]
5050
}

src/sys/test_manager/tests/nonhermetic_packaged_tests/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fuchsia_test_component("echo_test_specific_package") {
2626

2727
fuchsia_test_package("nonhermetic_packaged_test") {
2828
test_components = [ ":echo_test_specific_package" ]
29+
package_deps = [ ":echo_server_for_test" ]
2930
}
3031

3132
fuchsia_package("echo_server_for_test") {

src/sys/test_runners/elf/tests/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ fuchsia_test_component("elf_test_runner_integration_test") {
3131
fuchsia_test_package("elf-test-runner-integration-test") {
3232
test_components = [ ":elf_test_runner_integration_test" ]
3333
subpackages = [ "//src/sys/test_manager:pkg" ]
34+
35+
# TODO(https://fxbug.dev/412436921): Use subpackages instead of package_deps.
36+
package_deps = [ "../test_data:elf-test-runner-example-tests" ]
3437
}
3538

3639
group("tests") {

src/sys/test_runners/gotests/tests/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ fuchsia_test_component("go_runner_integration_test") {
3232
fuchsia_test_package("go-runner-integration-test") {
3333
test_components = [ ":go_runner_integration_test" ]
3434
subpackages = [ "//src/sys/test_manager:pkg" ]
35+
36+
# TODO(https://fxbug.dev/412436921): Use subpackages instead of package_deps.
37+
package_deps = [ "../test_data:go-test-runner-example" ]
3538
}
3639

3740
group("tests") {

src/sys/test_runners/gtest/tests/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ fuchsia_test_package("gtest-runner-integration-test") {
6666
]
6767
subpackages = [ "//src/sys/test_manager:pkg" ]
6868

69+
# TODO(https://fxbug.dev/412436921): Use subpackages instead of package_deps.
70+
package_deps = [ "../test_data:gtest-runner-example-tests" ]
71+
6972
# https://fxbug.dev/42154358: This stress test fails on coverage bot.
7073
if (is_coverage) {
7174
test_components -= [ ":gtest_runner_stress_test" ]

src/sys/test_runners/gunit/tests/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ fuchsia_test_component("gunit_runner_integration_test") {
3737
fuchsia_test_package("gunit-runner-integration-test") {
3838
test_components = [ ":gunit_runner_integration_test" ]
3939
subpackages = [ "//src/sys/test_manager:pkg" ]
40+
41+
# TODO(https://fxbug.dev/412436921): Use subpackages instead of package_deps.
42+
package_deps = [ ":gunit-runner-example-tests" ]
4043
}
4144

4245
fuchsia_component("empty_test_component") {

0 commit comments

Comments
 (0)