blob: e0624442772e1ef050a98d756d5101e8caa75c74 [file] [log] [blame]
# Copyright 2020 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/clang/clang.gni")
import("//build/config/fuchsia-sdk.gni")
import("//build/shellscript_test.gni")
import("//third_party/fuchsia-sdk/build/build_id_dir.gni")
import("//third_party/fuchsia-sdk/build/cipd.gni")
import("//third_party/fuchsia-sdk/build/component.gni")
import("//third_party/fuchsia-sdk/build/package.gni")
executable("hello_bin") {
sources = [ "hello.cc" ]
}
executable("renamed_exe") {
sources = [ "hello.cc" ]
output_name = "hello"
}
# Merge 2 cmx files
cmc_merge("merge_cmx") {
sources = [
"meta/part1.cmx",
"meta/part2.cmx",
]
output_name = "combined.cmx"
}
cmc_validate("validate_merged") {
merged_output = get_target_outputs(":merge_cmx")
manifest = merged_output[0]
deps = [ ":merge_cmx" ]
}
# Invalid cmx, building this label will fail
fuchsia_component("invalid_cmx_test") {
manifest = "meta/invalid.cmx"
}
# Produces meta/test_component.cmx
fuchsia_component("test_component_cmx") {
manifest = "meta/test_component.cmx"
data_deps = [ ":renamed_exe" ]
}
# Produces meta/test_component_renamed.cmx
fuchsia_component("test_component_renamed_cmx") {
manifest = "meta/test_component.cmx"
manifest_output_name = "test_component_renamed"
data_deps = [ ":hello_bin" ]
}
# Produces meta/test_component.cm
fuchsia_component("test_component_cm") {
manifest = "meta/test_component.cml"
data_deps = [ ":hello_bin" ]
}
# Produces meta/test_component_renamed.cm
fuchsia_component("test_component_renamed_cm") {
manifest = "meta/test_component.cml"
manifest_output_name = "test_component_renamed"
data_deps = [ ":hello_bin" ]
}
fuchsia_component("vk_validation_component") {
manifest = "meta/test_component.cmx"
manifest_output_name = "vk_validation"
data_deps = [
":hello_bin",
"//build:vulkan_validation",
]
}
fuchsia_component("with_resources") {
manifest = "meta/test_component.cmx"
manifest_output_name = "resource-user"
data_deps = [ ":hello_bin" ]
resources = [
{
path = "resources.txt"
dest = "data/resources.txt"
},
]
}
declare_args() {
do_rename_test = false
}
# Produces meta/overridden_name.cmx
fuchsia_component("test_override_component") {
manifest = "meta/original.cmx"
if (do_rename_test) {
manifest_output_name = "overridden_name"
}
data_deps = [ ":hello_bin" ]
}
fuchsia_package("simple_package_v1") {
deps = [ ":test_component_cmx" ]
}
fuchsia_package("simple_package_v2") {
deps = [ ":test_component_cm" ]
}
fuchsia_package("package") {
deps = [
":test_component_renamed_cm",
":test_component_renamed_cmx",
":test_override_component",
]
}
fuchsia_package("package_with_vk") {
deps = [ ":vk_validation_component" ]
}
fuchsia_package("resource_pkg") {
deps = [ ":with_resources" ]
}
# Test the CIPD packaging and build-id dir generation.
fuchsia_cipd_package("cipd_package") {
package_definition_name = "cipd.yaml"
package = "test/fuchsia/cipd-\${targetarch}"
description = "Test package for CIPD rule template."
# Use absolute root path. This models how things are built and then cipd is
# run outside the GN/ninja environment, so root_build_dir is not known to
# the process running cipd.
use_absolute_root_path = true
deps = [ ":package" ]
sources = [ "${root_gen_dir}/tests/package/package/package.far" ]
}
#
# Create a .build-id directory to contain all the unstripped binaries
# for the Fucshia packages being uploaded to CIPD.
#
_build_ids_path = "${root_build_dir}/cipd/.build-id"
build_id_dir(".build-id") {
output_path = _build_ids_path
# Include symbols from clang as well
build_id_dirs = [ "${clang_base_path}/lib/debug/.build-id" ]
deps = [ ":package" ]
}
#
# Package all the symbols for all Fuchsia packages into a single
# CIPD package.
# This is a little different since the package root is the
# $_build_ids_path, and we want all the contents of it.
# so we add the "." directory.
fuchsia_cipd_package("debug_symbols") {
package_definition_name = "debug_symbols.yaml"
package_definition_dir = "${target_gen_dir}/${target_name}"
package = "test/fuchsia/debug-symbols-\${targetarch}"
description = "Debugging symbols for prebuilt binaries from tests."
package_root = _build_ids_path
# Include the .build-id directory, which is at the root.
directories = [ "." ]
deps = [ ":.build-id" ]
}
# Copy far.sh to the output dir. This script is used
# in the static analysis test.
# manifest_check.sh looks for a specific manifest file.
copy("copy_test_scripts") {
sources = [
"//tests/package/cipd_check.sh",
"//tests/package/far.sh",
"//tests/package/manifest_check.sh",
"//tests/package/symbol_check.sh",
]
outputs = [ "${target_gen_dir}/{{source_file_part}}" ]
}
_packages = [
"package",
"simple_package_v2",
"simple_package_v1",
"package_with_vk",
"resource_pkg",
]
foreach(pkg, _packages) {
# Static far analysis test.
shellscript_test("package_analysis_test_$pkg") {
script_template_file = "run_package_analysis_test_template.txt"
template_keys = [
"script_path",
"far_bin_path",
"package_name",
]
template_data = {
script_path = rebase_path("${target_gen_dir}/far.sh")
far_bin_path = rebase_path("${tools_out_dir}/far")
package_name = rebase_path("${target_gen_dir}/$pkg/$pkg")
}
data_deps = [
":$pkg",
":copy_test_scripts",
"//build:sdk_tools",
]
}
}
# Static far analysis test.
shellscript_test("manifest_check_test") {
script_template_file = "run_package_analysis_test_template.txt"
template_keys = [
"script_path",
"far_bin_path",
"package_name",
"manifest_name",
]
template_data = {
script_path = rebase_path("${target_gen_dir}/manifest_check.sh")
far_bin_path = rebase_path("${tools_out_dir}/far")
package_name = rebase_path("${target_gen_dir}/package/package")
if (do_rename_test) {
manifest_name = "overridden_name.cmx"
} else {
manifest_name = "original.cmx"
}
}
data_deps = [
":copy_test_scripts",
":package",
"//build:sdk_tools",
]
}
shellscript_test("resource_check_test") {
script_template_file = "run_package_analysis_test_template.txt"
template_keys = [
"script_path",
"far_bin_path",
"package_name",
"manifest_name",
]
template_data = {
script_path = rebase_path("${target_gen_dir}/manifest_check.sh")
far_bin_path = rebase_path("${tools_out_dir}/far")
package_name = rebase_path("${target_gen_dir}/resource_pkg/resource_pkg")
manifest_name = "data/resources.txt"
}
data_deps = [
":copy_test_scripts",
":resource_pkg",
"//build:sdk_tools",
]
}
shellscript_test("vk_check_test") {
script_template_file = "run_package_analysis_test_template.txt"
template_keys = [
"script_path",
"far_bin_path",
"package_name",
"manifest_name",
]
template_data = {
script_path = rebase_path("${target_gen_dir}/manifest_check.sh")
far_bin_path = rebase_path("${tools_out_dir}/far")
package_name =
rebase_path("${target_gen_dir}/package_with_vk/package_with_vk")
manifest_name = "lib/VkLayer_khronos_validation.so data/vulkan/explicit_layer.d/VkLayer_khronos_validation.json"
}
data_deps = [
":copy_test_scripts",
":package_with_vk",
"//build:sdk_tools",
]
}
shellscript_test("verify_cipd") {
script_template_file = "run_verify_cipd_template.txt"
template_keys = [
"cipd_script_path",
"cipd_package",
"symbols_script_path",
"symbols_package",
"out_dir",
]
template_data = {
cipd_script_path = rebase_path("${target_gen_dir}/cipd_check.sh")
cipd_package =
rebase_path("${root_gen_dir}/tests/package/cipd_package/cipd.yaml")
symbols_script_path = rebase_path("${target_gen_dir}/symbol_check.sh")
symbols_package = rebase_path(
"${root_gen_dir}/tests/package/debug_symbols/debug_symbols.yaml")
out_dir = rebase_path(root_out_dir)
}
data_deps = [
":cipd_package",
":copy_test_scripts",
":debug_symbols",
]
}
group("tests") {
testonly = true
deps = [
":manifest_check_test",
":resource_check_test",
":validate_merged",
":verify_cipd",
":vk_check_test",
]
foreach(pkg, _packages) {
deps += [ ":package_analysis_test_$pkg" ]
}
}