| # 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/packages/prebuilt_test_package.gni") |
| |
| # Defines prebuilt package tests based on the contents in a prebuilt test manifest. |
| # |
| # Vendors are required to upload a "test_manifest.json" file in the same CIPD |
| # package as their prebuilt FAR tests. We use this manifest for determining |
| # which test packages to enable and how each test package is run. |
| # |
| # Parameters |
| # |
| # archive_dir (required) |
| # [string] Path to directory containing prebuilt archives and test_manifest.json |
| # |
| # package_name_prefix (required) |
| # [string] Vendor specific prefix to add to pacakge (for avoiding GN target collision) |
| # |
| # environments (optional, default: [ { dimensions = { device_type = "QEMU" } } ]) |
| # [list of scopes] Device environments in which the test should run. |
| # |
| # Environment scope is defined in //build/testing/test_spec.gni |
| # |
| template("prebuilt_test_manifest") { |
| assert(defined(invoker.archive_dir), "archive_dir must be defined.") |
| assert(defined(invoker.package_name_prefix), "package_name_prefix must be defined.") |
| |
| manifest_path = "${invoker.archive_dir}/test_manifest.json" |
| manifest = read_file(manifest_path, "json") |
| test_targets = [] |
| foreach(test, manifest) { |
| package_target_name = "${invoker.package_name_prefix}-${test.package}" |
| test_package = test.package |
| component_name = test.component_name |
| |
| prebuilt_test_package(package_target_name) { |
| archive = "${invoker.archive_dir}/${test_package}.far" |
| package = test_package |
| tests = [ |
| { |
| component_name = component_name |
| forward_variables_from(invoker, [ "environments" ]) |
| }, |
| ] |
| } |
| |
| test_targets += [ ":${package_target_name}" ] |
| } |
| |
| group(target_name) { |
| testonly = true |
| public_deps = test_targets |
| } |
| } |