| # Copyright 2020 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. |
| |
| ########################################## |
| # Though under //zircon, this build file # |
| # is meant to be used in the Fuchsia GN # |
| # build. # |
| # See fxbug.dev/36139. # |
| ########################################## |
| |
| import("//build/test.gni") |
| import("//build/test/test_package.gni") |
| import("//build/testing/host_test_data.gni") |
| |
| assert(!defined(zx) || zx != "/", |
| "This file can only be used in the Fuchsia GN build.") |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":zbitl-test-package", |
| ":zbitl-unittests($host_toolchain)", |
| ] |
| } |
| |
| # Test data ZBIs created by data/gen.py. |
| test_data_zbis = [ |
| "data/empty.zbi", |
| "data/one-item.zbi", |
| "data/compressed-item.zbi", |
| "data/bad-crc-item.zbi", |
| "data/multiple-small-items.zbi", |
| "data/second-item-on-page-boundary.zbi", |
| ] |
| |
| if (is_host) { |
| host_test_data("host-test-data") { |
| sources = test_data_zbis |
| outputs = [ "$root_out_dir/test_data/zbitl/{{source_file_part}}" ] |
| } |
| } |
| |
| # We define a translation unit per (src, dest) storage type pair, which |
| # parametrize the tests for the copy APIs. The number of test cases is subject |
| # to combinatorial explosion and in putting all such cases in a single TU we |
| # see a significant build bottleneck arise, as well as stack overflow for |
| # certain instrumentation and optimization levels (due to the global |
| # constructors defined by the zxtest framework). |
| # |
| # For each storage type, we expect <type>TestTraits to coincide with the name |
| # of its associated test traits type. |
| src_storage_types = [ |
| "String", |
| "ByteView", |
| "FblByteArray", |
| "Fd", |
| "Stdio", |
| ] |
| if (is_fuchsia) { |
| src_storage_types += [ |
| "Vmo", |
| "UnownedVmo", |
| "MapOwnedVmo", |
| "MapUnownedVmo", |
| ] |
| } |
| dest_storage_types = src_storage_types - [ # Non-writable types. |
| "String", |
| "ByteView", |
| ] |
| |
| copy_test_deps = [] |
| foreach(src, src_storage_types) { |
| foreach(dest, dest_storage_types) { |
| source_set_name = "copy_tests.${src}-to-${dest}" |
| source_set(source_set_name) { |
| testonly = true |
| sources = [ "copy-tests.cc" ] |
| deps = [ |
| "//third_party/googletest:gtest", |
| "//zircon/system/ulib/zbitl", |
| "//zircon/system/ulib/zircon", |
| ] |
| defines = [ |
| "SRC_STORAGE_TYPE=${src}", |
| "DEST_STORAGE_TYPE=${dest}", |
| ] |
| } |
| copy_test_deps += [ ":${source_set_name}" ] |
| } |
| } |
| |
| test("zbitl-unittests") { |
| sources = [ |
| "checking-tests.cc", |
| "fd-tests.cc", |
| "json-tests.cc", |
| "mem_config_test.cc", |
| "memory-tests.cc", |
| "stdio-tests.cc", |
| "tests.cc", |
| "view-tests.cc", |
| ] |
| deps = [ |
| "$zx/kernel/lib/efi", |
| "//src/lib/files", |
| "//src/lib/fxl", |
| "//src/lib/fxl/test:gtest_main", |
| "//third_party/googletest:gmock", |
| "//third_party/googletest:gtest", |
| "//zircon/system/ulib/zbitl", |
| |
| # TODO(fxbug.dev/57392): Move it back to //third_party once unification completes. |
| "//zircon/third_party/rapidjson", |
| ] |
| deps += copy_test_deps |
| |
| if (is_fuchsia) { |
| sources += [ "vmo-tests.cc" ] |
| configs += [ "//build/unification/config:zircon-migrated" ] |
| } else if (is_host) { |
| deps += [ ":host-test-data" ] |
| } |
| } |
| |
| test_package("zbitl-test-package") { |
| package_name = "zbitl-tests" |
| deps = [ ":zbitl-unittests" ] |
| |
| tests = [ |
| { |
| name = "zbitl-unittests" |
| }, |
| ] |
| |
| resources = [] |
| foreach(zbi, test_data_zbis) { |
| resources += [ |
| { |
| path = zbi |
| dest = get_path_info(zbi, "file") |
| }, |
| ] |
| } |
| } |