Skip to content

Commit ea15c9e

Browse files
committed
Add bazel targets for libc/include/... tests.
Also, set `alwayslink=True` for `//libc/test:LibcUnitTest`. This ensures that the `main` function provided always gets linked into a test target. While not strictly necessary, it makes it so tests like https://github.com/llvm/llvm-project/blob/45d8759cbed0f216786729718608a8be72a505c6/libc/test/include/signbit_test.c will give a duplicate symbol error if they incorrectly depend on `LibcUnitTest`.
1 parent 45d8759 commit ea15c9e

File tree

4 files changed

+356
-18
lines changed

4 files changed

+356
-18
lines changed

utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ libc_test_library(
7171
"//libc:llvm_libc_macros_stdfix_macros",
7272
"//llvm:Support",
7373
],
74+
alwayslink = True,
7475
)
7576

7677
libc_test_library(

utils/bazel/llvm-project-overlay/libc/test/include/BUILD.bazel

Lines changed: 302 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,315 @@
44

55
# Tests for LLVM libc public headers.
66

7-
load("//libc/test:libc_test_rules.bzl", "libc_test")
8-
9-
package(default_visibility = ["//visibility:public"])
7+
load("//libc/test:libc_test_rules.bzl", "libc_c_test", "libc_test", "libc_test_library")
108

119
licenses(["notice"])
1210

11+
libc_test(
12+
name = "assert_test",
13+
srcs = ["assert_test.cpp"],
14+
deps = ["//libc:public_headers_deps"],
15+
)
16+
17+
libc_test(
18+
name = "complex_test",
19+
srcs = ["complex_test.cpp"],
20+
deps = [
21+
"//libc:public_headers_deps",
22+
"//libc/test/UnitTest:fp_test_helpers",
23+
],
24+
)
25+
26+
libc_test_library(
27+
name = "fpclassify_test_fixture",
28+
hdrs = ["FpClassifyTest.h"],
29+
deps = ["//libc/test/UnitTest:fp_test_helpers"],
30+
)
31+
32+
libc_test(
33+
name = "fpclassify_test",
34+
srcs = ["fpclassify_test.cpp"],
35+
deps = [
36+
":fpclassify_test_fixture",
37+
"//libc:public_headers_deps",
38+
],
39+
)
40+
41+
libc_test(
42+
name = "fpclassifyf_test",
43+
srcs = ["fpclassifyf_test.cpp"],
44+
deps = [
45+
":fpclassify_test_fixture",
46+
"//libc:public_headers_deps",
47+
],
48+
)
49+
50+
libc_test(
51+
name = "fpclassifyl_test",
52+
srcs = ["fpclassifyl_test.cpp"],
53+
deps = [
54+
":fpclassify_test_fixture",
55+
"//libc:public_headers_deps",
56+
],
57+
)
58+
59+
libc_c_test(
60+
name = "fpclassify_c_test",
61+
srcs = ["fpclassify_test.c"],
62+
deps = ["//libc:public_headers_deps"],
63+
)
64+
65+
libc_test_library(
66+
name = "isfinite_test_ficture",
67+
hdrs = ["IsFiniteTest.h"],
68+
deps = ["//libc/test/UnitTest:fp_test_helpers"],
69+
)
70+
71+
libc_test(
72+
name = "isfinite_test",
73+
srcs = ["isfinite_test.cpp"],
74+
deps = [
75+
":isfinite_test_ficture",
76+
"//libc:public_headers_deps",
77+
],
78+
)
79+
80+
libc_test(
81+
name = "isfinitef_test",
82+
srcs = ["isfinitef_test.cpp"],
83+
deps = [
84+
":isfinite_test_ficture",
85+
"//libc:public_headers_deps",
86+
],
87+
)
88+
89+
libc_test(
90+
name = "isfinitel_test",
91+
srcs = ["isfinitel_test.cpp"],
92+
deps = [
93+
":isfinite_test_ficture",
94+
"//libc:public_headers_deps",
95+
],
96+
)
97+
98+
libc_c_test(
99+
name = "isfinite_c_test",
100+
srcs = ["isfinite_test.c"],
101+
deps = ["//libc:public_headers_deps"],
102+
)
103+
104+
libc_test_library(
105+
name = "isinf_test_fixture",
106+
hdrs = ["IsInfTest.h"],
107+
deps = ["//libc/test/UnitTest:fp_test_helpers"],
108+
)
109+
110+
libc_test(
111+
name = "isinf_test",
112+
srcs = ["isinf_test.cpp"],
113+
deps = [
114+
":isinf_test_fixture",
115+
"//libc:public_headers_deps",
116+
],
117+
)
118+
119+
libc_test(
120+
name = "isinff_test",
121+
srcs = ["isinff_test.cpp"],
122+
deps = [
123+
":isinf_test_fixture",
124+
"//libc:public_headers_deps",
125+
],
126+
)
127+
128+
libc_test(
129+
name = "isinfl_test",
130+
srcs = ["isinfl_test.cpp"],
131+
deps = [
132+
":isinf_test_fixture",
133+
"//libc:public_headers_deps",
134+
],
135+
)
136+
137+
libc_c_test(
138+
name = "isinf_c_test",
139+
srcs = ["isinf_test.c"],
140+
deps = ["//libc:public_headers_deps"],
141+
)
142+
143+
libc_test_library(
144+
name = "isnan_test_fixture",
145+
hdrs = ["IsNanTest.h"],
146+
deps = ["//libc/test/UnitTest:fp_test_helpers"],
147+
)
148+
149+
libc_test(
150+
name = "isnan_test",
151+
srcs = ["isnan_test.cpp"],
152+
deps = [
153+
":isnan_test_fixture",
154+
"//libc:public_headers_deps",
155+
],
156+
)
157+
158+
libc_test(
159+
name = "isnanf_test",
160+
srcs = ["isnanf_test.cpp"],
161+
deps = [
162+
":isnan_test_fixture",
163+
"//libc:public_headers_deps",
164+
],
165+
)
166+
167+
libc_test(
168+
name = "isnanl_test",
169+
srcs = ["isnanl_test.cpp"],
170+
deps = [
171+
":isnan_test_fixture",
172+
"//libc:public_headers_deps",
173+
],
174+
)
175+
176+
libc_c_test(
177+
name = "isnan_c_test",
178+
srcs = ["isnan_test.c"],
179+
deps = ["//libc:public_headers_deps"],
180+
)
181+
182+
libc_test_library(
183+
name = "isnormal_test_fixture",
184+
hdrs = ["IsNormalTest.h"],
185+
deps = ["//libc/test/UnitTest:fp_test_helpers"],
186+
)
187+
188+
libc_test(
189+
name = "isnormal_test",
190+
srcs = ["isnormal_test.cpp"],
191+
deps = [
192+
":isnormal_test_fixture",
193+
"//libc:public_headers_deps",
194+
],
195+
)
196+
197+
libc_test(
198+
name = "isnormalf_test",
199+
srcs = ["isnormalf_test.cpp"],
200+
deps = [
201+
":isnormal_test_fixture",
202+
"//libc:public_headers_deps",
203+
],
204+
)
205+
206+
libc_test(
207+
name = "isnormall_test",
208+
srcs = ["isnormall_test.cpp"],
209+
deps = [
210+
":isnormal_test_fixture",
211+
"//libc:public_headers_deps",
212+
],
213+
)
214+
215+
libc_c_test(
216+
name = "isnormal_c_test",
217+
srcs = ["isnormal_test.c"],
218+
deps = ["//libc:public_headers_deps"],
219+
)
220+
221+
libc_c_test(
222+
name = "issubnormal_c_test",
223+
srcs = ["issubnormal_test.c"],
224+
deps = ["//libc:public_headers_deps"],
225+
)
226+
227+
libc_test_library(
228+
name = "iszero_test_fixture",
229+
hdrs = ["IsZeroTest.h"],
230+
deps = ["//libc/test/UnitTest:fp_test_helpers"],
231+
)
232+
233+
libc_test(
234+
name = "iszero_test",
235+
srcs = ["iszero_test.cpp"],
236+
deps = [
237+
":iszero_test_fixture",
238+
"//libc:public_headers_deps",
239+
],
240+
)
241+
242+
libc_test(
243+
name = "iszerof_test",
244+
srcs = ["iszerof_test.cpp"],
245+
deps = [
246+
":iszero_test_fixture",
247+
"//libc:public_headers_deps",
248+
],
249+
)
250+
251+
libc_test(
252+
name = "iszerol_test",
253+
srcs = ["iszerol_test.cpp"],
254+
deps = [
255+
":iszero_test_fixture",
256+
"//libc:public_headers_deps",
257+
],
258+
)
259+
260+
libc_c_test(
261+
name = "iszero_c_test",
262+
srcs = ["iszero_test.c"],
263+
deps = ["//libc:public_headers_deps"],
264+
)
265+
266+
libc_test_library(
267+
name = "signbit_test_fixture",
268+
hdrs = ["SignbitTest.h"],
269+
deps = ["//libc/test/UnitTest:fp_test_helpers"],
270+
)
271+
272+
libc_test(
273+
name = "signbit_test",
274+
srcs = ["signbit_test.cpp"],
275+
deps = [
276+
":signbit_test_fixture",
277+
"//libc:public_headers_deps",
278+
],
279+
)
280+
281+
libc_test(
282+
name = "signbitf_test",
283+
srcs = ["signbitf_test.cpp"],
284+
deps = [
285+
":signbit_test_fixture",
286+
"//libc:public_headers_deps",
287+
],
288+
)
289+
290+
libc_test(
291+
name = "signbitl_test",
292+
srcs = ["signbitl_test.cpp"],
293+
deps = [
294+
":signbit_test_fixture",
295+
"//libc:public_headers_deps",
296+
],
297+
)
298+
13299
libc_test(
14300
name = "stdbit_test",
15301
srcs = [
16302
"stdbit_stub.h",
17303
"stdbit_test.cpp",
18304
],
19-
deps = [
20-
"//libc:public_headers_deps",
21-
],
305+
deps = ["//libc:public_headers_deps"],
306+
)
307+
308+
libc_c_test(
309+
name = "signbit_c_test",
310+
srcs = ["signbit_test.c"],
311+
deps = ["//libc:public_headers_deps"],
312+
)
313+
314+
libc_test(
315+
name = "stdckdint_test",
316+
srcs = ["stdckdint_test.cpp"],
317+
deps = ["//libc:public_headers_deps"],
22318
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 public headers.
6+
7+
load("//libc/test:libc_test_rules.bzl", "libc_test")
8+
9+
package(default_visibility = ["//visibility:public"])
10+
11+
licenses(["notice"])
12+
13+
libc_test(
14+
name = "queue_test",
15+
srcs = ["queue_test.cpp"],
16+
deps = [
17+
"//libc:__support_char_vector",
18+
"//libc:__support_cpp_string",
19+
"//libc:public_headers_deps",
20+
],
21+
)

0 commit comments

Comments
 (0)