| 1 |
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. |
| 2 |
# See https://llvm.org/LICENSE.txt for license information. |
| 3 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 |
|
| 5 |
# Tests for LLVM libc string.h functions. |
| 6 |
|
| 7 |
load("//libc/test:libc_test_rules.bzl", "libc_test", "libc_test_library") |
| 8 |
|
| 9 |
package(default_visibility = ["//visibility:public"]) |
| 10 |
|
| 11 |
licenses(["notice"]) |
| 12 |
|
| 13 |
libc_test( |
| 14 |
name = "strlen_test", |
| 15 |
srcs = ["strlen_test.cpp"], |
| 16 |
deps = [ |
| 17 |
"//libc:strlen", |
| 18 |
], |
| 19 |
) |
| 20 |
|
| 21 |
libc_test( |
| 22 |
name = "strcpy_test", |
| 23 |
srcs = ["strcpy_test.cpp"], |
| 24 |
deps = [ |
| 25 |
"//libc:hdr_signal_macros", |
| 26 |
"//libc:strcpy", |
| 27 |
], |
| 28 |
) |
| 29 |
|
| 30 |
libc_test( |
| 31 |
name = "strlcpy_test", |
| 32 |
srcs = ["strlcpy_test.cpp"], |
| 33 |
deps = [ |
| 34 |
"//libc:strlcpy", |
| 35 |
], |
| 36 |
) |
| 37 |
|
| 38 |
libc_test( |
| 39 |
name = "stpcpy_test", |
| 40 |
srcs = ["stpcpy_test.cpp"], |
| 41 |
deps = [ |
| 42 |
"//libc:stpcpy", |
| 43 |
"//libc:string_utils", |
| 44 |
], |
| 45 |
) |
| 46 |
|
| 47 |
libc_test( |
| 48 |
name = "stpncpy_test", |
| 49 |
srcs = ["stpncpy_test.cpp"], |
| 50 |
deps = [ |
| 51 |
"//libc:__support_cpp_span", |
| 52 |
"//libc:hdr_signal_macros", |
| 53 |
"//libc:stpncpy", |
| 54 |
], |
| 55 |
) |
| 56 |
|
| 57 |
libc_test( |
| 58 |
name = "strcmp_test", |
| 59 |
srcs = ["strcmp_test.cpp"], |
| 60 |
deps = [ |
| 61 |
"//libc:strcmp", |
| 62 |
], |
| 63 |
) |
| 64 |
|
| 65 |
libc_test( |
| 66 |
name = "strncmp_test", |
| 67 |
srcs = ["strncmp_test.cpp"], |
| 68 |
deps = [ |
| 69 |
"//libc:strncmp", |
| 70 |
], |
| 71 |
) |
| 72 |
|
| 73 |
libc_test( |
| 74 |
name = "memchr_test", |
| 75 |
srcs = ["memchr_test.cpp"], |
| 76 |
deps = [ |
| 77 |
"//libc:hdr_signal_macros", |
| 78 |
"//libc:memchr", |
| 79 |
], |
| 80 |
) |
| 81 |
|
| 82 |
libc_test_library( |
| 83 |
name = "strchr_test_helper", |
| 84 |
hdrs = ["StrchrTest.h"], |
| 85 |
deps = ["//libc/test/UnitTest:LibcUnitTest"], |
| 86 |
) |
| 87 |
|
| 88 |
libc_test( |
| 89 |
name = "strchr_test", |
| 90 |
srcs = ["strchr_test.cpp"], |
| 91 |
deps = [ |
| 92 |
":strchr_test_helper", |
| 93 |
"//libc:strchr", |
| 94 |
], |
| 95 |
) |
| 96 |
|
| 97 |
libc_test( |
| 98 |
name = "strchrnul_test", |
| 99 |
srcs = ["strchrnul_test.cpp"], |
| 100 |
deps = [ |
| 101 |
"//libc:strchrnul", |
| 102 |
], |
| 103 |
) |
| 104 |
|
| 105 |
libc_test( |
| 106 |
name = "strpbrk_test", |
| 107 |
srcs = ["strpbrk_test.cpp"], |
| 108 |
deps = [ |
| 109 |
"//libc:strpbrk", |
| 110 |
], |
| 111 |
) |
| 112 |
|
| 113 |
libc_test( |
| 114 |
name = "strsep_test", |
| 115 |
srcs = ["strsep_test.cpp"], |
| 116 |
deps = [ |
| 117 |
"//libc:hdr_signal_macros", |
| 118 |
"//libc:strsep", |
| 119 |
], |
| 120 |
) |
| 121 |
|
| 122 |
libc_test( |
| 123 |
name = "strstr_test", |
| 124 |
srcs = ["strstr_test.cpp"], |
| 125 |
deps = [ |
| 126 |
"//libc:strstr", |
| 127 |
], |
| 128 |
) |
| 129 |
|
| 130 |
libc_test( |
| 131 |
name = "strnlen_test", |
| 132 |
srcs = ["strnlen_test.cpp"], |
| 133 |
deps = [ |
| 134 |
"//libc:strnlen", |
| 135 |
], |
| 136 |
) |
| 137 |
|
| 138 |
libc_test( |
| 139 |
name = "memrchr_test", |
| 140 |
srcs = ["memrchr_test.cpp"], |
| 141 |
deps = [ |
| 142 |
"//libc:hdr_signal_macros", |
| 143 |
"//libc:memrchr", |
| 144 |
], |
| 145 |
) |
| 146 |
|
| 147 |
libc_test( |
| 148 |
name = "strrchr_test", |
| 149 |
srcs = ["strrchr_test.cpp"], |
| 150 |
deps = [ |
| 151 |
":strchr_test_helper", |
| 152 |
"//libc:strrchr", |
| 153 |
], |
| 154 |
) |
| 155 |
|
| 156 |
libc_test( |
| 157 |
name = "strcasestr_test", |
| 158 |
srcs = ["strcasestr_test.cpp"], |
| 159 |
deps = [ |
| 160 |
"//libc:strcasestr", |
| 161 |
], |
| 162 |
) |
| 163 |
|
| 164 |
libc_test( |
| 165 |
name = "strcat_test", |
| 166 |
srcs = ["strcat_test.cpp"], |
| 167 |
deps = [ |
| 168 |
"//libc:hdr_signal_macros", |
| 169 |
"//libc:strcat", |
| 170 |
], |
| 171 |
) |
| 172 |
|
| 173 |
libc_test( |
| 174 |
name = "strlcat_test", |
| 175 |
srcs = ["strlcat_test.cpp"], |
| 176 |
deps = [ |
| 177 |
"//libc:strlcat", |
| 178 |
], |
| 179 |
) |
| 180 |
|
| 181 |
libc_test( |
| 182 |
name = "strncat_test", |
| 183 |
srcs = ["strncat_test.cpp"], |
| 184 |
deps = [ |
| 185 |
"//libc:strncat", |
| 186 |
], |
| 187 |
) |
| 188 |
|
| 189 |
libc_test( |
| 190 |
name = "strcspn_test", |
| 191 |
srcs = ["strcspn_test.cpp"], |
| 192 |
deps = [ |
| 193 |
"//libc:strcspn", |
| 194 |
], |
| 195 |
) |
| 196 |
|
| 197 |
libc_test( |
| 198 |
name = "strspn_test", |
| 199 |
srcs = ["strspn_test.cpp"], |
| 200 |
deps = [ |
| 201 |
"//libc:hdr_signal_macros", |
| 202 |
"//libc:strspn", |
| 203 |
], |
| 204 |
) |
| 205 |
|
| 206 |
libc_test( |
| 207 |
name = "strtok_test", |
| 208 |
srcs = ["strtok_test.cpp"], |
| 209 |
deps = [ |
| 210 |
"//libc:strtok", |
| 211 |
], |
| 212 |
) |
| 213 |
|
| 214 |
libc_test( |
| 215 |
name = "strtok_r_test", |
| 216 |
srcs = ["strtok_r_test.cpp"], |
| 217 |
deps = [ |
| 218 |
"//libc:strtok_r", |
| 219 |
], |
| 220 |
) |
| 221 |
|
| 222 |
libc_test_library( |
| 223 |
name = "memory_check_utils", |
| 224 |
hdrs = ["memory_utils/memory_check_utils.h"], |
| 225 |
deps = [ |
| 226 |
"//libc:__support_cpp_span", |
| 227 |
"//libc:__support_libc_assert", |
| 228 |
"//libc:__support_macros_config", |
| 229 |
"//libc:__support_macros_sanitizer", |
| 230 |
"//libc:hdr_stdint_proxy", |
| 231 |
"//libc:string_memory_utils", |
| 232 |
], |
| 233 |
) |
| 234 |
|
| 235 |
libc_test_library( |
| 236 |
name = "protected_pages", |
| 237 |
hdrs = ["memory_utils/protected_pages.h"], |
| 238 |
deps = [ |
| 239 |
"//libc:__support_macros_attributes", |
| 240 |
"//libc:__support_macros_properties_os", |
| 241 |
"//libc:hdr_stdint_proxy", |
| 242 |
], |
| 243 |
) |
| 244 |
|
| 245 |
libc_test( |
| 246 |
name = "memcpy_test", |
| 247 |
srcs = ["memcpy_test.cpp"], |
| 248 |
deps = [ |
| 249 |
":memory_check_utils", |
| 250 |
":protected_pages", |
| 251 |
"//libc:__support_macros_properties_os", |
| 252 |
"//libc:hdr_signal_macros", |
| 253 |
"//libc:memcpy", |
| 254 |
], |
| 255 |
) |
| 256 |
|
| 257 |
libc_test( |
| 258 |
name = "memccpy_test", |
| 259 |
srcs = ["memccpy_test.cpp"], |
| 260 |
deps = [ |
| 261 |
"//libc:__support_cpp_span", |
| 262 |
"//libc:memccpy", |
| 263 |
], |
| 264 |
) |
| 265 |
|
| 266 |
libc_test( |
| 267 |
name = "mempcpy_test", |
| 268 |
srcs = ["mempcpy_test.cpp"], |
| 269 |
deps = [ |
| 270 |
"//libc:hdr_signal_macros", |
| 271 |
"//libc:mempcpy", |
| 272 |
], |
| 273 |
) |
| 274 |
|
| 275 |
libc_test( |
| 276 |
name = "memset_test", |
| 277 |
srcs = ["memset_test.cpp"], |
| 278 |
deps = [ |
| 279 |
":memory_check_utils", |
| 280 |
":protected_pages", |
| 281 |
"//libc:__support_macros_properties_os", |
| 282 |
"//libc:hdr_signal_macros", |
| 283 |
"//libc:memset", |
| 284 |
], |
| 285 |
) |
| 286 |
|
| 287 |
libc_test( |
| 288 |
name = "memset_explicit_test", |
| 289 |
srcs = ["memset_explicit_test.cpp"], |
| 290 |
deps = [ |
| 291 |
":memory_check_utils", |
| 292 |
"//libc:memset_explicit", |
| 293 |
"//libc:string_memory_utils", |
| 294 |
], |
| 295 |
) |
| 296 |
|
| 297 |
libc_test( |
| 298 |
name = "memmove_test", |
| 299 |
srcs = ["memmove_test.cpp"], |
| 300 |
deps = [ |
| 301 |
":memory_check_utils", |
| 302 |
"//libc:__support_cpp_span", |
| 303 |
"//libc:hdr_signal_macros", |
| 304 |
"//libc:memcmp", |
| 305 |
"//libc:memmove", |
| 306 |
"//libc/test/UnitTest:memory_matcher", |
| 307 |
], |
| 308 |
) |
| 309 |
|
| 310 |
libc_test( |
| 311 |
name = "memcmp_test", |
| 312 |
srcs = ["memcmp_test.cpp"], |
| 313 |
deps = [ |
| 314 |
":memory_check_utils", |
| 315 |
"//libc:hdr_signal_macros", |
| 316 |
"//libc:memcmp", |
| 317 |
"//libc/test/UnitTest:test_logger", |
| 318 |
], |
| 319 |
) |
| 320 |
|
| 321 |
libc_test( |
| 322 |
name = "memmem_test", |
| 323 |
srcs = ["memmem_test.cpp"], |
| 324 |
deps = [ |
| 325 |
"//libc:memmem", |
| 326 |
"//libc:string_utils", |
| 327 |
], |
| 328 |
) |