| # Copyright 2019 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/dist/resource.gni") |
| import("//build/test.gni") |
| import("//build/testing/zbi_test.gni") |
| import("//build/testing/zbi_test_success.gni") |
| import("//build/zbi/zbi_input.gni") |
| |
| executable("bootsvc-integration-test") { |
| if (is_fuchsia) { |
| configs += [ "//build/unification/config:zircon-migrated" ] |
| } |
| if (is_fuchsia) { |
| fdio_config = [ "//build/config/fuchsia:fdio_config" ] |
| if (configs + fdio_config - fdio_config != configs) { |
| configs -= fdio_config |
| } |
| } |
| |
| testonly = true |
| defines = [ "ZBI_TEST_SUCCESS_STRING=\"$zbi_test_success_string\"" ] |
| sources = [ "integration-test.cc" ] |
| deps = [ |
| "..:util", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_c", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_llcpp", |
| "//sdk/lib/fdio", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/safemath", |
| "//zircon/public/lib/zx", |
| "//zircon/public/lib/zxtest", |
| ] |
| |
| # TODO(fxbug.dev/69585): This target uses raw zx::channel with LLCPP which is deprecated. |
| # Please migrate to typed channel APIs (fidl::ClientEnd<T>, fidl::ServerEnd<T>). |
| # See linked bug for details. |
| configs += [ "//build/cpp:fidl-llcpp-deprecated-raw-channels" ] |
| } |
| |
| # This collects all the runtime dependencies of bootsvc-integration-test, |
| # to bring them into a test ZBI. |
| zbi_input("integration-test-deps") { |
| visibility = [ ":*" ] |
| testonly = true |
| deps = [ |
| # Include the additional ZBI items that we test the behavior of in |
| # the integration test. |
| ":integration-test-bootloader-file-invalid", |
| ":integration-test-bootloader-file-valid", |
| ":integration-test-crashlog", |
| ":integration-test-factory-item", |
| ":integration-test-image-arg", |
| ":shutdown-flag", |
| |
| # Include a boot argument from bootfs. |
| ":integration-test-bootfs-arg", |
| |
| # Include a fake file in the ZBI in meta/, so we can test against a file that shouldn't be |
| # executable. |
| ":fake-cm-file", |
| |
| # Include some fake libraries at both packaged and unpackaged locations to test that they can be |
| # opened executable. This is done so that the test doesn't need to look at different paths |
| # depending on whether the build is using sanitizers. |
| ":fake-packaged-library", |
| ":fake-unpackaged-library", |
| |
| # Pull in the dependencies of devcoordinator so that we can test |
| # requesting libdriver.so from the bootsvc loader service. |
| # This could possibly be smaller, but seems pretty reasonable. |
| "//src/bringup/bin/device-name-provider", |
| "//src/bringup/bin/miscsvc", |
| "//src/bringup/bin/netsvc", |
| "//src/bringup/bin/pwrbtn-monitor", |
| "//src/bringup/bin/svchost:bootfs", |
| "//src/devices/internal/drivers/fragment", |
| "//src/devices/internal/drivers/fragment:fragment.proxy", |
| ] |
| } |
| |
| # The bootsvc integration tests exercises reading several different kinds of |
| # entries from the ZBI. Make sure we include one of each, so that we can test |
| # that bootsvc is exposing access to them correctly. |
| zbi_input("integration-test-factory-item") { |
| visibility = [ ":*" ] |
| testonly = true |
| type = "BOOTFS_FACTORY" |
| args = [ "--entry=IAmAFactoryItemHooray" ] |
| } |
| |
| zbi_input("integration-test-crashlog") { |
| visibility = [ ":*" ] |
| testonly = true |
| type = "CRASHLOG" |
| args = [ "--entry=IAmACrashLogButNotAVeryLongOne" ] |
| } |
| |
| # This flag is passed to the bootsvc so that when the test binary exits bootsvc |
| # shuts the system down. |
| zbi_input("shutdown-flag") { |
| visibility = [ ":*" ] |
| testonly = true |
| type = "cmdline" |
| args = [ "--entry=bootsvc.on_next_process_exit=shutdown" ] |
| } |
| |
| # This file must contain a trailing newline, but you can't inline that in a |
| # shell command with --entry, so generate a file and pass that as the argument |
| # when building the bootsvc-integration-tests zbi. |
| generated_file("bootsvc-integration-test-image-arg") { |
| visibility = [ ":*" ] |
| testonly = true |
| |
| outputs = [ "$target_out_dir/$target_name.txt" ] |
| |
| # Writing out a list rather than a string means it gets a trailing newline. |
| contents = [ "testkey=testvalue" ] |
| } |
| |
| zbi_input("integration-test-image-arg") { |
| visibility = [ ":*" ] |
| testonly = true |
| deps = [ ":bootsvc-integration-test-image-arg" ] |
| type = "IMAGE_ARGS" |
| sources = get_target_outputs(deps[0]) |
| } |
| |
| zbi_input("integration-test-bootloader-file-invalid") { |
| visibility = [ ":*" ] |
| testonly = true |
| type = "BOOTLOADER_FILE" |
| contents = "$0x23This filename is too short" |
| args = [ "--entry=$contents" ] |
| } |
| |
| zbi_input("integration-test-bootloader-file-valid") { |
| visibility = [ ":*" ] |
| testonly = true |
| type = "BOOTLOADER_FILE" |
| contents = "$0x21This is the filename of the file!FILE CONTENTS ARE HERE" |
| args = [ "--entry=$contents" ] |
| } |
| |
| generated_file("bootsvc-integration-test-bootfs-arg") { |
| visibility = [ ":*" ] |
| testonly = true |
| |
| outputs = [ "$target_out_dir/$target_name.txt" ] |
| |
| # Writing out a list rather than a string means it gets a trailing newline. |
| contents = [ "bootfskey=bootfsvalue" ] |
| } |
| |
| resource("integration-test-bootfs-arg") { |
| visibility = [ ":*" ] |
| testonly = true |
| deps = [ ":bootsvc-integration-test-bootfs-arg" ] |
| sources = get_target_outputs(deps[0]) |
| outputs = [ "config/devmgr" ] |
| } |
| |
| generated_file("gen-dummy-file") { |
| outputs = [ "$target_out_dir/$target_name" ] |
| contents = "doesn't matter" |
| } |
| |
| resource("fake-cm-file") { |
| visibility = [ ":*" ] |
| deps = [ ":gen-dummy-file" ] |
| sources = [ "$target_out_dir/gen-dummy-file" ] |
| outputs = [ "meta/fake.cm" ] |
| } |
| |
| resource("fake-packaged-library") { |
| visibility = [ ":*" ] |
| deps = [ ":gen-dummy-file" ] |
| sources = [ "$target_out_dir/gen-dummy-file" ] |
| outputs = [ "pkg/dummy_pkg/lib/dummy.so" ] |
| } |
| |
| resource("fake-unpackaged-library") { |
| visibility = [ ":*" ] |
| deps = [ ":gen-dummy-file" ] |
| sources = [ "$target_out_dir/gen-dummy-file" ] |
| outputs = [ "lib/dummy.so" ] |
| } |
| |
| zbi_test("bootsvc-integration-tests") { |
| assert(current_cpu != "") |
| |
| args = [ |
| "userboot=bin/bootsvc", |
| "bootsvc.next=bin/bootsvc-integration-test,testargument", |
| "kernel.root-job.behavior=shutdown", |
| ] |
| deps = [ |
| # We need a zircon kernel to get off the ground at all. |
| "//zircon/kernel", |
| |
| # Include bootsvc itself, since that's what we're testing here. Note |
| # that this uses the package() target for bootsvc, which comes with its |
| # own data_deps to exercise the `userboot.root` option to find bootsvc |
| # and its libraries inside a package directory in the BOOTFS. |
| "..", |
| |
| # Include the integration test binary, which bootsvc will launch. |
| ":bootsvc-integration-test", |
| |
| # Include the test's own runtime dependencies. |
| ":integration-test-deps", |
| ] |
| |
| output_dir = root_build_dir |
| output_name = "$target_name-$current_cpu" |
| } |
| |
| zbi_test("bootsvc-root-job-test") { |
| args = [ |
| "userboot=bin/bootsvc", |
| "bootsvc.next=test/core/zbi-child-test", |
| "kernel.root-job.behavior=shutdown", |
| "kernel.root-job.notice=$zbi_test_success_string", |
| ] |
| deps = [ |
| # We need a zircon kernel to get off the ground at all. |
| "//zircon/kernel", |
| |
| # Include bootsvc itself, since that's what we're testing here. Note |
| # that this uses the package() target for bootsvc, which comes with its |
| # own data_deps to exercise the `userboot.root` option to find bootsvc |
| # and its libraries inside a package directory in the BOOTFS. |
| "..", |
| |
| # Include the integration test binary, which bootsvc will launch. |
| "//src/bringup/lib/mexec/tests:smoke-zbi-test", |
| ] |
| } |