|  | # 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/package.gni") | 
|  | import("//build/test/test_package.gni") | 
|  | import("//build/testing/environments.gni") | 
|  | import("//src/virtualization/buildtools/linux_paths.gni") | 
|  | import("//src/virtualization/buildtools/romfs_image.gni") | 
|  |  | 
|  | # Packages required to run the guest integration tests. | 
|  | guest_packages = [ | 
|  | "//src/virtualization/bin", | 
|  | "//src/virtualization/packages", | 
|  | ] | 
|  |  | 
|  | # TODO(fxbug.dev/50820): Fix on ASan and switch back to [ nuc_env ]. | 
|  | guest_environments = nuc_env_fails_on_asan + [ | 
|  | sherlock_env, | 
|  | vim3_env, | 
|  | ] | 
|  |  | 
|  | linux_tests_label = "//src/virtualization/packages/debian_guest:tests" | 
|  | linux_tests_resources = [ | 
|  | { | 
|  | path = get_label_info(linux_tests_label, "target_out_dir") + | 
|  | "/debian/tests.img" | 
|  | dest = "linux_tests.img" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | group("tests") { | 
|  | testonly = true | 
|  | deps = [ | 
|  | ":guest_unit_tests", | 
|  | ":hypervisor_tests_pkg", | 
|  | ":virtualization_block_tests_pkg", | 
|  | ":virtualization_core_tests_pkg", | 
|  | ":virtualization_net_tests_pkg", | 
|  | ":virtualization_vsock_tests_pkg", | 
|  | ] | 
|  |  | 
|  | # TODO(fxbug.dev/12616): These tests currently do not work on arm64. | 
|  | if (current_cpu == "x64") { | 
|  | deps += [ | 
|  | # TODO(fxbug.dev/64348): These tests needs to be reworked so that they | 
|  | # interact correctly with Scenic. | 
|  | # ":virtualization_gpu_tests_pkg", | 
|  | # ":virtualization_input_tests_pkg", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # Ensure guest packages are available in the manifest. | 
|  | data_deps = guest_packages | 
|  | } | 
|  |  | 
|  | source_set("logger") { | 
|  | visibility = [ ":*" ] | 
|  | sources = [ | 
|  | "logger.cc", | 
|  | "logger.h", | 
|  | ] | 
|  | configs += [ | 
|  | # TODO(fxbug.dev/58162): delete the below and fix compiler warnings | 
|  | "//build/config:Wno-conversion", | 
|  | ] | 
|  | } | 
|  |  | 
|  | source_set("guest_console") { | 
|  | visibility = [ | 
|  | "//src/connectivity/network/testing/netemul/*", | 
|  | "//src/virtualization/*", | 
|  | ] | 
|  | sources = [ | 
|  | "guest_console.cc", | 
|  | "guest_console.h", | 
|  | "socket.cc", | 
|  | "socket.h", | 
|  | ] | 
|  | deps = [ | 
|  | "//sdk/fidl/fuchsia.virtualization", | 
|  | "//src/lib/fxl", | 
|  | ] | 
|  | public_deps = [ | 
|  | ":logger", | 
|  | "//zircon/public/lib/zx", | 
|  | ] | 
|  | } | 
|  |  | 
|  | source_set("fake_netstack") { | 
|  | visibility = [ | 
|  | "//src/connectivity/network/testing/netemul/*", | 
|  | "//src/virtualization/*", | 
|  | ] | 
|  | sources = [ | 
|  | "fake_netstack.cc", | 
|  | "fake_netstack.h", | 
|  | ] | 
|  | deps = [ | 
|  | "//sdk/fidl/fuchsia.netstack", | 
|  | "//src/lib/inet", | 
|  | "//zircon/public/lib/fit", | 
|  | "//zircon/system/ulib/async:async-cpp", | 
|  | "//zircon/system/ulib/async-loop:async-loop-cpp", | 
|  | "//zircon/system/ulib/async-loop:async-loop-default", | 
|  | ] | 
|  | public_deps = [ "//sdk/fidl/fuchsia.netstack" ] | 
|  |  | 
|  | # TODO(fxbug.dev/58162): delete the below and fix compiler warnings | 
|  | configs += [ "//build/config:Wno-conversion" ] | 
|  | } | 
|  |  | 
|  | source_set("fake_scenic") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  | sources = [ | 
|  | "fake_scenic.cc", | 
|  | "fake_scenic.h", | 
|  | ] | 
|  |  | 
|  | deps = [ | 
|  | "//garnet/public/lib/fostr/fidl/fuchsia.ui.gfx", | 
|  | "//garnet/public/lib/fostr/fidl/fuchsia.ui.scenic", | 
|  | "//src/lib/fxl", | 
|  | ] | 
|  | public_deps = [ "//sdk/fidl/fuchsia.ui.scenic" ] | 
|  | } | 
|  |  | 
|  | executable("unit_tests") { | 
|  | testonly = true | 
|  | output_name = "guest_unit_tests" | 
|  | sources = [ "guest_console_test.cc" ] | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | "//src/lib/fxl/test:gtest_main", | 
|  | "//third_party/googletest:gtest", | 
|  | ] | 
|  | } | 
|  |  | 
|  | source_set("test_main") { | 
|  | testonly = true | 
|  | visibility = [ ":*" ] | 
|  | sources = [ "test_main.cc" ] | 
|  | deps = [ | 
|  | ":logger", | 
|  | "//src/lib/fxl/test:test_settings", | 
|  | "//third_party/googletest:gtest", | 
|  | ] | 
|  | } | 
|  |  | 
|  | source_set("lib") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  | sources = [ | 
|  | "enclosed_guest.cc", | 
|  | "enclosed_guest.h", | 
|  | "guest_test.h", | 
|  | "periodic_logger.cc", | 
|  | "periodic_logger.h", | 
|  | ] | 
|  |  | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | "//sdk/fidl/fuchsia.kernel", | 
|  | "//sdk/fidl/fuchsia.sysinfo", | 
|  | ] | 
|  | public_deps = [ | 
|  | ":fake_netstack", | 
|  | ":fake_scenic", | 
|  | "//sdk/lib/sys/cpp/testing:integration", | 
|  | "//src/virtualization/lib/grpc", | 
|  | "//src/virtualization/lib/vsh:client", | 
|  | "//src/virtualization/packages/biscotti_guest/third_party/protos:vm_cc_proto", | 
|  | "//zircon/public/lib/async-cpp", | 
|  | "//zircon/system/ulib/async-loop:async-loop-cpp", | 
|  | "//zircon/system/ulib/async-loop:async-loop-default", | 
|  | ] | 
|  | } | 
|  |  | 
|  | unittest_package("guest_unit_tests") { | 
|  | deps = [ ":unit_tests" ] | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "guest_unit_tests" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("virtualization_core_tests") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  |  | 
|  | sources = [ "core_tests.cc" ] | 
|  |  | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | ":lib", | 
|  | ":test_main", | 
|  | "//third_party/googletest:gmock", | 
|  | ] | 
|  | } | 
|  |  | 
|  | test_package("virtualization_core_tests_pkg") { | 
|  | package_name = "virtualization-core-tests" | 
|  |  | 
|  | deps = [ | 
|  | ":virtualization_core_tests", | 
|  | linux_tests_label, | 
|  | ] | 
|  | data_deps = guest_packages | 
|  | resources = linux_tests_resources | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "virtualization_core_tests" | 
|  | environments = guest_environments | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("virtualization_block_tests") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  |  | 
|  | sources = [ "virtio_block_tests.cc" ] | 
|  |  | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | ":lib", | 
|  | ":test_main", | 
|  | "//src/virtualization/bin/vmm/device:qcow_test_data", | 
|  | "//third_party/googletest:gmock", | 
|  | ] | 
|  | } | 
|  |  | 
|  | test_package("virtualization_block_tests_pkg") { | 
|  | package_name = "virtualization-block-tests" | 
|  |  | 
|  | deps = [ | 
|  | ":virtualization_block_tests", | 
|  | linux_tests_label, | 
|  | ] | 
|  | data_deps = guest_packages | 
|  | resources = linux_tests_resources | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "virtualization_block_tests" | 
|  | environments = guest_environments | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("virtualization_gpu_tests") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  |  | 
|  | sources = [ "virtio_gpu_tests.cc" ] | 
|  |  | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | ":lib", | 
|  | ":test_main", | 
|  | "//third_party/googletest:gmock", | 
|  | ] | 
|  | } | 
|  |  | 
|  | test_package("virtualization_gpu_tests_pkg") { | 
|  | package_name = "virtualization-gpu-tests" | 
|  |  | 
|  | deps = [ | 
|  | ":virtualization_gpu_tests", | 
|  | linux_tests_label, | 
|  | ] | 
|  | data_deps = guest_packages | 
|  | resources = linux_tests_resources | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "virtualization_gpu_tests" | 
|  | environments = guest_environments | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("virtualization_input_tests") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  |  | 
|  | sources = [ "virtio_input_tests.cc" ] | 
|  |  | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | ":lib", | 
|  | ":test_main", | 
|  | ] | 
|  | } | 
|  |  | 
|  | test_package("virtualization_input_tests_pkg") { | 
|  | package_name = "virtualization-input-tests" | 
|  |  | 
|  | deps = [ | 
|  | ":virtualization_input_tests", | 
|  | linux_tests_label, | 
|  | ] | 
|  | data_deps = guest_packages | 
|  | resources = linux_tests_resources | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "virtualization_input_tests" | 
|  | environments = guest_environments | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("virtualization_net_tests") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  |  | 
|  | sources = [ "virtio_net_tests.cc" ] | 
|  |  | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | ":lib", | 
|  | ":test_main", | 
|  | "//src/lib/inet", | 
|  | "//third_party/googletest:gmock", | 
|  | ] | 
|  | } | 
|  |  | 
|  | test_package("virtualization_net_tests_pkg") { | 
|  | package_name = "virtualization-net-tests" | 
|  |  | 
|  | deps = [ | 
|  | ":virtualization_net_tests", | 
|  | linux_tests_label, | 
|  | ] | 
|  | data_deps = guest_packages | 
|  | resources = linux_tests_resources | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "virtualization_net_tests" | 
|  | environments = guest_environments | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("virtualization_vsock_tests") { | 
|  | visibility = [ ":*" ] | 
|  | testonly = true | 
|  |  | 
|  | sources = [ "virtio_vsock_tests.cc" ] | 
|  |  | 
|  | deps = [ | 
|  | ":guest_console", | 
|  | ":lib", | 
|  | ":test_main", | 
|  | "//third_party/googletest:gmock", | 
|  | ] | 
|  | } | 
|  |  | 
|  | test_package("virtualization_vsock_tests_pkg") { | 
|  | package_name = "virtualization-vsock-tests" | 
|  |  | 
|  | deps = [ | 
|  | ":virtualization_vsock_tests", | 
|  | linux_tests_label, | 
|  | ] | 
|  | data_deps = guest_packages | 
|  | resources = linux_tests_resources | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "virtualization_vsock_tests" | 
|  | environments = guest_environments | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | package("virtualization_test_utils_pkg") { | 
|  | package_name = "virtualization-test-utils" | 
|  |  | 
|  | deps = [ | 
|  | "virtio_block_test_util", | 
|  | "virtio_net_test_util", | 
|  | "virtio_rng_test_util", | 
|  | "virtio_vsock_test_util", | 
|  | ] | 
|  |  | 
|  | meta = [ | 
|  | { | 
|  | path = | 
|  | rebase_path("virtio_block_test_util/meta/virtio_block_test_util.cmx") | 
|  | dest = "virtio_block_test_util.cmx" | 
|  | }, | 
|  | { | 
|  | path = rebase_path("virtio_rng_test_util/meta/virtio_rng_test_util.cmx") | 
|  | dest = "virtio_rng_test_util.cmx" | 
|  | }, | 
|  | { | 
|  | path = rebase_path("virtio_net_test_util/meta/virtio_net_test_util.cmx") | 
|  | dest = "virtio_net_test_util.cmx" | 
|  | }, | 
|  | { | 
|  | path = | 
|  | rebase_path("virtio_vsock_test_util/meta/virtio_vsock_test_util.cmx") | 
|  | dest = "virtio_vsock_test_util.cmx" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | binaries = [ | 
|  | { | 
|  | name = "virtio_block_test_util" | 
|  | }, | 
|  | { | 
|  | name = "virtio_net_test_util" | 
|  | }, | 
|  | { | 
|  | name = "virtio_rng_test_util" | 
|  | }, | 
|  | { | 
|  | name = "virtio_vsock_test_util" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | executable("hypervisor_tests") { | 
|  | sources = [ | 
|  | "hypervisor_tests.cc", | 
|  | "hypervisor_tests_${target_cpu}.S", | 
|  | "hypervisor_tests_constants.h", | 
|  | ] | 
|  |  | 
|  | deps = [ | 
|  | "//sdk/fidl/fuchsia.kernel", | 
|  | "//sdk/fidl/fuchsia.sysinfo", | 
|  | "//sdk/lib/fdio", | 
|  | "//zircon/public/lib/fbl", | 
|  | "//zircon/public/lib/zx", | 
|  | "//zircon/public/lib/zxtest", | 
|  | ] | 
|  |  | 
|  | # TODO(fxbug.dev/58162): delete the below and fix compiler warnings | 
|  | configs += [ "//build/config:Wno-conversion" ] | 
|  | } | 
|  |  | 
|  | test_package("hypervisor_tests_pkg") { | 
|  | package_name = "hypervisor-tests-pkg" | 
|  |  | 
|  | deps = [ ":hypervisor_tests" ] | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "hypervisor_tests" | 
|  | environments = [ | 
|  | astro_env, | 
|  | emu_env, | 
|  | nelson_env, | 
|  | nuc_env, | 
|  | sherlock_env, | 
|  | vim3_env, | 
|  | ] | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | icd_filename = "libvulkan_intel.so" | 
|  | icd_manifest = "${target_gen_dir}/magma.json" | 
|  |  | 
|  | action("icd_manifest") { | 
|  | visibility = [ ":*" ] | 
|  | script = "//src/graphics/lib/magma/scripts/gen_icd_manifest.sh" | 
|  | args = [ | 
|  | "${icd_filename}", | 
|  | rebase_path(icd_manifest, root_build_dir), | 
|  | ] | 
|  | outputs = [ icd_manifest ] | 
|  | } | 
|  |  | 
|  | romfs_image("extras") { | 
|  | testonly = true | 
|  |  | 
|  | deps = [ | 
|  | ":icd_manifest", | 
|  | "//src/graphics/lib/magma/tests/integration:virtmagma_abi_conformance_tests(${linux_exe_toolchain})", | 
|  | "//src/graphics/lib/magma/tests_linux/unit_tests:virtmagma_unit_tests_linux(${linux_exe_toolchain})", | 
|  | "//src/graphics/lib/magma/tests_linux/unit_tests:virtmagma_vulkan_unit_tests(${linux_exe_toolchain})", | 
|  | "//src/lib/vulkan:vulkan_headers_and_loader(${linux_lib_toolchain})", | 
|  | ] | 
|  |  | 
|  | inputs = [ | 
|  | "${icd_manifest}", | 
|  | "${linux_lib_path}/libvulkan.so",  # Vulkan Loader | 
|  | "${linux_exe_path}/virtmagma_unit_tests_linux", | 
|  | "${linux_exe_path}/virtmagma_vulkan_unit_tests", | 
|  | "${linux_exe_path}/virtmagma_abi_conformance_tests", | 
|  | ] | 
|  |  | 
|  | if (current_cpu == "x64") { | 
|  | deps += [ "//third_party/mesa/src/intel/vulkan:vulkan_intel(${linux_lib_toolchain})" ] | 
|  |  | 
|  | inputs += [ "${linux_lib_path}/${icd_filename}" ] | 
|  | } | 
|  |  | 
|  | output = "$target_out_dir/linux/extras.img" | 
|  | } | 
|  |  | 
|  | # This should be merged into |guest_integration_tests| once the termina guest is stable in CQ. | 
|  | executable("termina_integration_tests_bin") { | 
|  | visibility = [ ":*" ] | 
|  | output_name = "termina_integration_tests" | 
|  | testonly = true | 
|  |  | 
|  | sources = [ | 
|  | "virtio_magma_tests.cc", | 
|  | "virtio_wl_tests.cc", | 
|  | ] | 
|  |  | 
|  | deps = [ | 
|  | ":lib", | 
|  | ":test_main", | 
|  | "//third_party/googletest:gtest", | 
|  | ] | 
|  | } | 
|  |  | 
|  | group("termina") { | 
|  | testonly = true | 
|  | deps = guest_packages | 
|  | deps += [ ":termina_integration_tests" ] | 
|  | } | 
|  |  | 
|  | test_package("termina_integration_tests") { | 
|  | deps = [ | 
|  | ":extras", | 
|  | ":termina_integration_tests_bin", | 
|  | linux_tests_label, | 
|  | ] | 
|  |  | 
|  | resources = [ | 
|  | { | 
|  | path = get_label_info(linux_tests_label, "target_out_dir") + | 
|  | "/debian/tests.img" | 
|  | dest = "linux_tests.img" | 
|  | }, | 
|  | { | 
|  | path = "$target_out_dir/linux/extras.img" | 
|  | dest = "extras.img" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | tests = [ | 
|  | { | 
|  | name = "termina_integration_tests" | 
|  | environments = [ nuc_env ] | 
|  | }, | 
|  | ] | 
|  | } |