1# Copyright 2024 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("//pw_build:pw_cc_binary.bzl", "pw_cc_binary") 16load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 17 18package(default_visibility = ["//visibility:public"]) 19 20licenses(["notice"]) 21 22# Libraries 23 24cc_library( 25 name = "named_u32", 26 testonly = True, 27 hdrs = ["named_u32.h"], 28 includes = [".."], 29 deps = [ 30 "//pw_bytes", 31 "//pw_string", 32 ], 33) 34 35cc_library( 36 name = "custom_allocator", 37 testonly = True, 38 srcs = ["custom_allocator.cc"], 39 hdrs = ["custom_allocator.h"], 40 includes = [".."], 41 deps = [ 42 "//pw_allocator:allocator", 43 "//pw_log", 44 "//pw_result", 45 ], 46) 47 48cc_library( 49 name = "custom_allocator_test_harness", 50 testonly = True, 51 hdrs = ["custom_allocator_test_harness.h"], 52 includes = [".."], 53 deps = [ 54 ":custom_allocator", 55 "//pw_allocator:test_harness", 56 "//pw_allocator:testing", 57 ], 58) 59 60# Examples 61 62pw_cc_test( 63 name = "basic", 64 srcs = ["basic.cc"], 65 deps = [ 66 ":named_u32", 67 "//pw_allocator:allocator", 68 "//pw_allocator:testing", 69 ], 70) 71 72pw_cc_test( 73 name = "block_allocator", 74 srcs = ["block_allocator.cc"], 75 deps = [ 76 ":named_u32", 77 "//pw_allocator:first_fit", 78 ], 79) 80 81pw_cc_test( 82 name = "custom_allocator_perf_test", 83 srcs = ["custom_allocator_perf_test.cc"], 84 deps = [ 85 ":custom_allocator_test_harness", 86 "//pw_perf_test", 87 "//pw_random", 88 ], 89) 90 91pw_cc_test( 92 name = "custom_allocator_test", 93 srcs = ["custom_allocator_test.cc"], 94 deps = [ 95 ":custom_allocator", 96 ":custom_allocator_test_harness", 97 ":named_u32", 98 "//pw_allocator:fuzzing", 99 "//pw_allocator:testing", 100 "//pw_containers:vector", 101 "//pw_fuzzer:fuzztest", 102 ], 103) 104 105pw_cc_test( 106 name = "linker_sections", 107 srcs = ["linker_sections.cc"], 108 deps = [ 109 ":named_u32", 110 "//pw_allocator:allocator", 111 "//pw_allocator:first_fit", 112 "//pw_allocator:worst_fit", 113 ], 114) 115 116pw_cc_test( 117 name = "metrics", 118 srcs = ["metrics.cc"], 119 deps = [ 120 ":named_u32", 121 "//pw_allocator:testing", 122 "//pw_allocator:tracking_allocator", 123 "//pw_tokenizer", 124 ], 125) 126 127pw_cc_test( 128 name = "pmr", 129 testonly = True, 130 srcs = ["pmr.cc"], 131 deps = [ 132 "//pw_allocator:pmr_allocator", 133 "//pw_allocator:testing", 134 ], 135) 136 137pw_cc_binary( 138 name = "size_report", 139 testonly = True, 140 srcs = ["size_report.cc"], 141 deps = [ 142 ":custom_allocator", 143 "//pw_allocator:first_fit", 144 "//pw_allocator:size_reporter", 145 ], 146) 147 148pw_cc_test( 149 name = "spin_lock", 150 srcs = ["spin_lock.cc"], 151 # TODO: b/358411629 - This test times out on rp2. 152 target_compatible_with = select({ 153 "@pico-sdk//bazel/constraint:rp2040": ["@platforms//:incompatible"], 154 "@pico-sdk//bazel/constraint:rp2350": ["@platforms//:incompatible"], 155 "//conditions:default": [], 156 }), 157 deps = [ 158 ":named_u32", 159 "//pw_allocator:synchronized_allocator", 160 "//pw_allocator:testing", 161 "//pw_assert", 162 "//pw_sync:interrupt_spin_lock", 163 "//pw_thread:test_thread_context", 164 "//pw_thread:thread", 165 "//pw_thread:thread_core", 166 ], 167) 168