| # Copyright 2016 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/checkout.gni") |
| import("//build/components.gni") |
| import("//build/config/clang/clang.gni") |
| import("//build/config/sysroot.gni") |
| import("//build/go/go_test.gni") |
| import("//build/host.gni") |
| |
| go_git_dir = "" |
| if (submodules) { |
| go_git_link_path_list = read_file(".git", "list lines") |
| go_git_link_path = go_git_link_path_list[0] |
| go_git_dir_split = string_split(go_git_link_path) |
| go_git_dir = go_git_dir_split[1] |
| } else { |
| go_git_dir = ".git" |
| } |
| |
| if (is_host && current_toolchain == toolchain_variant.base) { |
| _go_root = "$host_tools_dir/goroot" |
| |
| compiled_action("makeroot") { |
| visibility = [ ":makefuchsia" ] |
| |
| depfile = "$target_gen_dir/$target_name.d" |
| inputs = [ |
| "${go_git_dir}/HEAD", |
| "${go_git_dir}/index", |
| ".gitignore", |
| ] |
| _output = "$target_gen_dir/$target_name.stamp" |
| outputs = [ _output ] |
| |
| tool = "makeroot" |
| args = [ |
| "--source-goroot", |
| rebase_path(".", root_build_dir), |
| "--target-goroot", |
| rebase_path(_go_root, root_build_dir), |
| |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| "--stamp-file", |
| rebase_path(_output, root_build_dir), |
| ] |
| } |
| |
| compiled_action("makefuchsia") { |
| visibility = [ ":go_runtime" ] |
| deps = [ |
| ":makeroot", |
| "//sdk/lib/fdio", |
| ] |
| |
| depfile = "$target_gen_dir/$target_name.d" |
| _output = "$target_gen_dir/$target_name.stamp" |
| outputs = [ _output ] |
| |
| tool = "makefuchsia" |
| args = [ |
| "--cc", |
| rebase_path("${clang_prefix}/clang", root_build_dir), |
| "--cxx", |
| rebase_path("${clang_prefix}/clang++", root_build_dir), |
| "--gocache", |
| rebase_path(gocache_dir, root_build_dir), |
| "--goroot", |
| rebase_path(_go_root, root_build_dir), |
| "--goroot-bootstrap", |
| rebase_path("//prebuilt/third_party/go/${host_platform}", root_build_dir), |
| "--sysroot", |
| rebase_path(sysroot, root_build_dir), |
| |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| "--stamp-file", |
| rebase_path(_output, root_build_dir), |
| ] |
| } |
| } |
| |
| group("go_runtime") { |
| if (is_host) { |
| public_deps = [ ":makefuchsia(${toolchain_variant.base})" ] |
| } else { |
| public_deps = [ ":$target_name(${host_toolchain})" ] |
| } |
| } |
| |
| go_test("go_exec_test") { |
| gopackages = [ "os/exec" ] |
| } |
| |
| go_test("go_net_test") { |
| gopackages = [ "net" ] |
| } |
| |
| go_test("go_os_test") { |
| gopackages = [ "os" ] |
| } |
| |
| go_test("go_pprof_test") { |
| gopackages = [ "runtime/pprof" ] |
| } |
| |
| go_test("go_time_test") { |
| gopackages = [ "time" ] |
| } |
| |
| go_test("go_zx_test") { |
| gopackages = [ "syscall/zx" ] |
| } |
| |
| go_test("go_zxwait_test") { |
| gopackages = [ "syscall/zx/zxwait" ] |
| } |
| |
| fuchsia_component("go-exec-test") { |
| testonly = true |
| manifest = "meta/go_exec_test.cml" |
| deps = [ |
| ":go_exec_test", |
| "//third_party/sbase:cat", |
| "//third_party/sbase:echo", |
| ] |
| } |
| |
| fuchsia_component("go-net-test") { |
| testonly = true |
| manifest = "meta/go_net_test.cml" |
| deps = [ ":go_net_test" ] |
| } |
| |
| fuchsia_component("go-os-test") { |
| testonly = true |
| manifest = "meta/go_os_test.cml" |
| deps = [ ":go_os_test" ] |
| } |
| |
| fuchsia_component("go-pprof-test") { |
| testonly = true |
| manifest = "meta/go_pprof_test.cml" |
| deps = [ ":go_pprof_test" ] |
| } |
| |
| resource("zoneinfo") { |
| sources = [ rebase_path("lib/time/zoneinfo.zip") ] |
| outputs = [ "lib/time/{{source_file_part}}" ] |
| } |
| |
| resource("time_testdata") { |
| sources = [ |
| rebase_path("src/time/testdata/2020b_Europe_Berlin"), |
| rebase_path("src/time/testdata/2021a_America_Nuuk"), |
| rebase_path("src/time/testdata/2021a_Asia_Gaza"), |
| rebase_path("src/time/testdata/2021a_Europe_Dublin"), |
| ] |
| outputs = [ "src/time/testdata/{{source_file_part}}" ] |
| } |
| |
| fuchsia_component("go-time-test") { |
| testonly = true |
| manifest = "meta/go_time_test.cml" |
| deps = [ |
| ":go_time_test", |
| ":time_testdata", |
| ":zoneinfo", |
| ] |
| } |
| |
| fuchsia_component("go-zx-test") { |
| testonly = true |
| manifest = "meta/go_zx_test.cml" |
| deps = [ ":go_zx_test" ] |
| } |
| |
| fuchsia_component("go-zxwait-test") { |
| testonly = true |
| manifest = "meta/go_zxwait_test.cml" |
| deps = [ ":go_zxwait_test" ] |
| } |
| |
| fuchsia_test_package("go-stdlib-tests") { |
| test_components = [ |
| ":go-exec-test", |
| ":go-net-test", |
| ":go-os-test", |
| ":go-pprof-test", |
| ":go-time-test", |
| ":go-zx-test", |
| ":go-zxwait-test", |
| ] |
| |
| deps = [ "//src/connectivity/network/netstack:component" ] |
| |
| test_specs = { |
| environments = [ emu_env ] |
| } |
| } |
| |
| go_test("go_unsafevalue_test") { |
| gopackages = [ "syscall/zx/fidl/internal/unsafevalue" ] |
| |
| # This runs both on target device and as a host test. |
| # In both cases, it needs to build a go toolchain rather than using a prebuilt because |
| # it is testing the fidl package, which is implemented in the toolcahin itself. |
| use_prebuilt_go = false |
| } |
| |
| go_test("go_fidl_test") { |
| gopackages = [ "syscall/zx/fidl" ] |
| } |
| |
| go_test("go_extended_fidl_test") { |
| # N.B. these tests are not in the fidl package to avoid having to rebuild the |
| # go toolchain while iterating on them. |
| gopackages = [ "syscall/zx/fidl/fidl_test" ] |
| # TODO(pascallouis): Currently, while we take a dependency, the output of |
| # this FIDL rule is not directly used, rather the generated bindings were |
| # copied and checked in. |
| # |
| # Not being able to depend on automated generation is due to where code is |
| # placed, and how this relates to the tree structure of the toolchain. |
| # Disabling while fidlgen table generation is pending. |
| # Use regen-fidl to generate this file. |
| # deps = [ |
| # "src/syscall/zx/fidl/internal/bindingstest($go_toolchain)", |
| # ] |
| } |
| |
| fuchsia_component("go-unsafevalue-test") { |
| testonly = true |
| manifest = "meta/go_unsafevalue_test.cml" |
| deps = [ ":go_unsafevalue_test" ] |
| } |
| |
| fuchsia_component("go-fidl-test") { |
| testonly = true |
| manifest = "meta/go_fidl_test.cml" |
| deps = [ ":go_fidl_test" ] |
| } |
| |
| fuchsia_component("go-extended-fidl-test") { |
| testonly = true |
| manifest = "meta/go_extended_fidl_test.cml" |
| deps = [ ":go_extended_fidl_test" ] |
| } |
| |
| fuchsia_test_package("go-fidl-tests") { |
| test_components = [ |
| ":go-unsafevalue-test", |
| ":go-extended-fidl-test", |
| ":go-fidl-test", |
| ] |
| |
| test_specs = { |
| environments = [ emu_env ] |
| } |
| } |
| |
| group("fidl-tests") { |
| testonly = true |
| deps = [ |
| ":go-fidl-tests", |
| ":go_extended_fidl_test($host_toolchain)", |
| ":go_unsafevalue_test($host_toolchain)", |
| ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fidl-tests", |
| ":go-stdlib-tests", |
| ] |
| } |