| # 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. |
| |
| ########################################## |
| # Though under //zircon, this build file # |
| # is meant to be used in the Fuchsia GN # |
| # build. # |
| # See fxb/36139. # |
| ########################################## |
| |
| assert(!defined(zx) || zx != "/", |
| "This file can only be used in the Fuchsia GN build.") |
| |
| import("//build/test.gni") |
| import("//build/unification/images/migrated_manifest.gni") |
| import("//build/unification/zbi/migrated_zbi_test.gni") |
| import("//build/unification/zbi/resource.gni") |
| import("//build/unification/zbi/zbi_input.gni") |
| import("//zircon/public/gn/test/zbi_test_success.gni") |
| |
| test("bootsvc-unit-test") { |
| # Dependent manifests unfortunately cannot be marked as `testonly`. |
| # TODO(44278): Remove when converting this file to proper GN build idioms. |
| if (is_fuchsia) { |
| testonly = false |
| } |
| 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 |
| } |
| } |
| output_name = "bootsvc-unit-test" |
| sources = [ "unit-test.cc" ] |
| deps = [ |
| "..:util", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/unittest", |
| ] |
| } |
| |
| 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 |
| } |
| } |
| |
| # TODO(44278): Revert to true when converting this file to proper GN build |
| # idioms. |
| testonly = false |
| defines = [ "ZBI_TEST_SUCCESS_STRING=\"$zbi_test_success_string\"" ] |
| sources = [ "integration-test.cc" ] |
| deps = [ |
| "..:util", |
| "//zircon/public/lib/fbl", |
| "//zircon/public/lib/fdio", |
| "//zircon/public/lib/safemath", |
| "//zircon/public/lib/zx", |
| "//zircon/public/lib/zxtest", |
| "//zircon/system/fidl/fuchsia-boot:c", |
| "//zircon/system/fidl/fuchsia-io:llcpp", |
| ] |
| } |
| |
| # 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 three additional ZBI items that we test the behavior of in |
| # the integration test. |
| ":integration-test-crashlog", |
| ":integration-test-factory-item", |
| ":integration-test-image-arg", |
| ":shutdown-flag", |
| |
| # 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. |
| "//zircon/system/core/netsvc:device-name-provider", |
| "//zircon/system/core/miscsvc", |
| "//zircon/system/core/netsvc", |
| "//zircon/system/core/pwrbtn-monitor", |
| "//build/unification/zbi:bin.svchost-zbi", |
| "//build/unification/zbi:driver.fragment-zbi", |
| "//build/unification/zbi:driver.fragment.proxy-zbi", |
| ] |
| } |
| |
| # 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]) |
| } |
| |
| 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" ] |
| } |
| |
| migrated_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. |
| "//build/unification/zbi: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" |
| } |
| |
| migrated_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. |
| "//build/unification/zbi: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. |
| "//zircon/system/utest/mexec:zbi-child", |
| ] |
| } |
| |
| migrated_manifest("bootsvc-unit-test-manifest") { |
| deps = [ ":bootsvc-unit-test" ] |
| } |