blob: f4c113f98213da8240b9cb817a2e9515fe709e1b [file] [log] [blame]
Alexei Frolov80246792020-11-05 21:12:45 -08001# Copyright 2020 The Pigweed Authors
Alexei Frolovc10c8122019-11-01 16:31:19 -07002#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070015import("//build_overrides/pigweed.gni")
16
Max Koopmanf4789282021-05-14 11:01:55 -070017import("$dir_pw_build/module_config.gni")
Alexei Frolovedd2f142020-06-09 19:11:27 -070018import("$dir_pw_build/target_types.gni")
Alexei Frolovea395522020-03-13 13:35:07 -070019import("$dir_pw_docgen/docs.gni")
Alexei Frolov80246792020-11-05 21:12:45 -080020import("$dir_pw_protobuf_compiler/proto.gni")
Wyatt Heplerb3fca3a2020-01-03 12:14:00 -080021import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070022
Max Koopmanf4789282021-05-14 11:01:55 -070023declare_args() {
24 # The build target that overrides the default configuration options for this
25 # module. This should point to a source set that provides defines through a
26 # public config (which may -include a file or add defines directly).
27 pw_unit_test_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
28}
29
Armando Montanez4ddaa9e2021-12-07 15:40:51 -080030# This pool limits the maximum number of unit tests that may run in parallel.
31# Despite the fact that this is a single GN "target", each toolchain owns its
32# own version of this pool, meaning pw_unit_test_POOL_DEPTH may be set
33# differently across targets in a single build, and build steps in one toolchain
34# will not consume pool resources of steps from another toolchain.
35pool("unit_test_pool") {
36 depth = pw_unit_test_POOL_DEPTH
37}
38
Alexei Frolovc10c8122019-11-01 16:31:19 -070039config("default_config") {
Alexei Frolov802c6e42019-12-17 15:24:35 -080040 include_dirs = [
41 "public",
42 "public_overrides",
43 ]
Alexei Frolovc10c8122019-11-01 16:31:19 -070044}
45
Max Koopmanf4789282021-05-14 11:01:55 -070046pw_source_set("config") {
47 public = [ "public/pw_unit_test/config.h" ]
48 public_configs = [ ":default_config" ]
49 public_deps = [
50 dir_pw_polyfill,
51 pw_unit_test_CONFIG,
52 ]
53 visibility = [ ":*" ]
54}
55
Alexei Frolovc10c8122019-11-01 16:31:19 -070056# pw_unit_test core library.
Alexei Frolovedd2f142020-06-09 19:11:27 -070057pw_source_set("pw_unit_test") {
Wyatt Hepler21192402020-01-15 15:40:51 -080058 public_configs = [ ":default_config" ]
Alexei Frolovc10c8122019-11-01 16:31:19 -070059 public_deps = [
Max Koopmanf4789282021-05-14 11:01:55 -070060 ":config",
Alexei Frolov47a43042021-04-06 14:19:55 -070061 dir_pw_polyfill,
62 dir_pw_preprocessor,
63 dir_pw_string,
Alexei Frolovc10c8122019-11-01 16:31:19 -070064 ]
65 public = [
Alexei Frolovc10c8122019-11-01 16:31:19 -070066 "public/pw_unit_test/event_handler.h",
67 "public/pw_unit_test/framework.h",
Alexei Frolov802c6e42019-12-17 15:24:35 -080068 "public_overrides/gtest/gtest.h",
Alexei Frolovc10c8122019-11-01 16:31:19 -070069 ]
Wyatt Hepler7e3f1d92020-08-07 14:09:03 -070070 sources = [ "framework.cc" ]
Alexei Frolovc10c8122019-11-01 16:31:19 -070071}
72
73# Library providing an event handler which outputs human-readable text.
Alexei Frolovedd2f142020-06-09 19:11:27 -070074pw_source_set("simple_printing_event_handler") {
Alexei Frolovc10c8122019-11-01 16:31:19 -070075 public_deps = [
76 ":pw_unit_test",
77 "$dir_pw_preprocessor",
78 ]
Rob Mohra0ba54f2020-02-27 11:43:49 -080079 public = [ "public/pw_unit_test/simple_printing_event_handler.h" ]
Wyatt Hepler7e3f1d92020-08-07 14:09:03 -070080 sources = [ "simple_printing_event_handler.cc" ]
Alexei Frolovc10c8122019-11-01 16:31:19 -070081}
82
83# Library providing a standard desktop main function for the pw_unit_test
84# framework. Unit test files can link against this library to build runnable
85# unit test executables.
Alexei Frolovedd2f142020-06-09 19:11:27 -070086pw_source_set("simple_printing_main") {
Rob Mohra0ba54f2020-02-27 11:43:49 -080087 public_deps = [ ":pw_unit_test" ]
Alexei Frolovc10c8122019-11-01 16:31:19 -070088 deps = [
89 ":simple_printing_event_handler",
Armando Montanezf7a5a742020-03-02 14:58:59 -080090 "$dir_pw_sys_io",
Alexei Frolovc10c8122019-11-01 16:31:19 -070091 ]
Rob Mohra0ba54f2020-02-27 11:43:49 -080092 sources = [ "simple_printing_main.cc" ]
Alexei Frolovc10c8122019-11-01 16:31:19 -070093}
94
Keir Mierleda0bccb2020-01-17 13:51:35 -080095# Library providing an event handler which logs using pw_log.
Alexei Frolov4c0428a2020-06-10 10:46:04 -070096pw_source_set("logging_event_handler") {
97 public_deps = [
98 ":pw_unit_test",
99 "$dir_pw_log",
100 "$dir_pw_preprocessor",
101 ]
102 public = [ "public/pw_unit_test/logging_event_handler.h" ]
Wyatt Hepler7e3f1d92020-08-07 14:09:03 -0700103 sources = [ "logging_event_handler.cc" ]
Alexei Frolov4c0428a2020-06-10 10:46:04 -0700104}
Keir Mierleda0bccb2020-01-17 13:51:35 -0800105
Alexei Frolov4c0428a2020-06-10 10:46:04 -0700106pw_source_set("logging_main") {
107 public_deps = [ ":pw_unit_test" ]
108 deps = [
109 ":logging_event_handler",
110 "$dir_pw_sys_io",
111 ]
112 sources = [ "logging_main.cc" ]
Keir Mierleda0bccb2020-01-17 13:51:35 -0800113}
114
Alexei Frolov80246792020-11-05 21:12:45 -0800115pw_source_set("rpc_service") {
116 public_configs = [ ":default_config" ]
117 public_deps = [
118 ":pw_unit_test",
119 ":unit_test_proto.pwpb",
120 ":unit_test_proto.raw_rpc",
Alexei Frolov47a43042021-04-06 14:19:55 -0700121 "$dir_pw_containers:vector",
Alexei Frolov80246792020-11-05 21:12:45 -0800122 ]
123 deps = [ dir_pw_log ]
124 public = [
125 "public/pw_unit_test/internal/rpc_event_handler.h",
126 "public/pw_unit_test/unit_test_service.h",
127 ]
128 sources = [
129 "rpc_event_handler.cc",
130 "unit_test_service.cc",
131 ]
132}
133
134pw_source_set("rpc_main") {
135 public_deps = [ ":pw_unit_test" ]
136 deps = [
137 ":rpc_service",
Alexei Froloveb94e962020-12-29 16:15:40 -0800138 "$dir_pw_rpc/system_server",
Alexei Frolov80246792020-11-05 21:12:45 -0800139 dir_pw_log,
140 ]
141 sources = [ "rpc_main.cc" ]
142}
143
Wyatt Hepler81017fe2021-08-02 17:46:41 -0700144pw_executable("test_rpc_server") {
145 sources = [ "test_rpc_server.cc" ]
146 deps = [
147 ":pw_unit_test",
148 ":rpc_service",
149 "$dir_pw_rpc/system_server",
150 "$dir_pw_rpc/system_server:socket",
151 dir_pw_log,
152 ]
153}
154
Alexei Frolov80246792020-11-05 21:12:45 -0800155pw_proto_library("unit_test_proto") {
156 sources = [ "pw_unit_test_proto/unit_test.proto" ]
157}
158
159pw_doc_group("docs") {
160 sources = [ "docs.rst" ]
161}
162
Wyatt Heplerb3fca3a2020-01-03 12:14:00 -0800163pw_test("framework_test") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800164 sources = [ "framework_test.cc" ]
Alexei Frolovc10c8122019-11-01 16:31:19 -0700165}
Wyatt Heplerb3fca3a2020-01-03 12:14:00 -0800166
167pw_test_group("tests") {
168 tests = [ ":framework_test" ]
169}