blob: 1de28a83c4c06d00d0ee68861844e8a3e4545e9f [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")
# 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.
executable("bin") {
output_name = "fuchsia_microbenchmarks"
testonly = true
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_host) {
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) {
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",
"syscalls.cc",
"threads.cc",
"timer.cc",
"tracing.cc",
"util.cc",
"vmar.cc",
"vmo.cc",
]
}
deps = [
"//sdk/lib/syslog/cpp",
"//src/lib/fxl",
"//zircon/system/ulib/fbl",
]
if (is_fuchsia) {
deps += [
":fuchsia.zircon.benchmarks",
"//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",
]
}
public_deps = [ "//zircon/system/ulib/perftest" ]
}
# 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",
"//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",
]
}
fidl("fuchsia.zircon.benchmarks") {
testonly = true
sources = [
"async_loop.fidl",
"round_tripper.fidl",
]
}
# Installing this package causes fuchsia_microbenchmarks to be run in unit
# test mode (fast mode) via runtests.
#
# This package requires fuchsia_microbenchmarks_perftestmode to also be
# installed.
#
# This package's copy of fuchsia_microbenchmarks invokes both itself
# (fuchsia_microbenchmarks) and no_op_executable as subprocesses, but it
# does so via the redirector executables in /bin (via the shell-commands
# package). Those point to the copies of those executables in
# fuchsia_microbenchmarks_perftestmode, which is why that package is
# required.
#
# Since Fuchsia packages cannot declare dependencies on other packages, GN
# targets that require fuchsia_microbenchmarks_unittestmode should depend
# on the fuchsia_microbenchmarks group() instead.
#
# The reason for splitting fuchsia_microbenchmarks into two packages like
# this is that we don't want to run fuchsia_microbenchmarks in unit test
# mode on the terminal-x64-release builder that runs SL4F tests, for two
# reasons:
#
# 1) The unit tests run on other builders, so it's unnecessary to run them
# a second time.
# 2) Running unit tests on the terminal-x64-release builder currently does
# not work: It results in the creation of a shard to run tests under
# QEMU, but running Fuchsia on QEMU on that builder does not work
# (perhaps because of missing dependencies).
fuchsia_unittest_package("fuchsia_microbenchmarks_unittestmode") {
package_name = "fuchsia_microbenchmarks"
manifest = "meta/fuchsia_microbenchmarks.cmx"
deps = [ ":bin" ]
}
# This package contains the fuchsia_microbenchmarks executable and installs
# a redirector executable for it in /bin (via the shell-commands package).
# Installing this package allows fuchsia_microbenchmarks to be run by SL4F
# tests as a performance test (i.e. outputting performance results data).
# This package can be installed without installing the
# fuchsia_microbenchmarks_unittestmode package.
fuchsia_shell_package("fuchsia_microbenchmarks_perftestmode") {
testonly = true
manifest = "meta/fuchsia_microbenchmarks.cmx"
deps = [
":bin",
":context_switch_overhead_helper",
":get_info_helper",
":no_op_executable",
]
}
if (is_linux) {
host_test("fuchsia_microbenchmarks_host_unittestmode") {
binary_path = "$root_out_dir/fuchsia_microbenchmarks"
deps = [
":bin",
":runtime_deps",
]
}
host_test_data("runtime_deps") {
sources = [ "$root_out_dir/no_op_executable" ]
deps = [ ":no_op_executable" ]
}
}
# This contains all the dependencies necessary for running
# fuchsia_microbenchmarks in unit test mode.
group("tests") {
testonly = true
deps = [
":fuchsia_microbenchmarks_perftestmode",
":fuchsia_microbenchmarks_unittestmode",
]
if (host_os == "linux") {
deps += [ ":fuchsia_microbenchmarks_host_unittestmode($host_toolchain)" ]
}
}
# Convenience target so that one can pass "--with //src/tests/microbenchmarks"
# to "fx set".
group("microbenchmarks") {
testonly = true
deps = [ ":tests" ]
}