Debian Codegraph @

llvm-project/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl

raw
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 """LLVM libc starlark rules for tests.
6
7 libc functions are created though the libc_build_rules.bzl:libc_function.
8 They come in two flavors:
9 - the internal one that is scoped into the `__llvm_libc` namespace.
10 - the libc one that is the regular C function.
11
12 When performing tests we make sure to always use the internal version.
13 """
14
15 load("//libc:libc_build_rules.bzl", "INTERNAL_SUFFIX")
16
17 def libc_test(name, srcs, libc_function_deps, deps = [], **kwargs):
18 """Add target for a libc test.
19
20 Args:
21 name: Test target name
22 srcs: List of sources for the test.
23 libc_function_deps: List of libc_function targets used by this test.
24 deps: The list of other libraries to be linked in to the test target.
25 **kwargs: Attributes relevant for a cc_test. For example, name, srcs.
26 """
27 native.cc_test(
28 name = name,
29 srcs = srcs,
30 deps = [d + INTERNAL_SUFFIX for d in libc_function_deps] + [
31 "//libc:libc_root",
32 "//libc/utils/UnitTest:LibcUnitTest",
33 ] + deps,
34 features = ["-link_llvmlibc"], # Do not link libllvmlibc.a
35 **kwargs
36 )