| # 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 --with //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("//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_fuchsia-diagnostics-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| if (defined(invoker.api_level) && invoker.api_level == "15") { |
| # TODO(https://fxbug.dev/335307425): Remove this when F15 is no longer supported. |
| not_needed([ "test_info" ]) |
| group(target_name) { |
| } |
| } else { |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.diagnostics:fuchsia-diagnostics-tests-root" |
| test_component_name = "fuchsia-diagnostics-tests-root.cm" |
| } |
| } |
| } |
| |
| template("generate_fuchsia-diagnostics-log-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.diagnostics:fuchsia-diagnostics-log-tests-root" |
| test_component_name = "fuchsia-diagnostics-log-tests-root.cm" |
| } |
| } |
| |
| template("generate_fidl-hlcpp-unit-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| test_component = "//sdk/ctf/tests/pkg/fidl/cpp:fidl-hlcpp-unit-tests-root" |
| test_component_name = "fidl-hlcpp-unit-tests-root.cm" |
| } |
| } |
| |
| template("generate_fidl-hlcpp-conformance-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| test_component = |
| "//sdk/ctf/tests/pkg/fidl/cpp:fidl-hlcpp-conformance-tests-root" |
| test_component_name = "fidl-hlcpp-conformance-tests-root.cm" |
| } |
| } |
| |
| template("generate_svc-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ |
| test_info.target_label, |
| # These tests do not currently use a test realm factory. |
| ] |
| test_component = "//sdk/ctf/tests/pkg/svc:svc-tests-root" |
| test_component_name = "svc-tests-root.cm" |
| } |
| } |
| |
| template("generate_vulkan-loader-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| 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_component_name = "vulkan-loader-test-root.cm" |
| 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 = "//sdk/ctf/tests/fidl/fuchsia.intl:test-root" |
| test_component_name = "test-root.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//sdk/ctf/tests/fidl/fuchsia.intl/testing/realm-factory", |
| ] |
| } |
| } |
| |
| template("generate_timekeeper-integration") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//src/sys/time/timekeeper_integration:timekeeper-integration-test-root-component" |
| test_component_name = "timekeeper-integration-test-root-component.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/sys/time/testing/realm-proxy:pkg", |
| ] |
| test_specs = { |
| environments = [ |
| nuc7_env, |
| nuc11_env, |
| ] |
| log_settings = { |
| # Some tests produce "error" level logs as part of the test execution. |
| max_severity = "ERROR" |
| } |
| } |
| } |
| } |
| |
| template("generate_faketime-integration") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//src/sys/time/timekeeper_integration:faketime-integration-test-root-component" |
| test_component_name = "faketime-integration-test-root-component.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/sys/time/testing/realm-proxy:pkg", |
| ] |
| test_specs = { |
| environments = [ |
| nuc7_env, |
| nuc11_env, |
| ] |
| log_settings = { |
| # Some tests produce "error" level logs as part of the test execution. |
| max_severity = "ERROR" |
| } |
| } |
| } |
| } |
| |
| template("generate_fdio-spawn-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//sdk/ctf/tests/pkg/fdio:test-root" |
| test_component_name = "test-root.cm" |
| 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) { |
| 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" |
| test_component_name = "test-root.cm" |
| } |
| } |
| |
| template("generate_fuchsia-settings-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.settings:test-root" |
| test_component_name = "test-root.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//sdk/ctf/tests/fidl/fuchsia.settings/testing/realm-factory", |
| ] |
| } |
| } |
| |
| template("generate_fuchsia-element-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ |
| test_info.target_label, |
| "//sdk/ctf/tests/fidl/fuchsia.element/testing/realm-factory:realm-factory", |
| ] |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.element:test-root" |
| test_component_name = "test-root.cm" |
| } |
| } |
| |
| template("generate_fuchsia-hwinfo-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ test_info.target_label ] |
| test_component = "//sdk/ctf/tests/fidl/fuchsia.hwinfo:test-root" |
| test_component_name = "test-root.cm" |
| } |
| } |
| |
| template("generate_pkgdir-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| if (defined(invoker.api_level) && invoker.api_level == "15") { |
| # TODO(https://fxbug.dev/335307425): Remove this when F15 is no longer supported. |
| not_needed([ "test_info" ]) |
| group(target_name) { |
| } |
| } else { |
| fuchsia_package_with_test(target_name) { |
| subpackages = [ |
| test_info.target_label, |
| "//src/sys/pkg/tests/pkgdir/test_realm_proxy", |
| ] |
| test_component = "//src/sys/pkg/tests/pkgdir:test-root" |
| test_component_name = "test-root.cm" |
| } |
| } |
| } |
| |
| template("generate_simulate-scan-wlan-hw-sim-tests") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| } |
| subpackages = [ |
| test_info.target_label, |
| "//src/connectivity/wlan/tests/helpers/realm-factory", |
| "//src/lib/fuchsia-component-test/realm_builder_server:pkg", |
| ] |
| test_component = "//src/connectivity/wlan/testing/hw-sim/test/simulate_scan:simulate-scan-test-root-component" |
| test_component_name = "test-root.cm" |
| } |
| } |
| |
| template("generate_basic-driver-test") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = |
| "//src/devices/tests/ctf/basic_driver:basic-driver-test-root" |
| test_component_name = "basic-driver-test-root.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/devices/testing/realm-factory", |
| ] |
| } |
| } |
| |
| template("generate_nodegroup_test") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//src/devices/tests/v2/node_group:nodegroup_test_root" |
| test_component_name = "nodegroup_test_root.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/devices/testing/realm-factory", |
| ] |
| } |
| } |
| |
| template("generate_touch-test-suite") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//src/ui/tests/conformance_input_tests:touch-conformance-test-component" |
| test_component_name = "touch-conformance-test.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/ui/testing/context:ui-context-factory", |
| ] |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| environments = [ |
| { |
| dimensions = { |
| # Ensure the device has Vulkan. |
| device_type = "AEMU" |
| } |
| }, |
| ] |
| } |
| } |
| } |
| |
| template("generate_mouse-test-suite") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//src/ui/tests/conformance_input_tests:mouse-conformance-test-component" |
| test_component_name = "mouse-conformance-test.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/ui/testing/context:ui-context-factory", |
| ] |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| environments = [ |
| { |
| dimensions = { |
| # Ensure the device has Vulkan. |
| device_type = "AEMU" |
| } |
| }, |
| ] |
| } |
| } |
| } |
| |
| template("generate_key-test-suite") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = |
| "//src/ui/tests/conformance_input_tests:key-conformance-test-component" |
| test_component_name = "key-conformance-test.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/ui/testing/context:ui-context-factory", |
| ] |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| environments = [ |
| { |
| dimensions = { |
| # Ensure the device has Vulkan. |
| device_type = "AEMU" |
| } |
| }, |
| ] |
| } |
| } |
| } |
| |
| template("generate_focus-test-suite") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//src/ui/tests/conformance_input_tests:focus-conformance-test-component" |
| test_component_name = "focus-conformance-test.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/ui/testing/context:ui-context-factory", |
| ] |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| environments = [ |
| { |
| dimensions = { |
| # Ensure the device has Vulkan. |
| device_type = "AEMU" |
| } |
| }, |
| ] |
| } |
| } |
| } |
| |
| template("generate_media-button-test-suite") { |
| forward_variables_from(invoker, [ "test_info" ]) |
| fuchsia_package_with_test(target_name) { |
| test_component = "//src/ui/tests/conformance_input_tests:media-button-conformance-test-component" |
| test_component_name = "media-button-conformance-test.cm" |
| subpackages = [ |
| test_info.target_label, |
| "//src/ui/testing/context:ui-context-factory", |
| ] |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| environments = [ |
| { |
| dimensions = { |
| # Ensure the device has Vulkan. |
| device_type = "AEMU" |
| } |
| }, |
| ] |
| } |
| } |
| } |
| |
| # 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}_ctf${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) { |
| forward_variables_from(invoker, [ "deps" ]) |
| if (!defined(deps)) { |
| deps = [] |
| } |
| testonly = true |
| deps += tests |
| } |
| } |