blob: d0205a90b8f93620ce0d88ea18be7ba15691a153 [file] [log] [blame]
# 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/fidl/fidl.gni")
import("//build/package.gni")
import("//build/test/test_package.gni")
import("//build/testing/environments.gni")
import("//src/virtualization/buildtools/linux_paths.gni")
import("//src/virtualization/buildtools/romfs_image.gni")
import("//third_party/protobuf/proto_library.gni")
group("tests") {
testonly = true
deps = [
":guest_discovery_service",
":guest_interaction_tests",
]
}
group("guest_interaction") {
testonly = true
deps = [
":debian_guest_interaction_daemon",
":guest_discovery_service",
]
}
proto_library("proto") {
sources = [ "proto/guest_interaction.proto" ]
generate_python = false
cc_generator_options = "lite"
generator_plugin_suffix = ".grpc.pb"
generator_plugin_label = "//third_party/grpc:grpc_cpp_plugin"
import_dirs = [ "//third_party/protobuf/src" ]
deps = [ "//third_party/grpc:grpc++" ]
}
source_set("common") {
sources = [ "common.h" ]
deps = [
":proto",
"//third_party/grpc:grpc++",
]
}
source_set("platform_interface_posix") {
sources = [
"platform_interface/platform_interface.h",
"platform_interface/posix_platform.cc",
]
deps = [
":common",
"//third_party/grpc:grpc++",
"//third_party/protobuf:protobuf_full",
]
}
source_set("client_lib") {
sources = [
"client/client_operation_state.h",
"platform_interface/platform_interface.h",
]
deps = [
":common",
":proto",
"//sdk/lib/sys/cpp",
"//src/lib/fxl",
"//third_party/grpc:grpc++",
]
}
source_set("server_lib") {
sources = [
"platform_interface/platform_interface.h",
"server/server_operation_state.h",
]
deps = [
":common",
":proto",
"//src/lib/fxl",
"//third_party/grpc:grpc++",
]
}
source_set("operation_test_lib") {
testonly = true
sources = [ "test/operation_test_lib.h" ]
deps = [
":proto",
"//src/lib/fxl",
"//src/lib/fxl/test:gtest_main",
"//third_party/grpc:grpc++",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
}
source_set("integration_test_lib") {
testonly = true
sources = [ "test/operation_test_lib.h" ]
deps = [
":proto",
"//sdk/fidl/fuchsia.net",
"//sdk/fidl/fuchsia.net.stack",
"//sdk/fidl/fuchsia.netstack",
"//sdk/fidl/fuchsia.virtualization",
"//sdk/lib/sys/cpp/testing:enclosing_environment",
"//sdk/lib/sys/cpp/testing:integration",
"//src/lib/fxl/test:gtest_main",
"//src/virtualization/tests:fake_netstack",
"//src/virtualization/tests:guest_console",
]
}
executable("client_operation_test") {
testonly = true
sources = [ "test/client_operation_test.cc" ]
deps = [
":client_lib",
":fuchsia.netemul.guest",
":operation_test_lib",
":proto",
"//sdk/lib/sys/cpp",
"//src/lib/fxl",
"//src/lib/fxl/test:gtest_main",
"//src/lib/testing/predicates",
"//src/virtualization/lib/grpc:grpc",
"//third_party/grpc:grpc++",
"//zircon/system/ulib/async-loop:async-loop-cpp",
]
# TODO(fxbug.dev/68325): Fix UB within GRPC and re-enable ubsan.
exclude_toolchain_tags = [ "ubsan" ]
}
executable("server_operation_test") {
testonly = true
sources = [ "test/server_operation_test.cc" ]
deps = [
":operation_test_lib",
":proto",
":server_lib",
"//sdk/lib/sys/cpp",
"//sdk/lib/syslog/cpp",
"//src/lib/fxl/test:gtest_main",
"//third_party/grpc:grpc++",
"//zircon/system/ulib/async-loop:async-loop-cpp",
]
# TODO(fxbug.dev/68325): Fix UB within GRPC and re-enable ubsan.
exclude_toolchain_tags = [ "ubsan" ]
}
test_package("guest_interaction_tests") {
deps = [
":client_operation_test",
":guest_interaction_service_test",
":server_daemon_test",
":server_operation_test",
]
resources = [
{
path = rebase_path("test/test_script.sh")
dest = "test_script.sh"
},
]
tests = [
{
name = "client_operation_test"
},
{
name = "server_operation_test"
},
{
name = "server_daemon_test"
# TODO(fxbug.dev/48129): Currently hangs in ASan. Fix and switch to [ nuc_env ].
environments = nuc_env_fails_on_asan
},
{
name = "guest_interaction_service_test"
# TODO(fxbug.dev/48129): Currently hangs in ASan. Fix and switch to [ nuc_env ].
environments = nuc_env_fails_on_asan
},
]
}
executable("debian_guest_interaction_daemon") {
output_name = "guest_interaction_daemon"
sources = [ "server/debian_server.cc" ]
deps = [
":platform_interface_posix",
":proto",
":server_lib",
"//sdk/lib/syslog/cpp",
"//third_party/grpc:grpc++",
]
}
executable("server_daemon_test") {
testonly = true
sources = [
"client/client_impl.h",
"client/client_operation_state.h",
"test/server_integration_test.cc",
]
deps = [
":common",
":fuchsia.netemul.guest",
":integration_test_lib",
":platform_interface_posix",
":proto",
"//sdk/fidl/fuchsia.kernel",
"//sdk/fidl/fuchsia.net",
"//sdk/fidl/fuchsia.net.stack",
"//sdk/fidl/fuchsia.netstack",
"//sdk/fidl/fuchsia.virtualization",
"//sdk/lib/fdio",
"//sdk/lib/sys/cpp/testing:enclosing_environment",
"//sdk/lib/sys/cpp/testing:integration",
"//src/lib/fxl",
"//src/lib/fxl/test:gtest_main",
"//src/virtualization/lib/grpc:grpc",
"//src/virtualization/tests:fake_netstack",
"//src/virtualization/tests:guest_console",
"//third_party/grpc:grpc++",
"//zircon/system/ulib/fzl",
]
configs += [ "//build/config:all_source" ]
}
fidl("fuchsia.netemul.guest") {
sdk_category = "internal"
sources = [ "fidl/fuchsia.netemul.guest_interaction.fidl" ]
public_deps = [ "//sdk/fidl/fuchsia.io" ]
}
executable("guest_discovery_service_bin") {
output_name = "guest_discovery_service"
sources = [
"client/client_impl.h",
"client/guest_discovery_service.cc",
"client/guest_discovery_service.h",
"client/guest_discovery_service_main.cc",
"client/guest_interaction_service.cc",
"client/guest_interaction_service.h",
]
deps = [
":client_lib",
":common",
":fuchsia.netemul.guest",
":platform_interface_posix",
":proto",
"//sdk/fidl/fuchsia.virtualization",
"//sdk/lib/fdio",
"//sdk/lib/sys/cpp",
"//sdk/lib/syslog/cpp",
"//src/lib/fxl",
"//src/virtualization/lib/grpc:grpc",
"//third_party/grpc:grpc++",
"//zircon/public/lib/async-cpp",
"//zircon/system/ulib/async-default",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
# Enables thrd_create_with_name in <threads.h>.
configs += [ "//build/config:all_source" ]
}
package("guest_discovery_service") {
deps = [ ":guest_discovery_service_bin" ]
binaries = [
{
name = "guest_discovery_service"
},
]
meta = [
{
path = rebase_path("meta/guest_discovery_service.cmx")
dest = "guest_discovery_service.cmx"
},
]
}
executable("guest_interaction_service_test") {
testonly = true
sources = [ "test/service_integration_test.cc" ]
deps = [
":common",
":fuchsia.netemul.guest",
":integration_test_lib",
"//garnet/public/lib/svc/cpp",
"//sdk/fidl/fuchsia.kernel",
"//sdk/fidl/fuchsia.net",
"//sdk/fidl/fuchsia.net.stack",
"//sdk/fidl/fuchsia.netstack",
"//sdk/fidl/fuchsia.virtualization",
"//sdk/lib/fdio",
"//sdk/lib/sys/cpp/testing:enclosing_environment",
"//sdk/lib/sys/cpp/testing:integration",
"//src/lib/fxl",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gmock",
"//third_party/grpc:grpc++",
"//third_party/protobuf:protobuf_full",
"//zircon/system/ulib/fzl",
]
}
extras_image = "$target_out_dir/linux/extras.img"
romfs_image("extras") {
deps = []
inputs = []
# gRPC has a dependency on //third_party/cares which can only target x64. Only build the Debian
# server for x64 guests. Provide an empty image for arm64.
if (target_cpu == "x64") {
deps += [ ":debian_guest_interaction_daemon(${linux_exe_toolchain})" ]
inputs += [ "${linux_exe_path}/guest_interaction_daemon" ]
}
output = extras_image
}