blob: 2cd3cbc8da5ce5fb84353360b2644cb00481ab12 [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
23licenses(["notice"]) # Apache License 2.0
24
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",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080051 "public/pw_kvs/key_value_store.h",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080052 ],
53 includes = ["public"],
54 deps = [
David Rogersc0104462020-05-08 15:50:23 -070055 "//pw_assert",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080056 "//pw_checksum",
Wyatt Hepler1c329ca2020-02-07 18:07:23 -080057 "//pw_containers",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080058 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -070059 "//pw_log:facade",
60 "//pw_span",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080061 "//pw_status",
Wyatt Hepler2ad60672020-01-21 08:00:16 -080062 ],
63)
64
Wyatt Heplerec4b9352020-01-31 15:51:50 -080065pw_cc_library(
66 name = "crc16",
67 hdrs = [
68 "public/pw_kvs/crc16_checksum.h",
69 ],
70 deps = [
71 ":pw_kvs",
72 "//pw_checksum",
Rob Mohr06819482020-04-06 13:25:43 -070073 "//pw_span",
Wyatt Heplerec4b9352020-01-31 15:51:50 -080074 ],
75)
76
Wyatt Heplerad684a12020-02-04 17:17:29 -080077pw_cc_library(
David Rogersd64cc012020-05-26 12:37:37 -070078 name = "fake_flash",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080079 srcs = [
David Rogersd64cc012020-05-26 12:37:37 -070080 "fake_flash_memory.cc",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -080081 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080082 hdrs = [
David Rogersd64cc012020-05-26 12:37:37 -070083 "public/pw_kvs/fake_flash_memory.h",
Wyatt Heplerad684a12020-02-04 17:17:29 -080084 ],
Wyatt Heplerad684a12020-02-04 17:17:29 -080085 deps = [
David Rogersd64cc012020-05-26 12:37:37 -070086 ":pw_kvs",
Rob Mohr06819482020-04-06 13:25:43 -070087 "//pw_containers",
Wyatt Heplerad684a12020-02-04 17:17:29 -080088 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -070089 "//pw_log:facade",
90 "//pw_span",
Wyatt Heplerad684a12020-02-04 17:17:29 -080091 "//pw_status",
92 ],
93)
94
David Rogers5cc5ce82020-03-13 19:19:03 -070095pw_cc_library(
David Rogers6a262b42020-07-09 03:27:41 -070096 name = "fake_flash_small_partition",
David Rogersca592962020-07-01 09:21:54 -070097 srcs = [
David Rogers6a262b42020-07-09 03:27:41 -070098 "fake_flash_test_partition.cc",
David Rogersca592962020-07-01 09:21:54 -070099 ],
100 hdrs = [
David Rogers6a262b42020-07-09 03:27:41 -0700101 "public/pw_kvs/flash_test_partition.h",
David Rogersca592962020-07-01 09:21:54 -0700102 ],
103 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700104 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800105 ":pw_kvs",
David Rogersca592962020-07-01 09:21:54 -0700106 ],
107)
108
109pw_cc_library(
David Rogers6a262b42020-07-09 03:27:41 -0700110 name = "fake_flash_64_aligned_partition",
111 srcs = [
112 "fake_flash_test_partition.cc",
113 ],
114 hdrs = [
115 "public/pw_kvs/flash_test_partition.h",
116 ],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800117 defines = ["PW_FLASH_TEST_ALIGNMENT=64"],
David Rogers6a262b42020-07-09 03:27:41 -0700118 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700119 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800120 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700121 ],
David Rogers6a262b42020-07-09 03:27:41 -0700122)
123
124pw_cc_library(
125 name = "fake_flash_256_aligned_partition",
126 srcs = [
127 "fake_flash_test_partition.cc",
128 ],
129 hdrs = [
130 "public/pw_kvs/flash_test_partition.h",
131 ],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800132 defines = ["PW_FLASH_TEST_ALIGNMENT=256"],
David Rogers6a262b42020-07-09 03:27:41 -0700133 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700134 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800135 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700136 ],
David Rogers6a262b42020-07-09 03:27:41 -0700137)
138
139pw_cc_library(
David Rogerseaa2a692020-08-07 00:48:16 -0700140 name = "fake_flash_test_key_value_store",
141 srcs = [
142 "fake_flash_test_key_value_store.cc",
143 ],
144 hdrs = [
145 "public/pw_kvs/test_key_value_store.h",
146 ],
147 deps = [
148 ":crc16",
David Rogerseaa2a692020-08-07 00:48:16 -0700149 ":fake_flash",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800150 ":pw_kvs",
David Rogerseaa2a692020-08-07 00:48:16 -0700151 ],
152)
153
154pw_cc_library(
David Rogersd64cc012020-05-26 12:37:37 -0700155 name = "test_utils",
156 hdrs = [
157 "pw_kvs_private/byte_utils.h",
158 ],
159 includes = ["public"],
160 visibility = ["//visibility:private"],
161)
162
163pw_cc_library(
David Rogers5cc5ce82020-03-13 19:19:03 -0700164 name = "test_partition",
165 srcs = [
166 "flash_partition_with_stats.cc",
167 ],
168 hdrs = [
169 "public/pw_kvs/flash_partition_with_stats.h",
170 ],
171 includes = ["public"],
172 visibility = ["//visibility:private"],
173 deps = [
Rob Mohr06819482020-04-06 13:25:43 -0700174 "//pw_containers",
David Rogers5cc5ce82020-03-13 19:19:03 -0700175 "//pw_kvs",
176 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -0700177 "//pw_log:facade",
David Rogers5cc5ce82020-03-13 19:19:03 -0700178 "//pw_status",
179 ],
180)
181
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800182pw_cc_test(
Wyatt Hepler1927c282020-02-11 16:45:02 -0800183 name = "alignment_test",
184 srcs = [
185 "alignment_test.cc",
186 ],
187 deps = [
188 ":pw_kvs",
Rob Mohr06819482020-04-06 13:25:43 -0700189 "//pw_status",
190 "//pw_unit_test",
Wyatt Hepler1927c282020-02-11 16:45:02 -0800191 ],
192)
193
194pw_cc_test(
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800195 name = "checksum_test",
196 srcs = ["checksum_test.cc"],
197 deps = [
198 ":crc16",
199 ":pw_kvs",
200 "//pw_checksum",
201 "//pw_log",
Rob Mohr06819482020-04-06 13:25:43 -0700202 "//pw_unit_test",
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800203 ],
204)
205
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800206pw_cc_test(
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800207 name = "converts_to_span_test",
208 srcs = ["converts_to_span_test.cc"],
209 deps = [":pw_kvs"],
210)
211
212pw_cc_test(
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800213 name = "entry_test",
214 srcs = [
215 "entry_test.cc",
216 ],
217 deps = [
218 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800219 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700220 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700221 "//pw_span",
222 "//pw_unit_test",
Wyatt Hepler97fc7942020-02-06 15:55:45 -0800223 ],
224)
225
226pw_cc_test(
Wyatt Hepler7ded6da2020-03-11 18:24:43 -0700227 name = "entry_cache_test",
228 srcs = ["entry_cache_test.cc"],
Wyatt Hepler02946272020-03-18 10:36:22 -0700229 deps = [
230 ":pw_kvs",
231 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700232 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700233 "//pw_unit_test",
Wyatt Hepler02946272020-03-18 10:36:22 -0700234 ],
Wyatt Hepler7ded6da2020-03-11 18:24:43 -0700235)
236
237pw_cc_test(
David Rogers6a262b42020-07-09 03:27:41 -0700238 name = "flash_partition_small_test",
239 srcs = ["flash_partition_test.cc"],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800240 defines = ["PW_FLASH_TEST_ITERATIONS=100"],
David Rogersca592962020-07-01 09:21:54 -0700241 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700242 ":fake_flash_small_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800243 ":pw_kvs",
David Rogersca592962020-07-01 09:21:54 -0700244 "//pw_log:backend",
245 "//pw_unit_test",
246 ],
David Rogers6a262b42020-07-09 03:27:41 -0700247)
248
249pw_cc_test(
250 name = "flash_partition_64_alignment_test",
251 srcs = ["flash_partition_test.cc"],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800252 defines = ["PW_FLASH_TEST_ITERATIONS=100"],
David Rogers6a262b42020-07-09 03:27:41 -0700253 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700254 ":fake_flash_64_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800255 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700256 "//pw_log:backend",
257 "//pw_unit_test",
258 ],
David Rogers6a262b42020-07-09 03:27:41 -0700259)
260
261pw_cc_test(
262 name = "flash_partition_256_alignment_test",
263 srcs = ["flash_partition_test.cc"],
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800264 defines = ["PW_FLASH_TEST_ITERATIONS=100"],
David Rogers6a262b42020-07-09 03:27:41 -0700265 deps = [
David Rogers6a262b42020-07-09 03:27:41 -0700266 ":fake_flash_256_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800267 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700268 "//pw_log:backend",
269 "//pw_unit_test",
270 ],
David Rogersca592962020-07-01 09:21:54 -0700271)
272
273pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800274 name = "key_value_store_test",
275 srcs = ["key_value_store_test.cc"],
276 deps = [
277 ":crc16",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800278 ":pw_kvs",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800279 ":test_utils",
Rob Mohr06819482020-04-06 13:25:43 -0700280 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700281 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700282 "//pw_log:facade",
283 "//pw_span",
284 "//pw_status",
285 "//pw_string",
286 "//pw_unit_test",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800287 ],
288)
289
290pw_cc_test(
David Rogers6a262b42020-07-09 03:27:41 -0700291 name = "key_value_store_small_flash_test",
292 srcs = ["key_value_store_initialized_test.cc"],
293 deps = [
294 ":crc16",
David Rogers6a262b42020-07-09 03:27:41 -0700295 ":fake_flash_small_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800296 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700297 ":test_utils",
298 "//pw_checksum",
299 "//pw_log:backend",
300 "//pw_log:facade",
301 "//pw_span",
302 "//pw_status",
303 "//pw_string",
304 "//pw_unit_test",
305 ],
306)
307
308pw_cc_test(
309 name = "key_value_store_64_alignment_flash_test",
310 srcs = ["key_value_store_initialized_test.cc"],
311 deps = [
312 ":crc16",
David Rogers6a262b42020-07-09 03:27:41 -0700313 ":fake_flash_64_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800314 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700315 ":test_utils",
316 "//pw_checksum",
317 "//pw_log:backend",
318 "//pw_log:facade",
319 "//pw_span",
320 "//pw_status",
321 "//pw_string",
322 "//pw_unit_test",
323 ],
324)
325
326pw_cc_test(
327 name = "key_value_store_256_alignment_flash_test",
328 srcs = ["key_value_store_initialized_test.cc"],
329 deps = [
330 ":crc16",
David Rogers6a262b42020-07-09 03:27:41 -0700331 ":fake_flash_256_aligned_partition",
Wyatt Hepler2debeb62020-12-03 08:19:57 -0800332 ":pw_kvs",
David Rogers6a262b42020-07-09 03:27:41 -0700333 ":test_utils",
334 "//pw_checksum",
335 "//pw_log:backend",
336 "//pw_log:facade",
337 "//pw_span",
338 "//pw_status",
339 "//pw_string",
340 "//pw_unit_test",
341 ],
342)
343
344pw_cc_test(
David Rogerseaa2a692020-08-07 00:48:16 -0700345 name = "fake_flash_test_key_value_store_test",
346 srcs = ["test_key_value_store_test.cc"],
347 deps = [
348 ":crc16",
349 ":fake_flash_test_key_value_store",
350 ":pw_kvs",
351 "//pw_log:backend",
352 "//pw_status",
353 "//pw_unit_test",
354 ],
355)
356
357pw_cc_test(
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800358 name = "key_value_store_binary_format_test",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800359 srcs = [
Wyatt Hepler8e94ed62020-03-05 16:45:32 -0800360 "key_value_store_binary_format_test.cc",
Wyatt Hepler118fc3c2020-02-21 14:23:19 -0800361 ],
362 deps = [
363 ":crc16",
364 ":pw_kvs",
365 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700366 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700367 "//pw_unit_test",
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800368 ],
369)
370
371pw_cc_test(
Wyatt Hepler16b04522020-02-07 16:00:14 -0800372 name = "key_value_store_fuzz_test",
373 srcs = ["key_value_store_fuzz_test.cc"],
374 deps = [
375 ":crc16",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800376 ":pw_kvs",
David Rogers5cc5ce82020-03-13 19:19:03 -0700377 ":test_partition",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800378 ":test_utils",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800379 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700380 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700381 "//pw_unit_test",
Wyatt Hepler16b04522020-02-07 16:00:14 -0800382 ],
383)
384
385pw_cc_test(
Wyatt Hepler495b6ee2020-02-12 18:58:01 -0800386 name = "key_value_store_map_test",
387 srcs = ["key_value_store_map_test.cc"],
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800388 deps = [
Wyatt Heplerec4b9352020-01-31 15:51:50 -0800389 ":crc16",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800390 ":pw_kvs",
David Rogers5cc5ce82020-03-13 19:19:03 -0700391 ":test_partition",
Wyatt Heplercdd6dfc2020-02-18 12:04:04 -0800392 ":test_utils",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800393 "//pw_checksum",
Rob Mohr4d615402020-04-03 12:13:19 -0700394 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700395 "//pw_log:facade",
396 "//pw_span",
397 "//pw_unit_test",
Wyatt Hepler2ad60672020-01-21 08:00:16 -0800398 ],
399)
Wyatt Heplerd6216822020-02-04 16:39:15 -0800400
Wyatt Heplerc84393f2020-03-20 11:23:24 -0700401pw_cc_test(
402 name = "sectors_test",
403 srcs = ["sectors_test.cc"],
404 deps = [
405 ":pw_kvs",
406 ":test_utils",
Rob Mohr4d615402020-04-03 12:13:19 -0700407 "//pw_log:backend",
Rob Mohr06819482020-04-06 13:25:43 -0700408 "//pw_unit_test",
Wyatt Heplerc84393f2020-03-20 11:23:24 -0700409 ],
410)
411
Armando Montanezf9e93e12020-04-22 07:44:14 -0700412pw_cc_test(
413 name = "key_value_store_wear_test",
414 srcs = [
415 "key_value_store_wear_test.cc",
416 ],
417 deps = [
418 ":pw_kvs",
David Rogersd5138f32020-04-28 15:18:56 -0700419 ":test_partition",
Armando Montanezf9e93e12020-04-22 07:44:14 -0700420 ":test_utils",
421 "//pw_log:backend",
422 "//pw_unit_test",
423 ],
424)