blob: 8ef62a2457d0eeb2fe5484d41922dc419aa9774c [file] [log] [blame]
# Copyright 2016 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/fidl/fidl.gni")
import("//build/testing/host_test.gni")
import("//src/starnix/tests/build/starnix_host_test_component.gni")
import("//zircon/vdso/vdso.gni")
# This can be built as a Fuchsia executable or as a host executable.
# The latter allows running some of the benchmarks on Linux for
# comparison against Fuchsia.
#
# In principle this could be built for Mac too, but it may require
# changes to build and run successfully on Mac.
fuchsia_microbenchmark_sources = [
"atomics.cc",
"clock_posix.cc",
"example.cc",
"filesystem.cc",
"main.cc",
"malloc.cc",
"memcpy.cc",
"null.cc",
"pthreads.cc",
"random_memcpy.cc",
"round_trips_futex.cc",
"round_trips_posix.cc",
]
if (is_linux) {
fuchsia_microbenchmark_sources += [
# The getpid() microbenchmark would work on Fuchsia, but it is
# not useful to run it on Fuchsia because Fuchsia's getpid()
# function does not return a real process ID.
"getpid.cc",
"process_spawn_posix.cc",
]
}
if (is_fuchsia) {
fuchsia_microbenchmark_sources += [
"async_loop.cc",
"channels.cc",
"clock.cc",
"context_switch_overhead.cc",
"events.cc",
"fdio_spawn.cc",
"fifos.cc",
"get_info.cc",
"handle.cc",
"handle_creation.cc",
"inspect.cc",
"lazy_dir.cc",
"mem_alloc.cc",
"mmu.cc",
"mutex.cc",
"object_wait.cc",
"ports.cc",
"prng.cc",
"pseudo_dir.cc",
"round_trips.cc",
"sleep.cc",
"sockets.cc",
"streams.cc",
"threads.cc",
"timer.cc",
"tracing.cc",
"util.cc",
"vmar.cc",
"vmo.cc",
]
if (!exclude_testonly_syscalls) {
fuchsia_microbenchmark_sources += [
# Uses `zx_syscall_test_*()`.
"syscalls.cc",
]
}
}
fuchsia_microbenchmark_deps = [
"//sdk/lib/syslog/cpp",
"//src/lib/fxl",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/perftest",
]
if (is_fuchsia) {
fuchsia_microbenchmark_deps += [
":fuchsia.zircon.benchmarks_hlcpp",
"//sdk/fidl/fuchsia.scheduler:fuchsia.scheduler_cpp_wire",
"//sdk/lib/fdio",
"//src/lib/fsl",
"//src/lib/storage/vfs/cpp",
"//src/zircon/lib/zircon",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
"//zircon/system/ulib/inspect",
"//zircon/system/ulib/zx",
]
}
executable("fuchsia_microbenchmarks_bin") {
output_name = "fuchsia_microbenchmarks"
testonly = true
sources = fuchsia_microbenchmark_sources
if (is_fuchsia && !exclude_testonly_syscalls) {
sources += [
# Uses `zx_restricted_*()` which is available in the 'next' vdso.
"restricted_enter.cc",
]
}
deps = fuchsia_microbenchmark_deps
}
# This is an executable that immediately exits when run. This is used by the
# process-spawn benchmarks.
executable("no_op_executable") {
output_name = "no_op_executable"
testonly = true
sources = [ "no_op_executable.cc" ]
deps = []
public_deps = []
}
# "Helper" executable used to implement the context_switch_overhead benchmark.
executable("context_switch_overhead_helper") {
output_name = "context_switch_overhead_helper"
testonly = true
sources = [ "context_switch_overhead_helper.cc" ]
deps = [
"//sdk/fidl/fuchsia.scheduler:fuchsia.scheduler_hlcpp",
"//sdk/lib/fdio",
"//sdk/lib/sys/cpp",
"//sdk/lib/syslog/cpp",
"//zircon/system/ulib/zx",
]
}
# "Helper" executable used to implement the get_info benchmark.
executable("get_info_helper") {
output_name = "get_info_helper"
testonly = true
sources = [ "get_info_helper.cc" ]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/zx",
]
}
if (is_fuchsia) {
# "Helper" executable used to implement the round_trips benchmarks on Fuchsia.
executable("round_trips_helper") {
output_name = "round_trips_helper"
testonly = true
sources = [
"main.cc",
"round_trips.cc",
]
deps = [
":fuchsia.zircon.benchmarks_hlcpp",
"//sdk/fidl/fuchsia.scheduler:fuchsia.scheduler_cpp_wire",
"//sdk/lib/fdio",
"//src/lib/fxl",
"//src/lib/storage/vfs/cpp",
"//src/zircon/lib/zircon",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
"//zircon/system/ulib/inspect",
"//zircon/system/ulib/perftest",
"//zircon/system/ulib/zx",
]
}
}
fidl("fuchsia.zircon.benchmarks") {
testonly = true
sources = [
"async_loop.fidl",
"round_tripper.fidl",
]
enable_hlcpp = true
}
fuchsia_unittest_package("fuchsia_microbenchmarks") {
package_name = "fuchsia_microbenchmarks"
manifest = "meta/fuchsia_microbenchmarks.cml"
deps = [
":context_switch_overhead_helper",
":fuchsia_microbenchmarks_bin",
":get_info_helper",
":no_op_executable",
":round_trips_helper",
]
}
if (is_linux) {
host_test("fuchsia_microbenchmarks_host") {
binary_path = "$root_out_dir/fuchsia_microbenchmarks"
deps = [
":fuchsia_microbenchmarks_bin",
":runtime_deps",
]
}
host_test_data("runtime_deps") {
sources = [ "$root_out_dir/no_op_executable" ]
deps = [ ":no_op_executable" ]
}
}
if (host_os == "linux" && target_cpu == "x64" && !is_asan) {
resource("no_op_executable_in_test_dir") {
testonly = true
out_dir = get_label_info(":no_op_executable", "root_out_dir")
sources = [ "${out_dir}/no_op_executable" ]
outputs = [ "data/tests/no_op_executable" ]
deps = [ ":no_op_executable" ]
}
executable("starnix_microbenchmarks_bin") {
output_name = "starnix_microbenchmarks"
testonly = true
sources = fuchsia_microbenchmark_sources + [ "starnix_filesystem.cc" ]
deps = fuchsia_microbenchmark_deps
}
starnix_host_test_component("starnix_microbenchmarks_component") {
test_label = ":starnix_microbenchmarks_bin"
test_binary = "starnix_microbenchmarks"
manifest = "meta/starnix_microbenchmarks.cml"
component_name = "starnix_microbenchmarks"
deps = [ ":no_op_executable_in_test_dir($host_toolchain)" ]
}
group("container_resources") {
deps = [
"//src/starnix/containers:data_tmp_target",
"//src/starnix/containers:default_init",
"//src/starnix/containers/debian:system_image",
]
}
fuchsia_test_package("starnix_microbenchmarks_unittestmode") {
test_components = [ ":starnix_microbenchmarks_component" ]
if (target_cpu == "x64") {
subpackages = [ "//src/starnix/kernel:starnix_kernel_package" ]
}
deps = [
":container_resources",
"//src/lib/testing/expectation:expectation_comparer",
]
}
fuchsia_shell_package("starnix_microbenchmarks_perftestmode") {
testonly = true
if (target_cpu == "x64") {
subpackages = [ "//src/starnix/kernel:starnix_kernel_package" ]
}
deps = [
":container_resources",
":starnix_microbenchmarks_component",
]
# This package intentionally contains many non-Fuchia ELF binaries that
# are not under /data/, and some of them are even unstripped, so disable
# these checks to build successfully.
disable_elf_binaries_checks = true
}
}
# This contains all the dependencies necessary for running
# fuchsia_microbenchmarks in unit test mode.
group("tests") {
testonly = true
deps = [ ":fuchsia_microbenchmarks" ]
if (host_os == "linux") {
deps += [ ":fuchsia_microbenchmarks_host($host_toolchain)" ]
}
if (target_cpu == "x64" && !is_asan) {
if (host_os == "linux") {
deps += [
":starnix_microbenchmarks_perftestmode",
":starnix_microbenchmarks_unittestmode",
]
}
}
}
# Convenience target so that one can pass "--with //src/tests/microbenchmarks"
# to "fx set".
group("microbenchmarks") {
testonly = true
deps = [ ":tests" ]
}