| # Copyright 2018 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/config.gni") |
| import("//build/config/fuchsia/zircon_images.gni") |
| import("//build/rust/rustc_macro.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//build/test.gni") |
| import("//build/test/test_package.gni") |
| import("//build/testing/environments.gni") |
| import("//src/sys/build/components.gni") |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":netstack-integration-tests", |
| ":netstack_bsdsocket_c_api_test($host_toolchain)", |
| ":netstack_c_api_tests", |
| ":netstack_external_network_test_client($host_toolchain)", |
| ":netstack_if_nameindex_test($host_toolchain)", |
| "benchmarks", |
| "getifaddrs:tests", |
| "integration:tests", |
| ] |
| } |
| |
| rustc_test("netstack_integration_test_bin") { |
| name = "netstack_integration_test" |
| edition = "2018" |
| |
| deps = [ |
| ":netstack_testing_macros", |
| "//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt-rustc", |
| "//sdk/fidl/fuchsia.hardware.ethernet:fuchsia.hardware.ethernet-rustc", |
| "//sdk/fidl/fuchsia.hardware.ethertap:fuchsia.hardware.ethertap-rustc", |
| "//sdk/fidl/fuchsia.hardware.network:fuchsia.hardware.network-rustc", |
| "//sdk/fidl/fuchsia.inspect.deprecated:fuchsia.inspect.deprecated-rustc", |
| "//sdk/fidl/fuchsia.net:fuchsia.net-rustc", |
| "//sdk/fidl/fuchsia.net.dhcp:fuchsia.net.dhcp-rustc", |
| "//sdk/fidl/fuchsia.net.filter:fuchsia.net.filter-rustc", |
| "//sdk/fidl/fuchsia.net.name:fuchsia.net.name-rustc", |
| "//sdk/fidl/fuchsia.net.stack:fuchsia.net.stack-rustc", |
| "//sdk/fidl/fuchsia.netstack:fuchsia.netstack-rustc", |
| "//sdk/fidl/fuchsia.posix.socket:fuchsia.posix.socket-rustc", |
| "//sdk/fidl/fuchsia.stash:fuchsia.stash-rustc", |
| "//sdk/fidl/fuchsia.sys:fuchsia.sys-rustc", |
| "//src/connectivity/lib/net-declare", |
| "//src/connectivity/lib/net-types", |
| "//src/connectivity/network/testing/netemul/lib/fidl:environment-rustc", |
| "//src/connectivity/network/testing/netemul/lib/fidl:network-rustc", |
| "//src/connectivity/network/testing/netemul/lib/fidl:sandbox-rustc", |
| "//src/connectivity/network/tun/fidl:fidl-rustc", |
| "//src/lib/fdio/rust:fdio", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/network/fidl_fuchsia_net_ext", |
| "//src/lib/network/fidl_fuchsia_net_stack_ext", |
| "//src/lib/network/packet", |
| "//src/lib/network/packet-formats", |
| "//src/lib/zerocopy", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:libc", |
| "//third_party/rust_crates:paste", |
| "//third_party/rust_crates:pin-utils", |
| "//third_party/rust_crates:socket2", |
| "//third_party/rust_crates:thiserror", |
| ] |
| |
| # TODO(46769): Fix the leaks and remove this. |
| non_rust_deps = [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ] |
| } |
| |
| rustc_macro("netstack_testing_macros") { |
| source_root = "src/proc_macros.rs" |
| |
| deps = [ |
| "//third_party/rust_crates:proc-macro-hack", |
| "//third_party/rust_crates:proc-macro2", |
| "//third_party/rust_crates:quote", |
| "//third_party/rust_crates:syn", |
| ] |
| } |
| |
| rustc_test("netstack_cobalt_integration_test_bin") { |
| name = "netstack_cobalt_integration_test" |
| edition = "2018" |
| source_root = "src/cobalt.rs" |
| deps = [ |
| "//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt-rustc", |
| "//sdk/fidl/fuchsia.cobalt.test:fuchsia.cobalt.test-rustc", |
| "//sdk/fidl/fuchsia.net.stack:fuchsia.net.stack-rustc", |
| "//src/connectivity/network/netstack:networking_metrics_rustlib", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/syslog/rust:syslog", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:itertools", |
| ] |
| } |
| |
| fuchsia_component("netstack_integration_test") { |
| testonly = true |
| manifest = "meta/netstack_integration_test.cmx" |
| deps = [ |
| ":netstack_integration_test_bin", |
| |
| # netemul is used to create hermetic environments. |
| "//src/connectivity/network/testing/netemul", |
| ] |
| } |
| |
| fuchsia_component("netstack_cobalt_integration_test") { |
| testonly = true |
| manifest = "meta/netstack_cobalt_integration_test.cmx" |
| deps = [ ":netstack_cobalt_integration_test_bin" ] |
| } |
| |
| zircon_extras_manifest("device_name_provider_manifest") { |
| visibility = [ ":*" ] |
| manifest = "image" |
| patterns = [ "bin/device-name-provider" ] |
| } |
| |
| package("device_name_provider") { |
| deps = [ ":device_name_provider_manifest" ] |
| extra = get_target_outputs(":device_name_provider_manifest") |
| meta = [ |
| { |
| path = rebase_path("meta/device_name_provider.cmx") |
| dest = "device_name_provider.cmx" |
| }, |
| ] |
| } |
| |
| fuchsia_test_package("netstack-integration-tests-inner") { |
| package_name = "netstack-integration-tests" |
| test_components = [ |
| ":netstack_cobalt_integration_test", |
| ":netstack_integration_test", |
| ] |
| deps = [ |
| # dhcpd is used to test DHCP address acquisition. |
| ":dhcpd-testing-configs", |
| "//src/connectivity/network/dhcp:component", |
| |
| # dns_resolver integration with netstack is tested. |
| "//src/connectivity/network/dns:component", |
| |
| # netcfg integration with netstack is tested. |
| ":netcfg-netemul-config", |
| "//src/connectivity/network/netcfg:component-netemul", |
| |
| # netstack3 is under test. |
| "//src/connectivity/network/netstack3:component", |
| |
| # network_manager integration with netstack is tested. |
| "//src/connectivity/management/network-manager:component-netemul", |
| ] |
| } |
| |
| config_data("dhcpd-testing-configs") { |
| testonly = true |
| for_pkg = "netstack-integration-tests" |
| sources = [ |
| "//src/connectivity/network/dhcp/data/bound_device_test_config_eth2.json", |
| "//src/connectivity/network/dhcp/data/bound_device_test_config_eth3.json", |
| "//src/connectivity/network/dhcp/data/default_config.json", |
| "//src/connectivity/network/dhcp/data/test_config.json", |
| ] |
| outputs = [ "dhcpd-testing/{{source_file_part}}" ] |
| } |
| |
| config_data("netcfg-netemul-config") { |
| testonly = true |
| for_pkg = "netstack-integration-tests" |
| sources = [ "//src/connectivity/network/netcfg/config/empty.json" ] |
| outputs = [ "netcfg/empty.json" ] |
| } |
| |
| # This target contains the test package netstack_integration_tests and the |
| # dependencies needed in the image/universe to run the tests within it. |
| # There's currently no way to express a dependency between packages in the build |
| # system, so we aggregate all the dependencies in this group target. |
| # See bug 36293 for more details. |
| group("netstack-integration-tests") { |
| testonly = true |
| |
| deps = [ |
| ":netstack-integration-tests-inner", |
| |
| # device_name_provider provides fuchsia.device.NameProvider. |
| ":device_name_provider", |
| |
| # netstack is under test. |
| "//src/connectivity/network/netstack", |
| |
| # mock_cobalt provides fuchsia.cobalt.LoggerFactory and fuchsia.cobalt.test.LoggerQuerier. |
| "//src/cobalt/bin/testing/mock_cobalt", |
| ] |
| } |
| |
| test("netstack_bsdsocket_c_api_test") { |
| if (is_linux || is_fuchsia) { |
| sources = [ |
| "bsdsocket_test.cc", |
| "util.cc", |
| "util.h", |
| ] |
| |
| # TODO(46920): UBSan has found an instance of undefined behavior in this target. |
| # Disable UBSan for this target temporarily until it is migrated into CI/CQ. |
| configs += [ "//build/config:temporarily_disable_ubsan_do_not_use" ] |
| } |
| |
| deps = [ |
| "//src/lib/fxl/test:gtest_main", |
| "//zircon/public/lib/fbl", |
| ] |
| } |
| |
| test("netstack_if_nameindex_test") { |
| if (is_linux || is_fuchsia) { |
| sources = [ "if_nameindex_test.cc" ] |
| } |
| |
| deps = [ "//src/lib/fxl/test:gtest_main" ] |
| } |
| |
| test("netstack_external_network_test_client") { |
| if (is_linux || is_fuchsia) { |
| sources = [ "external_network_test_client.cc" ] |
| } |
| deps = [ "//src/lib/fxl/test:gtest_main" ] |
| } |
| |
| test("netstack_fuchsia_c_api_test") { |
| sources = [ |
| "fdio_test.cc", |
| "util.cc", |
| "util.h", |
| ] |
| |
| deps = [ |
| "//sdk/fidl/fuchsia.posix.socket:fuchsia.posix.socket_llcpp", |
| "//sdk/lib/fdio", |
| "//src/lib/fxl/test:gtest_main", |
| "//src/lib/testing/predicates", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/sync", |
| ] |
| } |
| |
| test("netstack_no_network_test") { |
| sources = [ "no_network_test.cc" ] |
| |
| deps = [ "//src/lib/fxl/test:gtest_main" ] |
| } |
| |
| test("name_provider_no_network_test") { |
| sources = [ "name_provider_no_network_test.cc" ] |
| |
| deps = [ |
| ":device_name_provider", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_llcpp", |
| "//sdk/lib/sys/cpp", |
| "//src/lib/fxl/test:gtest_main", |
| ] |
| } |
| |
| test("name_provider_service_not_present_test") { |
| sources = [ "name_provider_service_not_present_test.cc" ] |
| |
| deps = [ |
| ":device_name_provider", |
| "//sdk/fidl/fuchsia.device", |
| "//src/lib/fxl/test:gtest_main", |
| ] |
| } |
| |
| # This target contains the test package netstack_c_api_tests and the |
| # dependencies needed in the image/universe to run the tests within it. |
| # There's currently no way to express a dependency between packages in the build |
| # system, so we aggregate all the dependencies in this group target. |
| # See bug 36293 for more details. |
| group("netstack_c_api_tests") { |
| testonly = true |
| deps = [ |
| ":netstack_c_api_tests_inner", |
| |
| # device_name_provider provides fuchsia.device.NameProvider. |
| ":device_name_provider", |
| |
| # netstack is under test. |
| "//src/connectivity/network/netstack", |
| |
| # netemul is used to create hermetic environments. |
| "//src/connectivity/network/testing/netemul", |
| |
| # cat is used to test FD passing. |
| "//third_party/sbase:cat", |
| ] |
| } |
| |
| fuchsia_component("connect") { |
| testonly = true |
| manifest = "meta/connect.cmx" |
| deps = [ "connect" ] |
| } |
| |
| fuchsia_component("connect-test") { |
| testonly = true |
| manifest = "meta/connect_test.cmx" |
| deps = [ ":connect" ] |
| } |
| |
| fuchsia_component("netstack-external-network-test-client") { |
| testonly = true |
| manifest = "meta/netstack_external_network_test_client.cmx" |
| deps = [ ":netstack_external_network_test_client" ] |
| } |
| |
| fuchsia_component("netstack-external-network-test") { |
| testonly = true |
| manifest = "meta/netstack_external_network_test.cmx" |
| deps = [ ":netstack-external-network-test-client" ] |
| } |
| |
| fuchsia_component("name-provider-no-network-test") { |
| testonly = true |
| manifest = "meta/name_provider_no_network_test.cmx" |
| deps = [ ":name_provider_no_network_test" ] |
| } |
| |
| fuchsia_component("name-provider-service-not-present-test") { |
| testonly = true |
| manifest = "meta/name_provider_service_not_present_test.cmx" |
| deps = [ ":name_provider_service_not_present_test" ] |
| } |
| |
| fuchsia_component("netstack-bsdsocket-c-api-test") { |
| testonly = true |
| manifest = "meta/netstack_bsdsocket_c_api_test.cmx" |
| deps = [ ":netstack_bsdsocket_c_api_test" ] |
| } |
| |
| fuchsia_component("netstack-fuchsia-c-api-test") { |
| testonly = true |
| manifest = "meta/netstack_fuchsia_c_api_test.cmx" |
| deps = [ ":netstack_fuchsia_c_api_test" ] |
| } |
| |
| fuchsia_component("netstack-if-nameindex-test") { |
| testonly = true |
| manifest = "meta/netstack_if_nameindex_test.cmx" |
| deps = [ ":netstack_if_nameindex_test" ] |
| } |
| |
| fuchsia_component("netstack-no-network-test") { |
| testonly = true |
| manifest = "meta/netstack_no_network_test.cmx" |
| deps = [ ":netstack_no_network_test" ] |
| } |
| |
| fuchsia_test_package("netstack_c_api_tests_inner") { |
| package_name = "netstack-c-api-tests" |
| |
| test_components = [ |
| ":connect-test", |
| ":name-provider-no-network-test", |
| ":name-provider-service-not-present-test", |
| ":netstack-external-network-test", |
| ":netstack-bsdsocket-c-api-test", |
| ":netstack-fuchsia-c-api-test", |
| ":netstack-if-nameindex-test", |
| ":netstack-no-network-test", |
| ] |
| |
| test_specs = { |
| environments = [ emu_env ] |
| } |
| |
| visibility = [ ":*" ] |
| } |