blob: 42d2c62278fda809a24e2bd6fb40364762b8eab8 [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.
##########################################
# Though under //zircon, this build file #
# is meant to be used in the Fuchsia GN #
# build. #
# See fxbug.dev/36139. #
##########################################
assert(!defined(zx) || zx != "/",
"This file can only be used in the Fuchsia GN build.")
import("//build/test.gni")
import("//src/sys/build/fuchsia_unittest_package.gni")
import("//zircon/public/gn/toolchain/c_utils.gni")
fuchsia_unittest_package("fdio-constructor-unittest-package") {
executable_path = "test/fdio-constructor-test"
deps = [ ":fdio-constructor" ]
}
group("tests") {
testonly = true
deps = [ ":fdio-constructor-unittest-package" ]
}
# This bogus test is necessary to have the verification run in the variant
# toolchain.
test("fdio-constructor") {
output_name = "fdio-constructor-test"
sources = [ "bogus-test.cc" ]
# 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_variant.instrumented) {
deps = [ ":no-static-ctor" ]
}
}
fdio_rspfile = "$target_gen_dir/fdio.rsp"
link_output_rspfile("fdio-rspfile") {
visibility = [ ":*" ]
deps = [ "//sdk/lib/fdio" ]
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),
]
}