• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_sync:binary_semaphore",
47  ]
48}
49
50pw_source_set("argparse") {
51  public_configs = [ ":public_include_path" ]
52  public = [ "public/pw_rpc/fuzz/argparse.h" ]
53  sources = [ "argparse.cc" ]
54  public_deps = [
55    "$dir_pw_containers:vector",
56    dir_pw_status,
57  ]
58  deps = [
59    "$dir_pw_string:builder",
60    dir_pw_assert,
61    dir_pw_log,
62  ]
63  visibility = [ ":*" ]
64}
65
66pw_test("argparse_test") {
67  sources = [ "argparse_test.cc" ]
68  deps = [ ":argparse" ]
69}
70
71pw_source_set("engine") {
72  public_configs = [ ":public_include_path" ]
73  public = [ "public/pw_rpc/fuzz/engine.h" ]
74  sources = [ "engine.cc" ]
75  public_deps = [
76    ":alarm_timer",
77    "$dir_pw_chrono:system_clock",
78    "$dir_pw_rpc:benchmark",
79    "$dir_pw_rpc:log_config",
80    "$dir_pw_rpc:protos.raw_rpc",
81    "$dir_pw_string:format",
82    "$dir_pw_sync:condition_variable",
83    "$dir_pw_sync:timed_mutex",
84    "$dir_pw_thread:thread",
85    dir_pw_random,
86  ]
87  deps = [ "$dir_pw_rpc:client" ]
88  visibility = [ ":*" ]
89}
90
91pw_test("engine_test") {
92  enable_if =
93      pw_chrono_SYSTEM_TIMER_BACKEND == "$dir_pw_chrono_stl:system_timer" &&
94      pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread"
95  sources = [ "engine_test.cc" ]
96  deps = [
97    ":engine",
98    "$dir_pw_rpc:client_server_testing_threaded",
99    "$dir_pw_thread:test_threads",
100    "$dir_pw_thread_stl:test_threads",
101    dir_pw_log,
102    pw_chrono_SYSTEM_TIMER_BACKEND,
103  ]
104}
105
106pw_executable("client_fuzzer") {
107  sources = [ "client_fuzzer.cc" ]
108  deps = [
109    ":argparse",
110    ":engine",
111    "$dir_pw_rpc:client",
112    "$dir_pw_rpc:integration_testing",
113  ]
114}
115
116pw_python_action("cpp_client_server_fuzz_test") {
117  script = "../py/pw_rpc/testing.py"
118  args = [
119    "--server",
120    "<TARGET_FILE($dir_pw_rpc:test_rpc_server)>",
121    "--client",
122    "<TARGET_FILE(:client_fuzzer)>",
123    "--",
124    "$pw_rpc_CPP_CLIENT_FUZZER_TEST_PORT",
125  ]
126  deps = [
127    ":client_fuzzer",
128    "$dir_pw_rpc:test_rpc_server",
129  ]
130
131  stamp = true
132}
133
134pw_test_group("tests") {
135  tests = [
136    ":argparse_test",
137    ":alarm_timer_test",
138    ":engine_test",
139  ]
140}
141