llvm/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel

# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Tests for LLVM libc string.h functions.

load("//libc:libc_build_rules.bzl", "libc_support_library")
load("//libc/test:libc_test_rules.bzl", "libc_test")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

libc_test(
    name = "strlen_test",
    srcs = ["strlen_test.cpp"],
    libc_function_deps = [
        "//libc:strlen",
    ],
)

libc_test(
    name = "strcpy_test",
    srcs = ["strcpy_test.cpp"],
    libc_function_deps = [
        "//libc:strcpy_sanitized",
    ],
)

libc_test(
    name = "strcmp_test",
    srcs = ["strcmp_test.cpp"],
    libc_function_deps = [
        "//libc:strcmp",
    ],
)

libc_test(
    name = "memchr_test",
    srcs = ["memchr_test.cpp"],
    libc_function_deps = [
        "//libc:memchr",
    ],
)

libc_support_library(
    name = "strchr_test_helper",
    hdrs = ["StrchrTest.h"],
    deps = ["//libc/test/UnitTest:LibcUnitTest"],
)

libc_test(
    name = "strchr_test",
    srcs = ["strchr_test.cpp"],
    libc_function_deps = [
        "//libc:strchr",
    ],
    deps = [":strchr_test_helper"],
)

libc_test(
    name = "strstr_test",
    srcs = ["strstr_test.cpp"],
    libc_function_deps = [
        "//libc:strstr",
    ],
)

libc_test(
    name = "strnlen_test",
    srcs = ["strnlen_test.cpp"],
    libc_function_deps = [
        "//libc:strnlen",
    ],
)

libc_test(
    name = "memrchr_test",
    srcs = ["memrchr_test.cpp"],
    libc_function_deps = [
        "//libc:memrchr",
    ],
)

libc_test(
    name = "strrchr_test",
    srcs = ["strrchr_test.cpp"],
    libc_function_deps = [
        "//libc:strrchr",
    ],
    deps = [":strchr_test_helper"],
)

libc_test(
    name = "strcspn_test",
    srcs = ["strcspn_test.cpp"],
    libc_function_deps = [
        "//libc:strcspn",
    ],
)

libc_test(
    name = "strspn_test",
    srcs = ["strspn_test.cpp"],
    libc_function_deps = [
        "//libc:strspn",
    ],
)

libc_test(
    name = "strtok_test",
    srcs = ["strtok_test.cpp"],
    libc_function_deps = [
        "//libc:strtok",
    ],
)

libc_support_library(
    name = "memory_check_utils",
    hdrs = ["memory_utils/memory_check_utils.h"],
    deps = [
        "//libc:__support_cpp_span",
        "//libc:__support_libc_assert",
        "//libc:__support_macros_config",
        "//libc:__support_macros_sanitizer",
        "//libc:string_memory_utils",
    ],
)

libc_support_library(
    name = "protected_pages",
    hdrs = ["memory_utils/protected_pages.h"],
    deps = [
        "//libc:__support_macros_attributes",
        "//libc:__support_macros_properties_os",
    ],
)

libc_test(
    name = "memcpy_test",
    srcs = ["memcpy_test.cpp"],
    libc_function_deps = [
        "//libc:memcpy",
    ],
    deps = [
        ":memory_check_utils",
        ":protected_pages",
        "//libc:__support_macros_properties_os",
    ],
)

libc_test(
    name = "mempcpy_test",
    srcs = ["mempcpy_test.cpp"],
    libc_function_deps = [
        "//libc:mempcpy",
    ],
)

libc_test(
    name = "memset_test",
    srcs = ["memset_test.cpp"],
    libc_function_deps = [
        "//libc:memset",
    ],
    deps = [
        ":memory_check_utils",
        ":protected_pages",
        "//libc:__support_macros_properties_os",
    ],
)

libc_test(
    name = "memmove_test",
    srcs = ["memmove_test.cpp"],
    libc_function_deps = [
        "//libc:memcmp",
        "//libc:memmove",
    ],
    deps = [
        ":memory_check_utils",
        "//libc:__support_cpp_span",
        "//libc/test/UnitTest:memory_matcher",
    ],
)

libc_test(
    name = "bcopy_test",
    srcs = ["bcopy_test.cpp"],
    libc_function_deps = [
        "//libc:bcopy",
    ],
    deps = [
        ":memory_check_utils",
        "//libc:__support_cpp_span",
        "//libc/test/UnitTest:memory_matcher",
    ],
)

libc_test(
    name = "memcmp_test",
    srcs = ["memcmp_test.cpp"],
    libc_function_deps = [
        "//libc:memcmp",
    ],
    deps = [
        ":memory_check_utils",
        "//libc/test/UnitTest:test_logger",
    ],
)

libc_test(
    name = "bcmp_test",
    srcs = ["bcmp_test.cpp"],
    libc_function_deps = [
        "//libc:bcmp",
    ],
    deps = [
        ":memory_check_utils",
        "//libc/test/UnitTest:test_logger",
    ],
)

libc_test(
    name = "bzero_test",
    srcs = ["bzero_test.cpp"],
    libc_function_deps = [
        "//libc:bzero",
    ],
    deps = [":memory_check_utils"],
)