blob: 3dacbf571a5f88b9704ee7a0f59b03c8e8f73320 [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("$zx/public/gn/toolchain/c_utils.gni")
group("test") {
testonly = true
deps = [ ":fdio" ]
}
zx_test("fdio") {
# If your test can run on host as well as target, consider adding it to
# fdio_hosttests in the "host" directory.
sources = [
"fdio_atexit.cc",
"fdio_directory.cc",
"fdio_eventfd.cc",
"fdio_fd.cc",
"fdio_fdio.cc",
"fdio_get_vmo.cc",
"fdio_handle_fd.c",
"fdio_io.cc",
"fdio_null_namespace.cc",
"fdio_open_max.c",
"fdio_path_canonicalize.c",
"fdio_root.c",
"fdio_socket.cc",
"fdio_socketpair.cc",
"fdio_startup.cc",
"fdio_stubs.cc",
"fdio_timerfd.cc",
"fdio_unsafe.cc",
"fdio_watcher.cc",
]
deps = [
"$zx/system/fidl/fuchsia-io:llcpp",
"$zx/system/fidl/fuchsia-posix-socket:llcpp",
"$zx/system/fidl/fuchsia-process:c",
"$zx/system/ulib/async-loop:async-loop-cpp",
"$zx/system/ulib/async-loop:async-loop-default.static",
"$zx/system/ulib/fbl",
"$zx/system/ulib/fdio",
"$zx/system/ulib/fidl-async",
"$zx/system/ulib/fidl-async:fidl-async-cpp",
"$zx/system/ulib/sync",
"$zx/system/ulib/test-utils",
"$zx/system/ulib/zircon",
"$zx/system/ulib/zx",
"$zx/system/ulib/zxtest",
]
data_deps = [
":accept-child",
":hello-world",
":null-namespace-child",
]
# fdio must not have any static constructors, because its code must work
# before static constructors have run. Some compiler instrumentation
# modes generate static constructors that are harmless and superfluous, so
# don't check those builds. Note that it's important that this be in deps
# here rather than in the group() above, because this will be evaluated
# after variant selection has chosen which build to actually test.
if (toolchain.tags + [ "instrumented" ] - [ "instrumented" ] ==
toolchain.tags) {
deps += [ ":no-static-ctor" ]
}
# TODO(45177): Fix the leaks and remove this.
deps +=
[ "$zx/public/gn/config/instrumentation:suppress-lsan.DO-NOT-USE-THIS" ]
}
zx_executable("accept-child") {
visibility = [ ":*" ]
testonly = true
sources = [ "fdio_atexit_test_accept_child.cc" ]
deps = [
"$zx/system/ulib/fdio",
"$zx/system/ulib/zircon",
]
}
# Used by tests in fdio_startup.cc.
zx_executable("hello-world") {
visibility = [ ":*" ]
testonly = true
sources = [ "hello.cc" ]
deps = [ "$zx/system/ulib/fdio" ]
}
zx_executable("null-namespace-child") {
visibility = [ ":*" ]
testonly = true
sources = [ "fdio_null_namespace_child.c" ]
deps = [
"$zx/system/ulib/fdio",
"$zx/system/ulib/zircon",
]
}
fdio_rspfile = "$target_gen_dir/fdio.rsp"
link_output_rspfile("fdio-rspfile") {
visibility = [ ":*" ]
deps = [ ".." ]
outputs = [ fdio_rspfile ]
}
toolchain_utils_action("no-static-ctor") {
testonly = true
script = "no-static-ctor.sh"
utils = [ "readelf" ]
outputs = [ "$target_out_dir/$target_name" ]
depfile = "${outputs[0]}.d"
deps = [ ":fdio-rspfile" ]
inputs = [ fdio_rspfile ]
args = [
"@" + rebase_path(fdio_rspfile, root_build_dir),
rebase_path(outputs[0], root_build_dir),
rebase_path(depfile, root_build_dir),
]
}