blob: 096974a838e3480c4e9ce3d395673816516aca60 [file] [log] [blame]
# Copyright 2017 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/package.gni")
import("//build/test/test_package.gni")
import("//build/testing/environments.gni")
# Set manually to true to compile the zxdb_test_app.cc file for manual debugger
# testing of various conditions.
include_test_app = false
static_library("lib") {
sources = [
"agent_configuration.cc",
"agent_configuration.h",
"arch.h",
"arch_helpers.cc",
"arch_helpers.h",
"arch_provider_fuchsia.cc",
"arch_provider_fuchsia.h",
"arch_provider_impl.h",
"binary_launcher.cc",
"binary_launcher.h",
"breakpoint.cc",
"breakpoint.h",
"component_launcher.cc",
"component_launcher.h",
"debug_agent.cc",
"debug_agent.h",
"debugged_job.cc",
"debugged_job.h",
"debugged_process.cc",
"debugged_process.h",
"debugged_thread.cc",
"debugged_thread.h",
"elf_utils.cc",
"elf_utils.h",
"general_registers.cc",
"general_registers.h",
"hardware_breakpoint.cc",
"hardware_breakpoint.h",
"limbo_provider.cc",
"limbo_provider.h",
"object_provider.cc",
"object_provider.h",
"process_breakpoint.cc",
"process_breakpoint.h",
"process_handle.h",
"remote_api.h",
"remote_api_adapter.cc",
"remote_api_adapter.h",
"socket_connection.cc",
"socket_connection.h",
"software_breakpoint.cc",
"software_breakpoint.h",
"system_info.cc",
"system_info.h",
"thread_exception.h",
"thread_handle.h",
"unwind.cc",
"unwind.h",
"watchpoint.cc",
"watchpoint.h",
"zircon_process_handle.cc",
"zircon_process_handle.h",
"zircon_thread_exception.cc",
"zircon_thread_exception.h",
"zircon_thread_handle.cc",
"zircon_thread_handle.h",
]
if (current_cpu == "x64") {
sources += [
"arch_provider_x64.cc",
"arch_provider_x64.h",
"arch_x64.cc",
"arch_x64_helpers.cc",
"arch_x64_helpers.h",
]
} else if (current_cpu == "arm64") {
sources += [
"arch_arm64.cc",
"arch_arm64_helpers.cc",
"arch_arm64_helpers.h",
"arch_provider_arm64.cc",
"arch_provider_arm64.h",
]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
deps = [ "//src/lib/elflib" ]
public_deps = [
"//garnet/lib/process",
"//sdk/fidl/fuchsia.boot",
"//sdk/fidl/fuchsia.exception",
"//src/developer/debug/ipc:agent",
"//src/developer/debug/ipc:client",
"//src/developer/debug/shared",
"//src/developer/debug/third_party/libunwindstack",
"//src/lib/containers/cpp",
"//src/lib/fxl",
"//third_party/googletest:gtest_prod",
"//zircon/public/lib/fit",
"//zircon/public/lib/ngunwind",
"//zircon/public/lib/zxc",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
}
if (include_test_app) {
executable("zxdb_test_app") {
if (is_debug) {
# Force no optimization in debug builds.
configs -= [ "//build/config:default_optimize" ]
configs += [ "//build/config:optimize_none" ]
}
sources = [ "zxdb_test_app.cc" ]
deps = [ "//zircon/public/lib/zx" ]
}
}
executable("bin") {
output_name = "debug_agent"
sources = [ "main.cc" ]
deps = [
":lib",
"//sdk/lib/sys/cpp",
"//zircon/public/lib/cmdline",
]
}
package("debug_agent") {
deps = [ ":bin" ]
meta = [
{
path = rebase_path("meta/debug_agent.cmx")
dest = "debug_agent.cmx"
},
]
binaries = [
{
name = "debug_agent"
},
]
}
# Common functionality used by tests.
source_set("test_lib") {
testonly = true
sources = [
"local_stream_backend.cc",
"local_stream_backend.h",
"mock_arch_provider.cc",
"mock_arch_provider.h",
"mock_object_provider.cc",
"mock_object_provider.h",
"mock_process.cc",
"mock_process.h",
"mock_process_handle.cc",
"mock_process_handle.h",
"mock_thread.cc",
"mock_thread.h",
"mock_thread_exception.h",
"mock_thread_handle.cc",
"mock_thread_handle.h",
]
public_deps = [
":lib",
"//src/developer/debug/shared:test_support",
]
}
executable("unit_tests") {
testonly = true
output_name = "debug_agent_unit_tests"
sources = [
"arch_helpers_unittest.cc",
"breakpoint_unittest.cc",
"debug_agent_unittest.cc",
"debugged_job_unittest.cc",
"debugged_process_unittest.cc",
"debugged_thread_breakpoint_unittest.cc",
"debugged_thread_unittest.cc",
"hardware_breakpoint_unittest.cc",
"limbo_provider_unittest.cc",
"software_breakpoint_unittest.cc",
"system_info_unittests.cc",
"unwind_unittest.cc",
"watchpoint_unittest.cc",
]
if (current_cpu == "x64") {
sources += [
"arch_provider_x64.cc",
"arch_provider_x64.h",
"arch_x64_helpers_unittest.cc",
"arch_x64_unittest.cc",
]
} else if (current_cpu == "arm64") {
sources += [
"arch_arm64_helpers_unittest.cc",
"arch_arm64_helpers_unittest.h",
"arch_arm64_unittest.cc",
"arch_provider_arm64.cc",
"arch_provider_arm64.h",
]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
deps = [
":test_lib",
"//sdk/lib/sys/cpp/testing:unit",
"//src/developer/debug/ipc:tests",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
# TODO(46711): Fix the leaks and remove this.
deps += [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ]
}
test_package("debug_agent_tests") {
package_name = "debug_agent_tests"
deps = []
binaries = []
# Tests ----------------------------------------------------------------------
# Unit tests.
deps += [ ":unit_tests" ]
tests = [
{
name = "debug_agent_unit_tests"
environments = basic_envs
},
]
# Integration tests ----------------------------------------------------------
# Integration tests do not run on QEMU because some of the low-level
# functionality is not implemented correctly.
# TODO(47485): Make pass w/ ASan and switch to [ nuc_env ].
integration_tests_env = nuc_env_fails_on_asan
deps += [ "//src/developer/debug/debug_agent/integration_tests" ]
tests += [
{
name = "debug_agent_integration_tests"
environments = integration_tests_env
},
]
# This .so will be used by some test to verify actual symbols.
deps += [ "//src/developer/debug/debug_agent/test_data:debug_so" ]
loadable_modules = [
{
name = "debug_agent_test_so.so"
},
]
# These are executables that integration tests will need in order to test
# actual behaviour against zircon.
deps += [ "//src/developer/debug/debug_agent/test_data:test_executables" ]
binaries += [
{
name = "breakpoint_test_exe"
},
{
name = "multithreaded_breakpoint_test_exe"
},
{
name = "watchpoint_test_exe"
},
]
if (current_cpu == "x64") {
binaries += [
{
name = "write_register_test_exe"
},
]
}
# Helper Executables ---------------------------------------------------------
#
# These executables are not used by tests or the agent, but are useful for
# replicating behaviour in development.
deps += [ "//src/developer/debug/debug_agent/test_data:helper_executables" ]
# Test binaries
binaries += [
{
name = "backtrace_request"
},
{
name = "debug_test_false"
},
{
name = "debug_test_true"
},
{
name = "test_suite"
},
{
name = "hw_watchpointer"
},
{
name = "multi_threaded"
},
{
name = "printer"
},
{
name = "process_loop"
},
{
name = "process_spawner"
},
{
name = "thread_signals"
},
{
name = "limbo_caller"
},
]
meta = [
{
path = "meta/limbo_caller.cmx"
dest = "limbo_caller.cmx"
},
{
path = "meta/test_suite.cmx"
dest = "debug_agent_test_suite.cmx"
},
]
if (include_test_app) {
deps += [ ":zxdb_test_app" ]
binaries += [
{
name = "zxdb_test_app"
},
]
}
}
group("tests") {
testonly = true
deps = [ ":debug_agent_tests" ]
}