| # Copyright 2023 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. |
| |
| # Instructions for CTF test authors. |
| # |
| # When adding a new CTF test, you must create a template below to ensure that |
| # when the test is released in CTF and rolled back into Fuchsia, the build |
| # knows how to expand the prebuilt test into a runnable Fuchsia package. |
| # |
| # The template name should follow the pattern "generate_${package_name}". |
| # If you're unsure what package name to use, run this command and see which |
| # missing template name causes the build to fail: |
| # |
| # fx set core.x64 //sdk/ctf:check_test_templates && fx build |
| # |
| # The template must take a single `test_info` scope as input which has the |
| # following attributes: |
| # |
| # name |
| # The name of the prebuilt CTF test package. |
| # Type: string |
| # |
| # target_label |
| # The absolute GN label of the prebuilt package. |
| # Type: string |
| # |
| # target_api_level |
| # The API level validated by this test. |
| # Type: int |
| # |
| # See generate_pkgdir-tests for an example. |
| |
| import("//build/config/fuchsia/platform_version.gni") |
| import("//sdk/ctf/build/internal/fuchsia_package_with_test.gni") |
| import("//sdk/ctf/build/internal/generate_ctf_packages.gni") |
| import("//src/lib/vulkan/vulkan.gni") |
| |
| template("generate_vulkan-loader-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "vulkan-loader-test-root.cm" |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| test_component = "//sdk/ctf/tests/pkg/vulkan:vulkan-loader-test-root" |
| test_specs = { |
| environments = vulkan_envs |
| log_settings = { |
| max_severity = "WARN" |
| } |
| } |
| } |
| } |
| |
| template("generate_fuchsia-intl-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "test-root.cm" |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.intl:test-root" |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| } |
| } |
| |
| template("generate_fdio-spawn-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "test-root.cm" |
| test_component = "//sdk/ctf/tests/pkg/fdio:test-root" |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| } |
| } |
| |
| template("generate_fuchsia-driver-test_tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "test-root.cm" |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| deps = [ |
| "//sdk/lib/driver_test_realm", |
| "//src/devices/misc/drivers/test-parent", |
| ] |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.driver.test:test-root" |
| } |
| } |
| |
| template("generate_fuchsia-settings-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "test-root.cm" |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.settings:test-root" |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| } |
| } |
| |
| template("generate_fuchsia-element-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "test-root.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//sdk/ctf/tests/fidl/fuchsia.element:test-realm-proxy", |
| ] |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.element:test-root" |
| } |
| } |
| |
| template("generate_fuchsia-hwinfo-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "test-root.cm" |
| subpackages = [ test_info.target_label ] |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.hwinfo:test-root" |
| } |
| } |
| |
| template("generate_pkgdir-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component_name = "test-root.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/sys/pkg/tests/pkgdir/test_realm_proxy", |
| ] |
| test_component = "//src/sys/pkg/tests/pkgdir:test-root" |
| } |
| } |
| |
| # Expands a prebuilt CTF test into a runnable fuchsia package. |
| # |
| # This template is called several times with every combination of ctf_test and |
| # api_level, where api_level is a supported API level and ctf_test is a prebuilt |
| # CTF package in the current checkout. |
| # |
| # CTF Test Authors: Do not modify this. See the comments at the top of this file. |
| template("generate_ctf_test") { |
| assert(defined(invoker.api_level), "api_level is required") |
| assert(defined(invoker.prebuilt_package), "prebuilt_package is required") |
| |
| prebuilt_package = invoker.prebuilt_package |
| api_level = invoker.api_level |
| |
| use_prebuilts_from_current_build = false |
| if (defined(invoker.use_prebuilts_from_current_build)) { |
| use_prebuilts_from_current_build = invoker.use_prebuilts_from_current_build |
| } |
| |
| prebuilt_package_label = "//sdk/ctf/release/packages:$target_name" |
| |
| if (use_prebuilts_from_current_build) { |
| prebuilt_package_name = ":${target_name}_prebuilt_from_current_build" |
| prebuilt_package_label = ":$prebuilt_package_name" |
| |
| generate_ctf_package(prebuilt_package_name) { |
| testonly = true |
| package_name = prebuilt_package.package_name |
| archive_path = "$root_build_dir/cts/${prebuilt_package.archive_name}.far" |
| deps = [ prebuilt_package.archive_gn_label ] |
| } |
| } |
| |
| target("generate_${prebuilt_package.package_name}", target_name) { |
| # If you change these properties, change the docs at the top of this file. |
| test_info = { |
| name = prebuilt_package.package_name |
| target_label = prebuilt_package_label |
| target_api_level = api_level |
| } |
| } |
| } |
| |
| # Generates test targets for prebuilt CTF tests at the given API level. |
| # |
| # Parameters |
| # |
| # api_level (required) |
| # The target API level. |
| # Type: int |
| # |
| # manifest (required) |
| # The path to package_archives.json |
| # Type: path |
| # |
| # use_prebuilts_from_current_build |
| # Generates tests using the prebuilt CTF test packages generated by the |
| # current local build instead of ones from a previous CTF release. This |
| # should only be set to true as a presubmit check when new tests are added |
| # to CTF. |
| # Type: bool |
| # Default: false |
| # |
| # CTF Test Authors: Do not modify this. See the comments at the top of this file. |
| template("generate_ctf_tests") { |
| assert(defined(invoker.api_level)) |
| assert(defined(invoker.manifest)) |
| |
| manifest = invoker.manifest |
| tests = [] |
| |
| foreach(prebuilt_package, read_file(manifest, "json")) { |
| test_name = "${prebuilt_package.package_name}_api${invoker.api_level}" |
| generate_ctf_test(test_name) { |
| forward_variables_from(invoker, |
| [ |
| "api_level", |
| "prebuilt_package", |
| "use_prebuilts_from_current_build", |
| ]) |
| } |
| tests += [ ":$test_name" ] |
| } |
| |
| group(target_name) { |
| testonly = true |
| deps = tests |
| } |
| } |