Debian Codegraph @

utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_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 math tests.
6
7 This rule delegates testing to libc_test_rules.bzl:libc_test.
8 It adds common math dependencies.
9 """
10
11 load("//libc/test:libc_test_rules.bzl", "libc_test")
12
13 def math_test(name, hdrs = [], deps = [], **kwargs):
14 """Add a target for the unittest of a math function.
15
16 Args:
17 name: The name of the function being tested.
18 hdrs: List of headers to add.
19 deps: The list of other libraries to be linked in to the test target.
20 **kwargs: Attributes relevant for a cc_test. For example, name, srcs.
21 """
22 test_name = name + "_test"
23 libc_test(
24 name = test_name,
25 srcs = [test_name + ".cpp"] + hdrs,
26 deps = ["//libc:func_name".replace("func_name", name)] + [
27 "//libc:__support_cpp_algorithm",
28 "//libc:__support_cpp_bit",
29 "//libc:__support_cpp_limits",
30 "//libc:__support_cpp_type_traits",
31 "//libc:__support_fputil_basic_operations",
32 "//libc:__support_fputil_cast",
33 "//libc:__support_fputil_fenv_impl",
34 "//libc:__support_fputil_fp_bits",
35 "//libc:__support_fputil_manipulation_functions",
36 "//libc:__support_fputil_nearest_integer_operations",
37 "//libc:__support_fputil_normal_float",
38 "//libc:__support_macros_properties_architectures",
39 "//libc:__support_macros_properties_os",
40 "//libc:__support_macros_properties_types",
41 "//libc:__support_math_extras",
42 "//libc:__support_uint128",
43 "//libc:hdr_errno_macros",
44 "//libc:hdr_fenv_macros",
45 "//libc:hdr_math_macros",
46 "//libc/test/UnitTest:fp_test_helpers",
47 ] + deps,
48 **kwargs
49 )
50
51 def math_mpfr_test(name, hdrs = [], deps = [], **kwargs):
52 """Add a target for the unittest of a math function.
53
54 Args:
55 name: The name of the function being tested.
56 hdrs: List of headers to add.
57 deps: The list of other libraries to be linked in to the test target.
58 **kwargs: Attributes relevant for a cc_test. For example, name, srcs.
59 """
60 math_test(
61 name = name,
62 hdrs = hdrs,
63 deps = deps + ["//libc/utils/MPFRWrapper:mpfr_wrapper"],
64 **kwargs
65 )