[zircon] [gn] Host runtests
Build the host version of runtests, and the libraries it needs.
Bug: BLD-325
Test: gn gen && ninja
Change-Id: Ie04afdc71ec9124c567fb396bf22eea50bdb0d04
diff --git a/zircon/BUILD.gn b/zircon/BUILD.gn
index 9a87bd1..69dc115 100644
--- a/zircon/BUILD.gn
+++ b/zircon/BUILD.gn
@@ -7,6 +7,7 @@
# Build the native host tools intended for developer use.
environment_redirect("tools-${host_os}-${host_cpu}") {
+ testonly = true
environment_label = "$zx/public/gn/toolchain:host"
cpu = host_cpu
os = host_os
@@ -20,6 +21,7 @@
# "$root_build_dir/tools/" directory.
tools_rspfile = "$target_gen_dir/tools.rsp"
generated_file("tools._rsp") {
+ testonly = true
visibility = [ ":tools" ]
outputs = [
tools_rspfile,
@@ -32,6 +34,7 @@
}
action("tools") {
+ testonly = true
deps = [
":tools._rsp",
]
@@ -52,6 +55,7 @@
}
group("default") {
+ testonly = true
deps = [
":tools",
]
diff --git a/zircon/system/host/BUILD.gn b/zircon/system/host/BUILD.gn
index 8bab0ce..bdcb7f7 100644
--- a/zircon/system/host/BUILD.gn
+++ b/zircon/system/host/BUILD.gn
@@ -6,6 +6,7 @@
# Not listed here are tools whose only use is via GN rules in this build,
# such as abigen.
group("tools") {
+ testonly = true
deps = [
"$zx/third_party/uapp/mkfs-msdosfs",
"banjo",
@@ -15,6 +16,7 @@
"loglistener",
"merkleroot",
"netprotocol",
+ "runtests",
"xdc-server",
"zbi",
]
diff --git a/zircon/system/host/runtests/BUILD.gn b/zircon/system/host/runtests/BUILD.gn
new file mode 100644
index 0000000..c47e206
--- /dev/null
+++ b/zircon/system/host/runtests/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+host_tool("runtests") {
+ testonly = true
+ sources = [
+ "runtests.cpp",
+ ]
+ deps = [
+ "$zx/system/ulib/fbl",
+ "$zx/system/ulib/runtests-utils",
+ "$zx/system/ulib/zircon-internal",
+ ]
+}
diff --git a/zircon/system/ulib/pretty/BUILD.gn b/zircon/system/ulib/pretty/BUILD.gn
new file mode 100644
index 0000000..eb50352
--- /dev/null
+++ b/zircon/system/ulib/pretty/BUILD.gn
@@ -0,0 +1,33 @@
+# 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.
+
+library("pretty") {
+ sdk = "static"
+ sdk_headers = [
+ "pretty/hexdump.h",
+ "pretty/sizes.h",
+ ]
+ kernel = true
+ host = true
+ static = true
+ sources = [
+ "hexdump.c",
+ "sizes.c",
+ ]
+ if (!is_kernel && is_fuchsia) {
+ deps = [
+ "$zx/system/ulib/fdio",
+ ]
+ }
+}
+
+test("pretty-test") {
+ sources = [
+ "test.c",
+ ]
+ deps = [
+ ":pretty",
+ "$zx/system/ulib/unittest",
+ ]
+}
diff --git a/zircon/system/ulib/runtests-utils/BUILD.gn b/zircon/system/ulib/runtests-utils/BUILD.gn
new file mode 100644
index 0000000..15e90ea
--- /dev/null
+++ b/zircon/system/ulib/runtests-utils/BUILD.gn
@@ -0,0 +1,53 @@
+# 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.
+
+library("runtests-utils") {
+ testonly = true
+ host = true
+ sources = [
+ "discover-and-run-tests.cpp",
+ "runtests-utils.cpp",
+ ]
+ public_deps = [
+ # <runtests-utils/runtests-utils.h> has #include <lib/zircon-internal/fnv1hash.h>.
+ "$zx/system/ulib/zircon-internal:headers",
+ ]
+ deps = [
+ "$zx/system/ulib/fbl",
+ "$zx/system/ulib/unittest",
+ "$zx/system/ulib/zircon-internal",
+ ]
+ if (is_fuchsia) {
+ sources += [
+ "fuchsia-run-test.cpp",
+ "log-exporter.cpp",
+ ]
+ public_deps += [
+ # <runtests-utils/log-exporter.h> has #include <lib/fidl/cpp/message_buffer.h>.
+ "$zx/system/ulib/fidl:headers",
+
+ # <runtests-utils/log-exporter.h> has #include <fuchsia/logger/c/fidl.h>.
+ "$zx/system/fidl/fuchsia-logger:c.headers",
+
+ # <runtests-utils/log-exporter.h> has #include <lib/async-loop/cpp/loop.h>.
+ "$zx/system/ulib/async-loop:async-loop-cpp.headers",
+ ]
+ deps += [
+ "$zx/system/fidl/fuchsia-logger:c",
+ "$zx/system/ulib/async",
+ "$zx/system/ulib/async:async-cpp",
+ "$zx/system/ulib/async-loop",
+ "$zx/system/ulib/async-loop:async-loop-cpp",
+ "$zx/system/ulib/fdio",
+ "$zx/system/ulib/fidl",
+ "$zx/system/ulib/loader-service",
+ "$zx/system/ulib/unittest",
+ "$zx/system/ulib/zircon",
+ "$zx/system/ulib/zx",
+ "$zx/system/ulib/zxcpp",
+ ]
+ } else {
+ sources += [ "posix-run-test.cpp" ]
+ }
+}
diff --git a/zircon/system/ulib/unittest/BUILD.gn b/zircon/system/ulib/unittest/BUILD.gn
new file mode 100644
index 0000000..fa79082
--- /dev/null
+++ b/zircon/system/ulib/unittest/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+library("unittest") {
+ sdk = "source"
+ sdk_headers = [ "unittest/unittest.h" ]
+ testonly = true
+ host = true
+ shared = true
+ sources = [
+ "all-tests.cpp",
+ "unittest.cpp",
+ "watchdog.cpp",
+ ]
+ deps = [
+ "$zx/system/ulib/pretty",
+ ]
+ if (is_fuchsia) {
+ sources += [
+ "crash-handler.cpp",
+ "crash-list.cpp",
+ ]
+ deps += [ "$zx/system/ulib/zx" ]
+ }
+}
diff --git a/zircon/system/ulib/zircon-internal/BUILD.gn b/zircon/system/ulib/zircon-internal/BUILD.gn
new file mode 100644
index 0000000..37dfbd3
--- /dev/null
+++ b/zircon/system/ulib/zircon-internal/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+library("zircon-internal") {
+ sdk = "source"
+ sdk_headers = [
+ "lib/zircon-internal/device/cpu-trace/cpu-perf.h",
+ "lib/zircon-internal/device/cpu-trace/intel-pm-events.inc",
+ "lib/zircon-internal/device/cpu-trace/intel-pm.h",
+ "lib/zircon-internal/device/cpu-trace/intel-pt.h",
+ "lib/zircon-internal/device/cpu-trace/skylake-misc-events.inc",
+ "lib/zircon-internal/device/cpu-trace/skylake-pm-events.inc",
+ "lib/zircon-internal/fnv1hash.h",
+ "lib/zircon-internal/ktrace-def.h",
+ "lib/zircon-internal/ktrace.h",
+ "lib/zircon-internal/macros.h",
+ "lib/zircon-internal/mtrace.h",
+ "lib/zircon-internal/xorshiftrand.h",
+ ]
+ kernel = true
+ host = true
+ sources = []
+}