xref: /aosp_15_r20/external/pigweed/pw_transfer/integration_test/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2022 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
15load("@rules_java//java:defs.bzl", "java_binary")
16load("@rules_jvm_external//:defs.bzl", "artifact")
17load("@rules_proto//proto:defs.bzl", "proto_library")
18load("@rules_python//python:defs.bzl", "py_library")
19load("@rules_python//python:proto.bzl", "py_proto_library")
20load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
21load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")
22load("//pw_build:python.bzl", "pw_py_binary", "pw_py_test")
23
24pw_cc_binary(
25    name = "server",
26    srcs = ["server.cc"],
27    deps = [
28        ":config_cc_proto",
29        "//pw_assert",
30        "//pw_chrono:system_clock",
31        "//pw_log",
32        "//pw_rpc/system_server",
33        "//pw_stream",
34        "//pw_stream:std_file_stream",
35        "//pw_thread:thread",
36        "//pw_transfer",
37        "@com_google_protobuf//:protobuf",
38    ],
39)
40
41pw_py_binary(
42    name = "proxy",
43    srcs = ["proxy.py"],
44    deps = [
45        ":config_pb2",
46        "//pw_hdlc/py:pw_hdlc",
47        "//pw_transfer:transfer_proto_pb2",
48        "//pw_transfer/py:pw_transfer",
49        "@com_google_protobuf//:protobuf_python",
50    ],
51)
52
53pw_py_test(
54    name = "proxy_test",
55    srcs = [
56        "proxy.py",
57        "proxy_test.py",
58    ],
59    imports = ["."],
60    main = "proxy_test.py",
61    deps = [
62        ":config_pb2",
63        "//pw_hdlc/py:pw_hdlc",
64        "//pw_rpc:internal_packet_proto_pb2",
65        "//pw_transfer:transfer_proto_pb2",
66        "//pw_transfer/py:pw_transfer",
67    ],
68)
69
70proto_library(
71    name = "config_proto",
72    srcs = ["config.proto"],
73    deps = ["//pw_protobuf:status_proto"],
74)
75
76cc_proto_library(
77    name = "config_cc_proto",
78    # cc_proto_library pulls in the regular proto library, which is only
79    # needed for host tests.
80    target_compatible_with = incompatible_with_mcu(),
81    deps = [":config_proto"],
82)
83
84py_proto_library(
85    name = "config_pb2",
86    deps = [":config_proto"],
87)
88
89java_proto_library(
90    name = "config_java_proto",
91    deps = [":config_proto"],
92)
93
94pw_cc_binary(
95    name = "cpp_client",
96    testonly = True,
97    srcs = ["client.cc"],
98    deps = [
99        ":config_cc_proto",
100        "//pw_log",
101        "//pw_rpc:integration_testing",
102        "//pw_status",
103        "//pw_stream:std_file_stream",
104        "//pw_sync:binary_semaphore",
105        "//pw_thread:thread",
106        "//pw_transfer",
107        "//pw_transfer:client",
108        "@com_google_protobuf//:protobuf",
109    ],
110)
111
112py_library(
113    name = "integration_test_fixture",
114    testonly = True,
115    srcs = [
116        "test_fixture.py",
117    ],
118    data = [
119        ":cpp_client",
120        ":java_client",
121        ":proxy",
122        ":python_client",
123        ":server",
124    ],
125    imports = ["."],
126    deps = [
127        ":config_pb2",
128        "//pw_protobuf:status_proto_pb2",
129        "@com_google_protobuf//:protobuf_python",
130        "@rules_python//python/runfiles",
131    ],
132)
133
134# Uses ports 3310 and 3311.
135pw_py_test(
136    name = "cross_language_large_write_test",
137    # Actually 1 hour, see
138    # https://docs.bazel.build/versions/main/test-encyclopedia.html#role-of-the-test-runner
139    timeout = "eternal",
140    srcs = [
141        "cross_language_large_write_test.py",
142    ],
143    tags = [
144        # This test is not run in CQ because it's too slow.
145        "manual",
146        "integration",
147    ],
148    deps = [
149        ":integration_test_fixture",
150        "@python_packages//parameterized",
151    ],
152)
153
154# Uses ports 3306 and 3307.
155pw_py_test(
156    name = "cross_language_large_read_test",
157    # Actually 1 hour, see
158    # https://docs.bazel.build/versions/main/test-encyclopedia.html#role-of-the-test-runner
159    timeout = "eternal",
160    srcs = [
161        "cross_language_large_read_test.py",
162    ],
163    tags = [
164        # This test is not run in CQ because it's too slow.
165        "manual",
166        "integration",
167    ],
168    deps = [
169        ":integration_test_fixture",
170        "@python_packages//parameterized",
171    ],
172)
173
174# Uses ports 3304 and 3305.
175pw_py_test(
176    name = "cross_language_medium_read_test",
177    timeout = "moderate",
178    srcs = [
179        "cross_language_medium_read_test.py",
180    ],
181    tags = [
182        "integration",
183    ],
184    deps = [
185        ":config_pb2",
186        ":integration_test_fixture",
187        "@com_google_protobuf//:protobuf_python",
188        "@python_packages//parameterized",
189    ],
190)
191
192# Uses ports 3316 and 3317.
193pw_py_test(
194    name = "cross_language_medium_write_test",
195    timeout = "long",
196    srcs = [
197        "cross_language_medium_write_test.py",
198    ],
199    tags = [
200        "integration",
201    ],
202    deps = [
203        ":config_pb2",
204        ":integration_test_fixture",
205        "@com_google_protobuf//:protobuf_python",
206        "@python_packages//parameterized",
207    ],
208)
209
210# Uses ports 3302 and 3303.
211pw_py_test(
212    name = "cross_language_small_test",
213    timeout = "moderate",
214    srcs = [
215        "cross_language_small_test.py",
216    ],
217    tags = [
218        "integration",
219    ],
220    deps = [
221        ":config_pb2",
222        ":integration_test_fixture",
223        "@python_packages//parameterized",
224    ],
225)
226
227# Uses ports 3308 and 3309.
228pw_py_test(
229    name = "multi_transfer_test",
230    timeout = "moderate",
231    srcs = [
232        "multi_transfer_test.py",
233    ],
234    tags = [
235        "integration",
236    ],
237    deps = [
238        ":config_pb2",
239        ":integration_test_fixture",
240        "@python_packages//parameterized",
241    ],
242)
243
244# Uses ports 3312 and 3313.
245pw_py_test(
246    name = "expected_errors_test",
247    timeout = "long",
248    srcs = ["expected_errors_test.py"],
249    tags = [
250        "integration",
251    ],
252    deps = [
253        ":config_pb2",
254        ":integration_test_fixture",
255        "//pw_protobuf:status_proto_pb2",
256        "@com_google_protobuf//:protobuf_python",
257        "@python_packages//parameterized",
258    ],
259)
260
261# Uses ports 3314 and 3315.
262pw_py_test(
263    name = "legacy_binaries_test",
264    timeout = "moderate",
265    srcs = ["legacy_binaries_test.py"],
266    data = [
267        "@pw_transfer_test_binaries//:all",
268    ],
269    tags = [
270        "integration",
271    ],
272    # Legacy binaries were only built for linux-x86_64.
273    target_compatible_with = ["@platforms//os:linux"],
274    deps = [
275        ":config_pb2",
276        ":integration_test_fixture",
277        "//pw_protobuf:status_proto_pb2",
278        "@python_packages//parameterized",
279        "@rules_python//python/runfiles",
280    ],
281)
282
283java_binary(
284    name = "java_client",
285    srcs = ["JavaClient.java"],
286    main_class = "JavaClient",
287    target_compatible_with = incompatible_with_mcu(),
288    deps = [
289        ":config_java_proto",
290        "//pw_hdlc/java/main/dev/pigweed/pw_hdlc",
291        "//pw_log/java/main/dev/pigweed/pw_log",
292        "//pw_rpc/java/main/dev/pigweed/pw_rpc:client",
293        "//pw_transfer/java/main/dev/pigweed/pw_transfer:client",
294        "@com_google_protobuf//:protobuf_java",
295        artifact("com.google.flogger:flogger-system-backend"),
296        artifact("com.google.guava:guava"),
297    ],
298)
299
300pw_py_binary(
301    name = "python_client",
302    srcs = ["python_client.py"],
303    deps = [
304        ":config_pb2",
305        "//pw_hdlc/py:pw_hdlc",
306        "//pw_rpc/py:pw_rpc",
307        "//pw_transfer:transfer_proto_pb2",
308        "//pw_transfer/py:pw_transfer",
309        "@com_google_protobuf//:protobuf_python",
310        "@python_packages//pyserial",
311    ],
312)
313