| # Copyright 2017 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/rust/rustc_fuzzer.gni") |
| import("//build/rust/rustc_library.gni") |
| |
| lib_sources = [ |
| "src/algorithm/mod.rs", |
| "src/algorithm/port_alloc.rs", |
| "src/benchmarks.rs", |
| "src/context.rs", |
| "src/data_structures/id_map.rs", |
| "src/data_structures/id_map_collection.rs", |
| "src/data_structures/mod.rs", |
| "src/data_structures/ref_counted_hash_map.rs", |
| "src/data_structures/socketmap.rs", |
| "src/data_structures/token_bucket.rs", |
| "src/device/arp.rs", |
| "src/device/ethernet.rs", |
| "src/device/link.rs", |
| "src/device/loopback.rs", |
| "src/device/mod.rs", |
| "src/device/ndp.rs", |
| "src/device/state.rs", |
| "src/error.rs", |
| "src/fuzz.rs", |
| "src/ip/device/dad.rs", |
| "src/ip/device/integration.rs", |
| "src/ip/device/mod.rs", |
| "src/ip/device/route_discovery.rs", |
| "src/ip/device/router_solicitation.rs", |
| "src/ip/device/slaac.rs", |
| "src/ip/device/state.rs", |
| "src/ip/forwarding.rs", |
| "src/ip/gmp/igmp.rs", |
| "src/ip/gmp/mld.rs", |
| "src/ip/gmp/mod.rs", |
| "src/ip/icmp.rs", |
| "src/ip/integration.rs", |
| "src/ip/ipv6.rs", |
| "src/ip/mod.rs", |
| "src/ip/path_mtu.rs", |
| "src/ip/reassembly.rs", |
| "src/ip/socket.rs", |
| "src/ip/types.rs", |
| "src/lib.rs", |
| "src/macros.rs", |
| "src/socket/mod.rs", |
| "src/socket/posix.rs", |
| "src/testutil.rs", |
| "src/transport/mod.rs", |
| "src/transport/tcp/buffer.rs", |
| "src/transport/tcp/mod.rs", |
| "src/transport/tcp/rtt.rs", |
| "src/transport/tcp/segment.rs", |
| "src/transport/tcp/seqnum.rs", |
| "src/transport/tcp/socket/demux.rs", |
| "src/transport/tcp/socket/icmp.rs", |
| "src/transport/tcp/socket/isn.rs", |
| "src/transport/tcp/socket/mod.rs", |
| "src/transport/tcp/state.rs", |
| "src/transport/udp.rs", |
| ] |
| |
| lib_deps = [ |
| # TODO(https://github.com/rust-lang-nursery/portability-wg/issues/11): |
| # remove this module. |
| "fakealloc", |
| |
| # TODO(https://github.com/dtolnay/thiserror/pull/64): remove this module. |
| "fakestd", |
| "//src/connectivity/lib/internet-checksum", |
| "//src/connectivity/lib/net-declare", |
| "//src/connectivity/lib/net-types", |
| "//src/connectivity/lib/packet-formats", |
| "//src/connectivity/network/lib/explicit", |
| "//src/connectivity/network/lib/todo_unused", |
| "//src/connectivity/network/netstack3/core/specialize-ip-macro", |
| "//src/lib/const-unwrap", |
| "//src/lib/mundane", |
| "//src/lib/network/packet", |
| "//src/lib/zerocopy", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:assert_matches", |
| "//third_party/rust_crates:derivative", |
| "//third_party/rust_crates:either", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:nonzero_ext", |
| "//third_party/rust_crates:num", |
| "//third_party/rust_crates:rand", |
| "//third_party/rust_crates:rand_xorshift", |
| "//third_party/rust_crates:siphasher", |
| "//third_party/rust_crates:smallvec", |
| "//third_party/rust_crates:thiserror", |
| ] |
| |
| lib_test_deps = [ |
| "proptest-support", |
| "teststd", |
| "//src/connectivity/lib/net-declare", |
| "//third_party/rust_crates:assert_matches", |
| "//third_party/rust_crates:itertools", |
| "//third_party/rust_crates:proptest", |
| "//third_party/rust_crates:test-case", |
| ] |
| |
| rustc_library("netstack3-core") { |
| name = "netstack3_core" |
| version = "0.1.0" |
| edition = "2021" |
| with_unit_tests = true |
| |
| configs -= [ "//build/config/rust:no_features" ] |
| configs += [ "//build/config/rust:netstack3_only_specialization_feature" ] |
| |
| deps = lib_deps |
| |
| test_deps = lib_test_deps |
| sources = lib_sources |
| |
| configs -= [ "//build/config/rust:allow_unused_results" ] |
| } |
| |
| fuchsia_unittest_package("netstack3-core-test-package") { |
| package_name = "netstack3-core-test" |
| deps = [ ":netstack3-core_test" ] |
| } |
| |
| config("benchmark") { |
| rustflags = [ |
| "--cfg=benchmark", |
| "--cfg=test", |
| ] |
| } |
| |
| rustc_library("netstack3-core-benchmarks") { |
| name = "netstack3_core_benchmarks" |
| edition = "2021" |
| testonly = true |
| with_unit_tests = true |
| sources = lib_sources |
| deps = lib_deps + lib_test_deps + [ "//third_party/rust_crates:criterion" ] |
| configs -= [ "//build/config/rust:allow_unused_results" ] |
| configs -= [ "//build/config/rust:no_features" ] |
| configs += [ "//build/config/rust:netstack3_only_specialization_feature" ] |
| configs += [ ":benchmark" ] |
| } |
| |
| config("fuzz") { |
| rustflags = [ |
| "--cfg=fuzz", |
| "--cfg=test", |
| ] |
| } |
| |
| rustc_fuzzer("fuzz-single-device") { |
| edition = "2021" |
| rustfunction = "single_device_arbitrary_packets" |
| |
| sources = lib_sources |
| deps = lib_deps + lib_test_deps + [ |
| "//src/connectivity/lib/net-declare", |
| "//src/connectivity/lib/net-types", |
| "//src/connectivity/lib/fuzz-util", |
| "//src/lib/network/packet", |
| "//third_party/rust_crates:arbitrary", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:lazy_static", |
| ] |
| |
| features = [ |
| # Logging is turned off by default so that the fuzzer can run faster. It can |
| # be enabled to be included in the output the fuzzer prints (only on |
| # failure) by enabling any of the following features. Enabling multiple is |
| # equivalent to enabling the most verbose. |
| # "log_trace" |
| # "log_debug" |
| # "log_info" |
| ] |
| |
| configs -= [ "//build/config/rust:allow_unused_results" ] |
| configs -= [ "//build/config/rust:no_features" ] |
| configs += [ "//build/config/rust:netstack3_only_specialization_feature" ] |
| configs += [ ":fuzz" ] |
| } |
| |
| fuzzers_package("netstack3-core-fuzzers") { |
| rust_fuzzers = [ ":fuzz-single-device" ] |
| fuzz_host = true |
| } |
| |
| group("tests") { |
| testonly = true |
| public_deps = [ |
| ":netstack3-core-fuzzers", |
| ":netstack3-core-test-package", |
| ":netstack3-core_test($host_toolchain)", |
| "specialize-ip-macro:tests", |
| ] |
| } |