blob: 6a3da51128beb5fd4c7f34d00006edc5cd90f111 [file] [log] [blame]
Wyatt Hepler2ad60672020-01-21 08:00:16 -08001# Copyright 2020 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(
16 "//pw_build:pigweed.bzl",
17 "pw_cc_library",
18 "pw_cc_test",
19)
20
21package(default_visibility = ["//visibility:public"])
22
Rob Mohr5fc25412021-06-23 09:35:23 -070023licenses(["notice"])
Wyatt Hepler2ad60672020-01-21 08:00:16 -080024
25pw_cc_library(
26 name = "pw_kvs",
27 srcs = [
Wyatt Hepler1927c282020-02-11 16:45:02 -080028 "alignment.cc",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080029 "checksum.cc",
Wyatt Heplerd31d9702020-02-14 08:46:36 -080030 "entry.cc",
Wyatt Hepler7ded6da2020-03-11 18:24:43 -070031 "entry_cache.cc",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080032 "flash_memory.cc",
Wyatt Hepler22d0d9f2020-03-05 14:57:11 -080033 "format.cc",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080034 "key_value_store.cc",
Wyatt Heplerbdd8e5a2020-02-20 19:27:26 -080035 "public/pw_kvs/internal/entry.h",
Wyatt Hepler7ded6da2020-03-11 18:24:43 -070036 "public/pw_kvs/internal/entry_cache.h",
Wyatt Hepler1fc11042020-02-19 17:17:51 -080037 "public/pw_kvs/internal/hash.h",
38 "public/pw_kvs/internal/key_descriptor.h",
Wyatt Hepler2454f2d2020-03-20 12:54:35 -070039 "public/pw_kvs/internal/sectors.h",
Keir Mierle0dd24a82020-02-21 16:08:59 -080040 "public/pw_kvs/internal/span_traits.h",
David Rogersca592962020-07-01 09:21:54 -070041 "pw_kvs_private/config.h",
Wyatt Heplerc84393f2020-03-20 11:23:24 -070042 "sectors.cc",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080043 ],
44 hdrs = [
Wyatt Hepler1927c282020-02-11 16:45:02 -080045 "public/pw_kvs/alignment.h",
Wyatt Hepler4da1fcb2020-01-30 17:32:18 -080046 "public/pw_kvs/checksum.h",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080047 "public/pw_kvs/crc16_checksum.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080048 "public/pw_kvs/flash_memory.h",
Wyatt Hepler88adfe82020-02-20 19:33:27 -080049 "public/pw_kvs/format.h",
Wyatt Hepler06b1b0b2020-03-09 08:26:34 -070050 "public/pw_kvs/io.h",
Rob Olivere64daf42020-11-24 11:50:03 -050051 "public/pw_kvs/key.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080052 "public/pw_kvs/key_value_store.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080053 ],
54 includes = ["public"],
55 deps = [
David Rogersc0104462020-05-08 15:50:23 -070056 "//pw_assert",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080057 "//pw_checksum",
Wyatt Hepler1c329ca2020-02-07 18:07:23 -080058 "//pw_containers",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080059 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -070060 "//pw_log:facade",
61 "//pw_span",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080062 "//pw_status",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080063 ],
64)
65
Wyatt Heplerec4b9352020-01-31 15:51:50 -080066pw_cc_library(
67 name = "crc16",
68 hdrs = [
69 "public/pw_kvs/crc16_checksum.h",
70 ],
71 deps = [
72 ":pw_kvs",
73 "//pw_checksum",
Rob Mohr06819482020-04-06 13:25:43 -070074 "//pw_span",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080075 ],
76)
77
Wyatt Heplerad684a12020-02-04 17:17:29 -080078pw_cc_library(
David Rogersd64cc012020-05-26 12:37:37 -070079 name = "fake_flash",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080080 srcs = [
David Rogersd64cc012020-05-26 12:37:37 -070081 "fake_flash_memory.cc",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080082 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080083 hdrs = [
David Rogersd64cc012020-05-26 12:37:37 -070084 "public/pw_kvs/fake_flash_memory.h",
Wyatt Heplerad684a12020-02-04 17:17:29 -080085 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080086 deps = [
David Rogersd64cc012020-05-26 12:37:37 -070087 ":pw_kvs",
Rob Mohr06819482020-04-06 13:25:43 -070088 "//pw_containers",
Wyatt Heplerad684a12020-02-04 17:17:29 -080089 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -070090 "//pw_log:facade",
91 "//pw_span",
Wyatt Heplerad684a12020-02-04 17:17:29 -080092 "//pw_status",
93 ],
94)
95
David Rogers5cc5ce82020-03-13 19:19:03 -070096pw_cc_library(
David Rogers6a262b42020-07-09 03:27:41 -070097 name = "fake_flash_small_partition",
David Rogersca592962020-07-01 09:21:54 -070098 srcs = [
David Rogers6a262b42020-07-09 03:27:41 -070099 "fake_flash_test_partition.cc",
David Rogersca592962020-07-01 09:21:54 -0700100 ],
101 hdrs = [
David Rogers6a262b42020-07-09 03:27:41 -0700102 "public/pw_kvs/flash_test_partition.h",
David Rogersca592962020-07-01 09:21:54 -0700103 ],
104 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700105 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800106 ":pw_kvs",
David Rogersca592962020-07-01 09:21:54 -0700107 ],
108)
109
110pw_cc_library(
David Rogers6a262b42020-07-09 03:27:41 -0700111 name = "fake_flash_64_aligned_partition",
112 srcs = [
113 "fake_flash_test_partition.cc",
114 ],
115 hdrs = [
116 "public/pw_kvs/flash_test_partition.h",
117 ],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800118 defines = ["PW_FLASH_TEST_ALIGNMENT=64"],
David Rogers6a262b42020-07-09 03:27:41 -0700119 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700120 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800121 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700122 ],
David Rogers6a262b42020-07-09 03:27:41 -0700123)
124
125pw_cc_library(
126 name = "fake_flash_256_aligned_partition",
127 srcs = [
128 "fake_flash_test_partition.cc",
129 ],
130 hdrs = [
131 "public/pw_kvs/flash_test_partition.h",
132 ],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800133 defines = ["PW_FLASH_TEST_ALIGNMENT=256"],
David Rogers6a262b42020-07-09 03:27:41 -0700134 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700135 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800136 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700137 ],
David Rogers6a262b42020-07-09 03:27:41 -0700138)
139
140pw_cc_library(
David Rogerseaa2a692020-08-07 00:48:16 -0700141 name = "fake_flash_test_key_value_store",
142 srcs = [
143 "fake_flash_test_key_value_store.cc",
144 ],
145 hdrs = [
146 "public/pw_kvs/test_key_value_store.h",
147 ],
148 deps = [
149 ":crc16",
David Rogerseaa2a692020-08-07 00:48:16 -0700150 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800151 ":pw_kvs",
David Rogerseaa2a692020-08-07 00:48:16 -0700152 ],
153)
154
155pw_cc_library(
David Rogersd64cc012020-05-26 12:37:37 -0700156 name = "test_utils",
157 hdrs = [
158 "pw_kvs_private/byte_utils.h",
159 ],
160 includes = ["public"],
161 visibility = ["//visibility:private"],
162)
163
164pw_cc_library(
David Rogers5cc5ce82020-03-13 19:19:03 -0700165 name = "test_partition",
166 srcs = [
167 "flash_partition_with_stats.cc",
168 ],
169 hdrs = [
170 "public/pw_kvs/flash_partition_with_stats.h",
171 ],
172 includes = ["public"],
173 visibility = ["//visibility:private"],
174 deps = [
Rob Mohr06819482020-04-06 13:25:43 -0700175 "//pw_containers",
David Rogers5cc5ce82020-03-13 19:19:03 -0700176 "//pw_kvs",
177 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -0700178 "//pw_log:facade",
David Rogers5cc5ce82020-03-13 19:19:03 -0700179 "//pw_status",
180 ],
181)
182
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800183pw_cc_test(
Wyatt Hepler1927c282020-02-11 16:45:02 -0800184 name = "alignment_test",
185 srcs = [
186 "alignment_test.cc",
187 ],
188 deps = [
189 ":pw_kvs",
Rob Mohr06819482020-04-06 13:25:43 -0700190 "//pw_status",
191 "//pw_unit_test",
Wyatt Hepler1927c282020-02-11 16:45:02 -0800192 ],
193)
194
195pw_cc_test(
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800196 name = "checksum_test",
197 srcs = ["checksum_test.cc"],
198 deps = [
199 ":crc16",
200 ":pw_kvs",
201 "//pw_checksum",
202 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -0700203 "//pw_unit_test",
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800204 ],
205)
206
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800207pw_cc_test(
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800208 name = "converts_to_span_test",
209 srcs = ["converts_to_span_test.cc"],
210 deps = [":pw_kvs"],
211)
212
213pw_cc_test(
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800214 name = "entry_test",
215 srcs = [
216 "entry_test.cc",
217 ],
218 deps = [
219 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800220 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700221 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700222 "//pw_span",
223 "//pw_unit_test",
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800224 ],
225)
226
227pw_cc_test(
Wyatt Hepler7ded6da2020-03-11 18:24:43 -0700228 name = "entry_cache_test",
229 srcs = ["entry_cache_test.cc"],
Wyatt Hepler02946272020-03-18 10:36:22 -0700230 deps = [
231 ":pw_kvs",
232 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700233 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700234 "//pw_unit_test",
Wyatt Hepler02946272020-03-18 10:36:22 -0700235 ],
Wyatt Hepler7ded6da2020-03-11 18:24:43 -0700236)
237
238pw_cc_test(
David Rogers6a262b42020-07-09 03:27:41 -0700239 name = "flash_partition_small_test",
240 srcs = ["flash_partition_test.cc"],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800241 defines = ["PW_FLASH_TEST_ITERATIONS=100"],
David Rogersca592962020-07-01 09:21:54 -0700242 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700243 ":fake_flash_small_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800244 ":pw_kvs",
David Rogersca592962020-07-01 09:21:54 -0700245 "//pw_log:backend",
246 "//pw_unit_test",
247 ],
David Rogers6a262b42020-07-09 03:27:41 -0700248)
249
250pw_cc_test(
251 name = "flash_partition_64_alignment_test",
252 srcs = ["flash_partition_test.cc"],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800253 defines = ["PW_FLASH_TEST_ITERATIONS=100"],
David Rogers6a262b42020-07-09 03:27:41 -0700254 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700255 ":fake_flash_64_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800256 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700257 "//pw_log:backend",
258 "//pw_unit_test",
259 ],
David Rogers6a262b42020-07-09 03:27:41 -0700260)
261
262pw_cc_test(
263 name = "flash_partition_256_alignment_test",
264 srcs = ["flash_partition_test.cc"],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800265 defines = ["PW_FLASH_TEST_ITERATIONS=100"],
David Rogers6a262b42020-07-09 03:27:41 -0700266 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700267 ":fake_flash_256_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800268 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700269 "//pw_log:backend",
270 "//pw_unit_test",
271 ],
David Rogersca592962020-07-01 09:21:54 -0700272)
273
274pw_cc_test(
Rob Olivere64daf42020-11-24 11:50:03 -0500275 name = "key_test",
276 srcs = [
277 "key_test.cc",
278 ],
279 deps = [
280 ":pw_kvs",
281 "//pw_status",
282 "//pw_unit_test",
283 ],
284)
285
286pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800287 name = "key_value_store_test",
288 srcs = ["key_value_store_test.cc"],
289 deps = [
290 ":crc16",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800291 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800292 ":test_utils",
Rob Mohr06819482020-04-06 13:25:43 -0700293 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700294 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700295 "//pw_log:facade",
296 "//pw_span",
297 "//pw_status",
298 "//pw_string",
299 "//pw_unit_test",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800300 ],
301)
302
303pw_cc_test(
David Rogers6a262b42020-07-09 03:27:41 -0700304 name = "key_value_store_small_flash_test",
305 srcs = ["key_value_store_initialized_test.cc"],
306 deps = [
307 ":crc16",
David Rogers6a262b42020-07-09 03:27:41 -0700308 ":fake_flash_small_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800309 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700310 ":test_utils",
311 "//pw_checksum",
312 "//pw_log:backend",
313 "//pw_log:facade",
314 "//pw_span",
315 "//pw_status",
316 "//pw_string",
317 "//pw_unit_test",
318 ],
319)
320
321pw_cc_test(
322 name = "key_value_store_64_alignment_flash_test",
323 srcs = ["key_value_store_initialized_test.cc"],
324 deps = [
325 ":crc16",
David Rogers6a262b42020-07-09 03:27:41 -0700326 ":fake_flash_64_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800327 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700328 ":test_utils",
329 "//pw_checksum",
330 "//pw_log:backend",
331 "//pw_log:facade",
332 "//pw_span",
333 "//pw_status",
334 "//pw_string",
335 "//pw_unit_test",
336 ],
337)
338
339pw_cc_test(
340 name = "key_value_store_256_alignment_flash_test",
341 srcs = ["key_value_store_initialized_test.cc"],
342 deps = [
343 ":crc16",
David Rogers6a262b42020-07-09 03:27:41 -0700344 ":fake_flash_256_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800345 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700346 ":test_utils",
347 "//pw_checksum",
348 "//pw_log:backend",
349 "//pw_log:facade",
350 "//pw_span",
351 "//pw_status",
352 "//pw_string",
353 "//pw_unit_test",
354 ],
355)
356
357pw_cc_test(
David Rogerseaa2a692020-08-07 00:48:16 -0700358 name = "fake_flash_test_key_value_store_test",
359 srcs = ["test_key_value_store_test.cc"],
360 deps = [
361 ":crc16",
362 ":fake_flash_test_key_value_store",
363 ":pw_kvs",
364 "//pw_log:backend",
365 "//pw_status",
366 "//pw_unit_test",
367 ],
368)
369
370pw_cc_test(
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800371 name = "key_value_store_binary_format_test",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800372 srcs = [
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800373 "key_value_store_binary_format_test.cc",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800374 ],
375 deps = [
376 ":crc16",
377 ":pw_kvs",
378 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700379 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700380 "//pw_unit_test",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800381 ],
382)
383
384pw_cc_test(
David Rogers67cf06d2021-04-15 14:56:46 -0700385 name = "key_value_store_put_test",
386 srcs = ["key_value_store_put_test.cc"],
Wyatt Hepler16b04522020-02-07 16:00:14 -0800387 deps = [
388 ":crc16",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800389 ":pw_kvs",
David Rogers5cc5ce82020-03-13 19:19:03 -0700390 ":test_partition",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800391 ":test_utils",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800392 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700393 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700394 "//pw_unit_test",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800395 ],
396)
397
398pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800399 name = "key_value_store_map_test",
400 srcs = ["key_value_store_map_test.cc"],
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800401 deps = [
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800402 ":crc16",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800403 ":pw_kvs",
David Rogers5cc5ce82020-03-13 19:19:03 -0700404 ":test_partition",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800405 ":test_utils",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800406 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700407 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700408 "//pw_log:facade",
409 "//pw_span",
410 "//pw_unit_test",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800411 ],
412)
Wyatt Heplerd6216822020-02-04 16:39:15 -0800413
Wyatt Heplerc84393f2020-03-20 11:23:24 -0700414pw_cc_test(
415 name = "sectors_test",
416 srcs = ["sectors_test.cc"],
417 deps = [
418 ":pw_kvs",
419 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700420 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700421 "//pw_unit_test",
Wyatt Heplerc84393f2020-03-20 11:23:24 -0700422 ],
423)
424
Armando Montanezf9e93e12020-04-22 07:44:14 -0700425pw_cc_test(
426 name = "key_value_store_wear_test",
427 srcs = [
428 "key_value_store_wear_test.cc",
429 ],
430 deps = [
431 ":pw_kvs",
David Rogersd5138f32020-04-28 15:18:56 -0700432 ":test_partition",
Armando Montanezf9e93e12020-04-22 07:44:14 -0700433 ":test_utils",
434 "//pw_log:backend",
435 "//pw_unit_test",
436 ],
437)