dart-sdk/BUILD.gn
Daco Harkes 9f96aeda6f [test/ffi] Add C++ unit tests for all target ABIs
This CL introduces unit tests for the Native* classes in compiler/ffi
that can run for all supported target ABIs on any host architecture.

The unit tests are compiled for all target ABIs with
`tools/build.py run_ffi_unit_tests` and run for all target ABIs with
`tools/test.py ffi_unit`.

The unit test and tested code do not conceptually depend on having a
DartVM. The tests are compiled with a custom `dart::Zone` and
`platform/`. This enables compiling for all `TARGET_ARCH_*` and
`TARGET_OS_*` on any host, and running unit tests for all target ABIs
on any host.

Because the `run_ffi_unit_tests` executables do not include the DartVM
their build is quick (<10seconds) and they are small (~6MB) when
compared to `run_vm_tests` (~250MB).

The tests are added to the existing FFI QEMU bot to prevent adding an
extra bot which would add checkout overhead.

The unit tests themselves are set up to be fairly similar to vm/cc
tests. The only difference is the NativeCallingConvention tests which
are set up with `.expect` files for easy inspection and updating.

TEST=runtime/vm/compiler/ffi/native_calling_convention_test.cc
TEST=runtime/vm/compiler/ffi/native_location_test.cc
TEST=runtime/vm/compiler/ffi/native_type_test.cc

Change-Id: I7b8bf4de9ef070e7546472217e571a60362b9639
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171725
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2020-11-16 16:10:55 +00:00

220 lines
5.2 KiB
Plaintext

# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
# for details. 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/gclient_args.gni")
import("sdk_args.gni")
targetting_fuchsia = target_os == "fuchsia"
# This target will be built if no target is specified when invoking ninja.
group("default") {
if (targetting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [ ":runtime" ]
if (defined(checkout_llvm) && checkout_llvm) {
deps += [ ":llvm_codegen" ]
}
}
group("most") {
import("runtime/runtime_args.gni")
if (targetting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [
":create_sdk",
":dart2js",
":dartanalyzer",
":dartdevc",
":runtime",
":samples",
]
if (dart_target_arch != "arm") {
deps += [ ":analysis_server" ]
}
}
group("runtime") {
import("runtime/runtime_args.gni")
if (targetting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [
"runtime/bin:dart",
"runtime/bin:entrypoints_verification_test_extension",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
"runtime/bin:process_test",
"runtime/bin:run_vm_tests",
"runtime/bin:sample_extension",
"runtime/bin:test_extension",
"runtime/vm:kernel_platform_files($host_toolchain)",
"utils/kernel-service:kernel-service",
]
# TODO(bkonyi): this dep causes a segfault on Android XARM_X64 builds.
# See issue #41776.
if (dart_target_arch != "arm") {
deps += [
"utils/dartdev:dartdev",
"utils/dds:dds",
]
}
}
# A separate target and not included in group("runtime"). This way the target\
# "runtime" does not get many executables extra as build output.
group("run_ffi_unit_tests") {
deps = [ "runtime/bin/ffi_unit_test:run_ffi_unit_tests" ]
}
group("runtime_kernel") {
if (targetting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [ ":runtime" ]
}
group("runtime_precompiled") {
deps = [
"runtime/bin:dart_precompiled_runtime",
"runtime/bin:process_test",
]
}
group("create_sdk") {
public_deps = [ "sdk:create_sdk" ]
}
group("create_platform_sdk") {
public_deps = [ "sdk:create_platform_sdk" ]
}
group("dart2js") {
deps = [ "utils/compiler:dart2js" ]
}
group("dartanalyzer") {
deps = [ "utils/dartanalyzer" ]
}
group("dartdevc") {
deps = [ "utils/dartdevc" ]
}
group("dartfmt") {
deps = [ "utils/dartfmt" ]
}
group("analysis_server") {
deps = [ "utils/analysis_server" ]
}
group("check_llvm") {
if (defined(checkout_llvm) && checkout_llvm) {
deps = [ "runtime/llvm_codegen/test" ]
}
}
group("llvm_codegen") {
if (defined(checkout_llvm) && checkout_llvm) {
deps = [
"runtime/llvm_codegen/bit",
"runtime/llvm_codegen/codegen",
]
}
}
# This is the target that is built on the dart2js build bots.
# It must depend on anything that is required by the dart2js
# test suites.
group("dart2js_bot") {
deps = [ ":create_sdk" ]
}
group("samples") {
deps = [ "runtime/bin:sample_extension" ]
}
# This rule and the compressed_observatory_archive rule are for the Fuchsia
# bots that pre-build the Observatory. They copy the observatory tar files to
# the root build output directory for convenient access by the Fuchsia buildbot
# scripts.
group("observatory_archive") {
deps = [ "runtime/observatory:copy_observatory_archive" ]
}
group("compressed_observatory_archive") {
deps = [ "runtime/observatory:copy_compressed_observatory_archive" ]
}
if (is_fuchsia) {
import("third_party/fuchsia/sdk/linux/build/component.gni")
import("third_party/fuchsia/sdk/linux/build/package.gni")
fuchsia_component("fuchsia_test_component") {
testonly = true
data_deps = [ "runtime/bin:dart" ]
manifest = "build/fuchsia/dart.cmx"
resource_files = [
".dart_tool/package_config.json",
"pkg/testing/test/hello_test.dart",
"tools/addlatexhash.dart",
]
resource_dirs = [
"tests/standalone_2",
"pkg/async_helper",
"pkg/expect",
"pkg/meta",
"pkg/native_stack_traces",
"pkg/smith",
"third_party/pkg/args",
"third_party/pkg/async",
"third_party/pkg/charcode",
"third_party/pkg/collection",
"third_party/pkg/convert",
"third_party/pkg/crypto",
"third_party/pkg/http",
"third_party/pkg/http_parser",
"third_party/pkg/path",
"third_party/pkg/pool",
"third_party/pkg/stack_trace",
"third_party/pkg/string_scanner",
"third_party/pkg/typed_data",
]
resources = []
foreach(file, resource_files) {
resources += [
{
path = file
dest = "data/" + file
},
]
}
resources +=
exec_script("tools/fuchsia/find_resources.py", resource_dirs, "json")
}
fuchsia_package("fuchsia_test_package") {
package_name = "dart_test_"
if (is_debug) {
package_name += "debug"
} else if (is_release) {
package_name += "release"
} else if (is_product) {
package_name += "product"
}
testonly = true
deps = [ ":fuchsia_test_component" ]
}
}