blob: ff5aa3508c3c65874d2b976cc6304b16be860798 [file] [log] [blame]
# 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_binary.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_test.gni")
_common_sources = [
# keep-sorted start
"src/bti.rs",
"src/channel/io_slice.rs",
"src/channel/message_buf.rs",
"src/channel/mod.rs",
"src/clock.rs",
"src/clock_update.rs",
"src/counter.rs",
"src/cprng.rs",
"src/debuglog.rs",
"src/event.rs",
"src/eventpair.rs",
"src/exception.rs",
"src/fifo.rs",
"src/futex.rs",
"src/guest.rs",
"src/handle.rs",
"src/info.rs",
"src/interrupt.rs",
"src/iob.rs",
"src/iob/io_slice.rs",
"src/iommu.rs",
"src/job.rs",
"src/lib.rs",
"src/macros.rs",
"src/name.rs",
"src/pager.rs",
"src/pmt.rs",
"src/port.rs",
"src/process.rs",
"src/profile.rs",
"src/property.rs",
"src/resource.rs",
"src/rights.rs",
"src/signals.rs",
"src/socket.rs",
"src/stream.rs",
"src/system.rs",
"src/task.rs",
"src/thread.rs",
"src/time.rs",
"src/vcpu.rs",
"src/version.rs",
"src/vmar.rs",
"src/vmo.rs",
"src/wait.rs",
# keep-sorted end
]
_common_deps = [
"//sdk/rust/zx-status",
"//third_party/rust_crates:bitflags",
"//third_party/rust_crates:bstr",
"//third_party/rust_crates:libc",
"//third_party/rust_crates:static_assertions",
"//third_party/rust_crates:zerocopy",
"//zircon/vdso:zx-sys",
]
_common_test_deps = [
":zx",
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_rust",
"//src/lib/fdio/rust:fdio",
"//src/lib/fuchsia",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-runtime",
"//third_party/rust_crates:assert_matches",
"//third_party/rust_crates:test-case",
]
if (is_fuchsia) {
rustc_library("zx") {
edition = "2021"
sources = _common_sources
deps = _common_deps
}
}
# Certain tests written as unit tests of fuchsia-zircon make use of other
# crates which themselves depend on fuchsia-zircon. This causes
# zx::foo to be a different type from crate::foo in the context of
# those unit tests when fuchsia-zircon is built with `with_unit_tests = true`.
#
# Since those tests are really integration tests, we should either move them
# into the "other" crates so that the dependency graph flows in only one
# direction, or simply move those tests into a dedicated target and redesignate
# them as integration tests, which they appear to be.
#
# TODO(https://fxbug.dev/42173139): untangle this web.
rustc_test("zx-unittests") {
edition = "2021"
output_name = "zx_tests"
sources = _common_sources
deps = _common_deps + _common_test_deps
}
rustc_test("zx-next-unittests") {
edition = "2021"
output_name = "zx_next_tests"
sources = _common_sources
deps = _common_deps + _common_test_deps
features = [ "vdso_next" ]
}
fuchsia_unittest_component("zx-tests-component") {
component_name = "zx-tests"
manifest = "meta/zx_tests.cml"
deps = [ ":zx-unittests" ]
test_type = "system"
}
fuchsia_unittest_component("zx-next-tests-component") {
component_name = "zx-next-tests"
manifest = "meta/zx_next_tests.cml"
deps = [ ":zx-next-unittests" ]
test_type = "system"
}
fuchsia_test_package("zx-tests") {
test_components = [
":zx-tests-component",
":zx-next-tests-component",
]
deps = [
"//src/testing/zx-test-util:exit_with_code_util",
"//src/testing/zx-test-util:sleep_forever_util",
]
if (current_cpu == "riscv64") {
# TODO(https://fxbug.dev/42081270): Remove this once
# version::tests::get_version_string passes on RISC-V.
test_specs = {
environments = []
}
}
}
group("tests") {
testonly = true
deps = [ ":zx-tests" ]
}