blob: d41384effe28e2e1f2434262bf3d87f0becb131a [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/components.gni")
import("//build/test.gni")
import("//build/testing/boot_tests/kernel_zbi_test.gni")
import("//build/testing/boot_tests/zbi_test_executable.gni")
import("//build/testing/environments.gni")
import("../libc.gni")
# We want to run these tests on every kind of hardware as well as emulators.
libc_test_specs = {
environments = all_fuchsia_envs
}
default_stack_size_cases = [
{
# This uses the compiled-in default.
name = "default"
},
{
# This uses an arbitrary, non-default size. It needs to be an even
# multiple of page size, since specified sizes are always rounded up.
name = "phdr"
size = 1114112 # 0x110000
},
]
foreach(case, default_stack_size_cases) {
test("default-stack-size-${case.name}") {
if (is_fuchsia) {
fdio_config = [ "//build/config/fuchsia:fdio_config" ]
if (configs + fdio_config - fdio_config != configs) {
configs -= fdio_config
}
}
sources = [ "default-stack-size-test.cc" ]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/zircon-internal",
"//zircon/system/ulib/zxtest",
]
if (defined(case.size)) {
defines = [ "STACK_TEST_EXPECTED_SIZE=${case.size}" ]
ldflags = [ "-Wl,-z,stack-size=${case.size}" ]
}
}
fuchsia_unittest_package("default-stack-size-${case.name}-pkg") {
deps = [ ":default-stack-size-${case.name}" ]
}
}
executable("debugdata-test-helper") {
if (is_fuchsia) {
fdio_config = [ "//build/config/fuchsia:fdio_config" ]
if (configs + fdio_config - fdio_config != configs) {
configs -= fdio_config
}
}
testonly = true
sources = [ "debugdata-test-helper.cc" ]
deps = [ "//zircon/system/ulib/zx" ]
}
test("cdebugdata-test") {
if (is_fuchsia) {
fdio_config = [ "//build/config/fuchsia:fdio_config" ]
if (configs + fdio_config - fdio_config != configs) {
configs -= fdio_config
}
}
sources = [ "debugdata.cc" ]
data_deps = [ ":debugdata-test-helper" ]
deps = [
"//sdk/fidl/fuchsia.debugdata:fuchsia.debugdata_cpp",
"//sdk/fidl/fuchsia.io:fuchsia.io_cpp",
"//sdk/lib/fdio",
"//sdk/lib/fidl",
"//src/storage/lib/vfs/cpp",
"//zircon/system/ulib/async",
"//zircon/system/ulib/async:async-cpp",
"//zircon/system/ulib/async-loop",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
"//zircon/system/ulib/zircon-internal",
"//zircon/system/ulib/zx",
"//zircon/system/ulib/zxtest",
]
output_dir = "$root_out_dir/zircon-migrated"
}
test("posix-clocks-test") {
if (is_fuchsia) {
fdio_config = [ "//build/config/fuchsia:fdio_config" ]
if (configs + fdio_config - fdio_config != configs) {
configs -= fdio_config
}
}
sources = [ "posix-clocks.cc" ]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/zx",
"//zircon/system/ulib/zxtest",
]
}
test("pthread-detach-idempotent-test") {
if (is_fuchsia) {
fdio_config = [ "//build/config/fuchsia:fdio_config" ]
if (configs + fdio_config - fdio_config != configs) {
configs -= fdio_config
}
}
sources = [ "pthread_detach_idempotent.cc" ]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/sync",
"//zircon/system/ulib/zx",
"//zircon/system/ulib/zxtest",
]
}
test("atexit-test") {
if (is_fuchsia) {
configs += [ "//build/config:all_source" ]
}
if (is_fuchsia) {
fdio_config = [ "//build/config/fuchsia:fdio_config" ]
if (configs + fdio_config - fdio_config != configs) {
configs -= fdio_config
}
}
sources = [ "atexit.cc" ]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/zxtest",
]
}
group("test") {
testonly = true
deps = [
":atexit-test-pkg",
":cdebugdata-test-pkg",
":gwp-asan-test-pkg",
":libc-unittests-pkg",
":posix-clocks-test-pkg",
":pthread-detach-idempotent-test-pkg",
"dlsym-circular-deps",
"ldso-xom:tests",
"noop:tests",
]
foreach(case, default_stack_size_cases) {
deps += [ ":default-stack-size-${case.name}-pkg" ]
}
}
group("tests") {
testonly = true
deps = [ ":test" ]
}
group("boot_tests") {
testonly = true
deps = [ ":boot-libc-unittests" ]
}
fuchsia_unittest_package("atexit-test-pkg") {
deps = [ ":atexit-test" ]
test_specs = libc_test_specs
}
fuchsia_unittest_package("cdebugdata-test-pkg") {
manifest = "cdebugdata-test.cml"
deps = [ ":cdebugdata-test" ]
test_specs = libc_test_specs
}
fuchsia_unittest_package("posix-clocks-test-pkg") {
deps = [ ":posix-clocks-test" ]
test_specs = libc_test_specs
}
fuchsia_unittest_package("pthread-detach-idempotent-test-pkg") {
deps = [ ":pthread-detach-idempotent-test" ]
test_specs = libc_test_specs
}
test("libc-unittests") {
deps = [ "..:unittests" ]
}
fuchsia_unittest_package("libc-unittests-pkg") {
deps = [ ":libc-unittests" ]
test_specs = libc_test_specs
}
# This set of tests serve as a good smoke test for libc itself and essential
# kernel support that affect the libc tests, before expecting any of the more
# demanding core-tests to necessarily work when libc might be suspect.
zbi_test_executable("libc-unittests-standalone") {
deps = [
"..:unittests",
"//src/zircon/testing/standalone-test",
"//zircon/system/ulib/zxtest",
]
}
kernel_zbi_test("boot-libc-unittests") {
deps = [ ":libc-unittests-standalone" ]
# TODO(https://fxbug.dev/42076755) Remove timeout when llvm-libc functions are optimized.
if (target_cpu == "riscv64") {
timeout = 1200
}
}
test("gwp-asan-test") {
# Whether GWP-ASan is enabled.
has_gwp_asan = !variant_replaces_allocator
sources = [ "gwp-asan-test.cc" ]
defines = [ "HAS_GWP_ASAN=$has_gwp_asan" ]
deps = [
"//sdk/lib/fdio",
"//sdk/lib/fit",
"//zircon/system/ulib/c/scudo:gwp-asan-common",
"//zircon/system/ulib/elf-search",
"//zircon/system/ulib/zx",
"//zircon/system/ulib/zxtest",
]
data_deps = [ ":gwp-asan-test-use-after-free" ]
}
template("executable_with_backtrace") {
executable(target_name) {
forward_variables_from(invoker, "*")
# Enable frame pointer for backtrace.
configs += [
"//build/config:frame_pointers",
"//build/config:default_frame_pointers",
]
configs -= [ "//build/config:default_frame_pointers" ]
}
}
executable_with_backtrace("gwp-asan-test-use-after-free") {
testonly = true
sources = [ "gwp-asan-test-use-after-free.cc" ]
}
executable_with_backtrace("gwp-asan-test-double-free") {
testonly = true
sources = [ "gwp-asan-test-double-free.cc" ]
}
executable_with_backtrace("gwp-asan-test-invalid-free") {
testonly = true
sources = [ "gwp-asan-test-invalid-free.cc" ]
}
executable_with_backtrace("gwp-asan-test-buffer-overflow") {
testonly = true
sources = [ "gwp-asan-test-buffer-overflow.cc" ]
}
executable_with_backtrace("gwp-asan-test-buffer-underflow") {
testonly = true
sources = [ "gwp-asan-test-buffer-underflow.cc" ]
}
fuchsia_unittest_package("gwp-asan-test-pkg") {
manifest = "gwp-asan-test.cml"
deps = [ ":gwp-asan-test" ]
test_specs = libc_test_specs
}