blob: b36e04a374411896b6e89c787d28a460a167a2c0 [file]
# Copyright 2023 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/components/fuchsia_test_package.gni")
import("//build/components/fuchsia_unittest_component.gni")
import("//build/components/fuchsia_unittest_package.gni")
import("//build/test.gni")
import("//build/testing/environments.gni")
import("//build/testing/perf/test.gni")
import("//src/starnix/tests/build/starnix_toolchain_test_component.gni")
import("//src/starnix/tests/starnix_test_subpackages.gni")
test("loopback_socket_benchmarks") {
sources = [ "loopback_socket_benchmarks.cc" ]
deps = [
"//sdk/lib/syslog/cpp",
"//src/connectivity/network/tests:os",
"//src/lib/fxl",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/perftest",
"//zircon/system/ulib/zx",
]
if (is_fuchsia) {
deps += [
"//src/performance/lib/test_utils:trace_controller",
"//zircon/system/ulib/trace",
]
}
}
fuchsia_unittest_component("loopback-socket-benchmarks-with-netstack3") {
manifest = "meta/loopback-socket-benchmarks-with-netstack3.cml"
deps = [ ":loopback_socket_benchmarks" ]
}
fuchsia_unittest_component("loopback-socket-benchmarks-with-fake-netstack") {
manifest = "meta/loopback-socket-benchmarks-with-fake-netstack.cml"
deps = [ ":loopback_socket_benchmarks" ]
}
fuchsia_test_package("loopback-socket-benchmarks-tests") {
test_components = [
":loopback-socket-benchmarks-with-netstack3",
":loopback-socket-benchmarks-with-fake-netstack",
]
subpackages = [
"//src/connectivity/network/netstack3:package-for-tests",
"//src/connectivity/network/tests/benchmarks/fake-netstack:package",
]
}
fuchsia_unittest_component(
"loopback-socket-benchmarks-with-netstack3-tracing") {
manifest = "meta/loopback-socket-benchmarks-with-netstack3-tracing.cml"
deps = [ ":loopback_socket_benchmarks" ]
test_type = "system"
}
fuchsia_test_package("loopback-socket-benchmarks-with-tracing-pkg-netstack3") {
test_components = [ ":loopback-socket-benchmarks-with-netstack3-tracing" ]
subpackages = [ "//src/connectivity/network/netstack3:package-for-tests" ]
# Prevent this test from being run as a target-side test, since it's kicked
# off by the dart wrapper.
test_specs = {
build_only = true
}
}
benchmark_test_configs = [
{
package = ":loopback-socket-benchmarks-tests"
tests = [
{
name = "loopback_socket_benchmarks_with_netstack3"
component = "loopback-socket-benchmarks-with-netstack3"
expected_metric_names_filepath = "//src/tests/end_to_end/perf/expected_metric_names/fuchsia.network.socket.loopback.netstack3.txt"
},
{
name = "loopback_socket_benchmarks_with_fake_netstack"
component = "loopback-socket-benchmarks-with-fake-netstack"
expected_metric_names_filepath = "//src/tests/end_to_end/perf/expected_metric_names/fuchsia.network.socket.loopback.fake_netstack.txt"
},
]
},
]
if (target_cpu != "riscv64" && !is_asan) {
# Remove the netstack package so each test package can provide its own.
_starnix_base_subpackages =
starnix_test_subpackages -
[ "//src/connectivity/network/netstack3:package-for-tests" ] +
[ "//src/starnix/containers/debian:debian_package" ]
starnix_toolchain_test_component(
"loopback-socket-benchmarks-starnix-with-netstack3") {
test_label = ":loopback_socket_benchmarks"
test_binary = "loopback_socket_benchmarks"
manifest = "meta/loopback-socket-benchmarks-starnix-with-netstack3.cml"
test_type = "starnix"
is_starnix_benchmark = true
}
starnix_toolchain_test_component(
"loopback-socket-benchmarks-starnix-with-fake-netstack") {
test_label = ":loopback_socket_benchmarks"
test_binary = "loopback_socket_benchmarks"
manifest = "meta/loopback-socket-benchmarks-starnix-with-fake-netstack.cml"
test_type = "starnix"
is_starnix_benchmark = true
}
fuchsia_test_package(
"loopback-socket-benchmarks-starnix-with-netstack3-pkg") {
package_name = "loopback-socket-benchmarks-starnix-with-netstack3"
test_components = [ ":loopback-socket-benchmarks-starnix-with-netstack3" ]
subpackages = _starnix_base_subpackages +
[ "//src/connectivity/network/netstack3:package-for-tests" ]
test_specs = {
package_resolution_timeout_secs = 660
}
}
fuchsia_test_package(
"loopback-socket-benchmarks-starnix-with-fake-netstack-pkg") {
package_name = "loopback-socket-benchmarks-starnix-with-fake-netstack"
test_components =
[ ":loopback-socket-benchmarks-starnix-with-fake-netstack" ]
subpackages = _starnix_base_subpackages + [ "//src/connectivity/network/tests/benchmarks/fake-netstack:fake-netstack-pkg" ]
test_specs = {
package_resolution_timeout_secs = 660
}
}
starnix_benchmarks = [
":loopback-socket-benchmarks-starnix-with-netstack3-pkg",
":loopback-socket-benchmarks-starnix-with-fake-netstack-pkg",
]
# TODO(https://issuetracker.google.com/296292263): The run count can be
# doubled once the pathological slow-down has been addressed, because the
# bulk of runtime is spent in these cases for NS3 and we expect runtime to
# approximately halve.
#
# Reduce the number of runs for the starnix benchmarks to avoid hitting a
# timeout in Infra.
_starnix_runs = 120
benchmark_test_configs += [
{
package = ":loopback-socket-benchmarks-starnix-with-netstack3-pkg"
package_name = "loopback-socket-benchmarks-starnix-with-netstack3"
runs = _starnix_runs
test_type = "starnix"
tests = [
{
name = "loopback_socket_benchmarks_starnix_with_netstack3"
component = "loopback-socket-benchmarks-starnix-with-netstack3"
expected_metric_names_filepath = "//src/tests/end_to_end/perf/expected_metric_names/fuchsia.network.socket.loopback.starnix.netstack3.txt"
},
]
},
{
package = ":loopback-socket-benchmarks-starnix-with-fake-netstack-pkg"
package_name = "loopback-socket-benchmarks-starnix-with-fake-netstack"
runs = _starnix_runs
test_type = "starnix"
tests = [
{
name = "loopback_socket_benchmarks_starnix_with_fake_netstack"
component = "loopback-socket-benchmarks-starnix-with-fake-netstack"
expected_metric_names_filepath = "//src/tests/end_to_end/perf/expected_metric_names/fuchsia.network.socket.loopback.starnix.fake_netstack.txt"
},
]
},
]
} else {
starnix_benchmarks = []
}
all_test_targets = [
":loopback-socket-benchmarks-tests",
":loopback-socket-benchmarks-with-tracing-pkg-netstack3",
]
all_benchmark_targets =
[ ":loopback-socket-benchmarks-with-tracing-pkg-netstack3" ] +
starnix_benchmarks
foreach(test_config, benchmark_test_configs) {
foreach(test, test_config.tests) {
fuchsia_component_perf_test(test.name) {
package = test_config.package
if (defined(test_config.package_name)) {
package_name = test_config.package_name
}
component_name = test.component
expected_metric_names_filepath = test.expected_metric_names_filepath
test_component_args = [
"-p",
"--quiet",
]
if (defined(test_config.runs)) {
test_component_args += [
"--runs",
"${test_config.runs}",
]
}
if (defined(test_config.test_type)) {
test_type = test_config.test_type
}
results_path_test_arg = "--out"
}
all_benchmark_targets += [ ":${test.name}" ]
}
}
group("tests") {
testonly = true
deps = all_test_targets + [ ":loopback_socket_benchmarks($host_toolchain)" ]
}
group("starnix_tests") {
testonly = true
deps = starnix_benchmarks
}
group("benchmarks") {
testonly = true
deps = all_benchmark_targets
}