blob: 763ecbbc8daa122de7745910a7df7eb588f37867 [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("//src/sys/build/fuchsia_component.gni")
# Defines an API integration test.
#
# This template creates a fuchsia_component with the given name, where the
# component contains a test executable built from a source file, along with
# an auto-generated manifest for the test executable.
#
# Example:
# ```
# audio_core_api_test_comonent(name) {
# source = "foo_test.cc"
# executable_deps = ["//lib"]
# }
# ```
#
# Parameters
#
# sources (required)
# List of source files to include in the test executable.
# Type: list(path)
#
# executable_deps (optional)
# List of additional dependencies for the test executable. Libraries needed
# by all tests in this directory will be included by default.
# Type: list(target)
#
# component_deps (optional)
# List of dependencies for the test component.
# Type: list(target)
#
template("audio_core_api_test_component") {
assert(defined(invoker.source) && invoker.source != "",
"source must be specified")
binary = "${target_name}-bin"
cmx_target = "${target_name}_cmx"
cmx_output = "${target_gen_dir}/${target_name}.cmx"
generated_file(cmx_target) {
contents = read_file("meta/audio-core-api-tests.cmx", "string")
contents = string_replace(contents, "{binary}", binary)
outputs = [ cmx_output ]
output_conversion = "string"
testonly = true
}
fuchsia_component(target_name) {
testonly = true
manifest = get_target_outputs(":${cmx_target}")
manifest = manifest[0]
deps = [
":${cmx_target}",
":${target_name}-bin",
]
if (defined(invoker.component_deps)) {
deps += invoker.component_deps
}
}
executable("${target_name}-bin") {
sources = [ invoker.source ]
if (defined(invoker.executable_deps)) {
deps = invoker.executable_deps
} else {
deps = []
}
deps += [
"//sdk/fidl/fuchsia.media",
"//sdk/lib/syslog/cpp",
"//src/lib/fxl/test:gtest_main",
"//src/media/audio/lib/test:hermetic_audio_test",
"//third_party/googletest:gmock",
]
testonly = true
}
}