blob: b2c4b243075c61ad9e176a8345289f5998068084 [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.cc",
"arch.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",
"hardware_breakpoint.cc",
"hardware_breakpoint.h",
"object_util.cc",
"object_util.h",
"process_breakpoint.cc",
"process_breakpoint.h",
"process_info.cc",
"process_info.h",
"process_memory_accessor.h",
"process_watchpoint.cc",
"process_watchpoint.h",
"software_breakpoint.cc",
"software_breakpoint.h",
"remote_api.h",
"remote_api_adapter.cc",
"remote_api_adapter.h",
"system_info.cc",
"system_info.h",
"unwind.cc",
"unwind.h",
"watchpoint.cc",
"watchpoint.h",
]
if (current_cpu == "x64") {
sources += [
"arch_x64.cc",
"arch_x64.h",
"arch_x64_helpers.cc",
"arch_x64_helpers.h",
]
} else if (current_cpu == "arm64") {
sources += [
"arch_arm64.cc",
"arch_arm64.h",
"arch_arm64_helpers.cc",
"arch_arm64_helpers.h",
]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
public_deps = [
"//garnet/lib/process",
"//garnet/public/lib/svc/cpp",
"//garnet/third_party/libunwindstack",
"//src/developer/debug/ipc:agent",
"//src/developer/debug/shared",
"//src/lib/fxl",
"//zircon/public/fidl/fuchsia-sysinfo:fuchsia-sysinfo_c",
"//zircon/public/lib/async-loop-cpp",
"//zircon/public/lib/ngunwind",
]
}
if (include_test_app) {
executable("zxdb_test_app") {
if (is_debug) {
# Force no optimization in debug builds.
configs -= [ "//build/config:debug" ]
cflags = [ "-O0" ]
}
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"
},
]
binary = "debug_agent"
}
executable("unit_tests") {
testonly = true
output_name = "debug_agent_unit_tests"
sources = [
"breakpoint_unittest.cc",
"debugged_thread_unittest.cc",
"mock_arch_provider.cc",
"mock_arch_provider.h",
"mock_process.cc",
"mock_process.h",
"process_breakpoint_unittest.cc",
"process_watchpoint_unittest.cc",
"system_info_unittests.cc",
]
if (current_cpu == "x64") {
sources += [ "arch_x64_helpers_unittest.cc" ]
} else if (current_cpu == "arm64") {
sources += [ "arch_arm64_helpers_unittest.cc" ]
} else {
assert(false, "Un-supported CPU: ${current_cpu}")
}
deps = [
":lib",
"//src/developer/debug/ipc:tests",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
}
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.
integration_tests_env = [
nuc_env,
vim2_env,
]
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"
},
]
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 = "debug_test_false"
},
{
name = "debug_test_true"
},
{
name = "hw_breakpointer"
},
{
name = "hw_watchpointer"
},
{
name = "multi_threaded"
},
{
name = "printer"
},
{
name = "process_spawner"
},
{
name = "process_loop"
},
]
if (include_test_app) {
deps += [ ":zxdb_test_app" ]
binaries += [
{
name = "zxdb_test_app"
},
]
}
}