xref: /aosp_15_r20/external/pigweed/pw_rpc/fuzz/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2023 The Pigweed Authors
2#
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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_chrono/backend.gni")
19import("$dir_pw_rpc/internal/integration_test_ports.gni")
20import("$dir_pw_thread/backend.gni")
21import("$dir_pw_unit_test/test.gni")
22
23config("public_include_path") {
24  include_dirs = [
25    "public",
26    "$dir_pw_rpc/public",
27  ]
28  visibility = [ ":*" ]
29}
30
31pw_source_set("alarm_timer") {
32  public_configs = [ ":public_include_path" ]
33  public = [ "public/pw_rpc/fuzz/alarm_timer.h" ]
34  public_deps = [
35    "$dir_pw_chrono:system_clock",
36    "$dir_pw_chrono:system_timer",
37  ]
38  visibility = [ ":*" ]
39}
40
41pw_test("alarm_timer_test") {
42  enable_if = pw_chrono_SYSTEM_TIMER_BACKEND != ""
43  sources = [ "alarm_timer_test.cc" ]
44  deps = [
45    ":alarm_timer",
46    "$dir_pw_chrono:system_clock",
47    "$dir_pw_sync:binary_semaphore",
48  ]
49}
50
51pw_source_set("argparse") {
52  public_configs = [ ":public_include_path" ]
53  public = [ "public/pw_rpc/fuzz/argparse.h" ]
54  sources = [ "argparse.cc" ]
55  public_deps = [
56    "$dir_pw_containers:vector",
57    dir_pw_status,
58  ]
59  deps = [
60    "$dir_pw_string:builder",
61    dir_pw_assert,
62    dir_pw_log,
63  ]
64  visibility = [ ":*" ]
65}
66
67pw_test("argparse_test") {
68  sources = [ "argparse_test.cc" ]
69  deps = [
70    ":argparse",
71    "$dir_pw_string:builder",
72  ]
73}
74
75pw_source_set("engine") {
76  public_configs = [ ":public_include_path" ]
77  public = [ "public/pw_rpc/fuzz/engine.h" ]
78  sources = [ "engine.cc" ]
79  public_deps = [
80    ":alarm_timer",
81    "$dir_pw_chrono:system_clock",
82    "$dir_pw_rpc:benchmark",
83    "$dir_pw_rpc:log_config",
84    "$dir_pw_rpc:protos.raw_rpc",
85    "$dir_pw_string:format",
86    "$dir_pw_sync:condition_variable",
87    "$dir_pw_sync:timed_mutex",
88    "$dir_pw_thread:thread",
89    dir_pw_random,
90  ]
91  deps = [ "$dir_pw_rpc:client" ]
92  visibility = [ ":*" ]
93}
94
95pw_test("engine_test") {
96  enable_if =
97      pw_chrono_SYSTEM_TIMER_BACKEND == "$dir_pw_chrono_stl:system_timer" &&
98      pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread"
99  sources = [ "engine_test.cc" ]
100  deps = [
101    ":engine",
102    "$dir_pw_rpc:client_server_testing",
103    "$dir_pw_rpc:client_server_testing_threaded",
104    "$dir_pw_thread:non_portable_test_thread_options",
105    "$dir_pw_thread_stl:non_portable_test_thread_options",
106    dir_pw_log,
107    pw_chrono_SYSTEM_TIMER_BACKEND,
108  ]
109}
110
111pw_executable("client_fuzzer") {
112  testonly = pw_unit_test_TESTONLY
113  sources = [ "client_fuzzer.cc" ]
114  deps = [
115    ":argparse",
116    ":engine",
117    "$dir_pw_rpc:client",
118    "$dir_pw_rpc:integration_testing",
119  ]
120}
121
122pw_python_action("cpp_client_server_fuzz_test") {
123  testonly = pw_unit_test_TESTONLY
124  script = "../py/pw_rpc/testing.py"
125  args = [
126    "--server",
127    "<TARGET_FILE($dir_pw_rpc:test_rpc_server)>",
128    "--client",
129    "<TARGET_FILE(:client_fuzzer)>",
130    "--",
131    "$pw_rpc_CPP_CLIENT_FUZZER_TEST_PORT",
132  ]
133  deps = [
134    ":client_fuzzer",
135    "$dir_pw_rpc:test_rpc_server",
136  ]
137
138  stamp = true
139}
140
141pw_test_group("tests") {
142  tests = [
143    ":argparse_test",
144    ":alarm_timer_test",
145    ":engine_test",
146  ]
147}
148