Skip to content

Commit 7dddbb8

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 9d33b92 commit 7dddbb8

File tree

3 files changed

+368
-11
lines changed

3 files changed

+368
-11
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ libc_test_library(
7171
"//libc:llvm_libc_macros_stdfix_macros",
7272
"//llvm:Support",
7373
],
74+
# Force linking in this library's `main()` to surface
75+
# a duplicate symbol error if a test defines its own main.
76+
alwayslink = True,
7477
)
7578

7679
libc_test_library(

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

Lines changed: 345 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,363 @@
44

55
# Tests for LLVM libc public headers.
66

7-
load("//libc/test:libc_test_rules.bzl", "libc_test")
7+
load("//libc/test:libc_test_rules.bzl", "libc_test", "libc_test_library")
88

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

1111
licenses(["notice"])
1212

13+
libc_test(
14+
name = "assert_test",
15+
srcs = ["assert_test.cpp"],
16+
deps = ["//libc:public_headers_deps"],
17+
)
18+
19+
libc_test(
20+
name = "complex_test",
21+
srcs = ["complex_test.cpp"],
22+
deps = [
23+
"//libc:public_headers_deps",
24+
"//libc/test/UnitTest:fp_test_helpers",
25+
],
26+
)
27+
28+
libc_test_library(
29+
name = "fpclassify_test_fixture",
30+
hdrs = ["FpClassifyTest.h"],
31+
deps = [
32+
"//libc:public_headers_deps",
33+
"//libc/test/UnitTest:LibcUnitTest",
34+
"//libc/test/UnitTest:fp_test_helpers",
35+
],
36+
)
37+
38+
libc_test(
39+
name = "fpclassify_test",
40+
srcs = ["fpclassify_test.cpp"],
41+
deps = [
42+
":fpclassify_test_fixture",
43+
"//libc:public_headers_deps",
44+
],
45+
)
46+
47+
libc_test(
48+
name = "fpclassifyf_test",
49+
srcs = ["fpclassifyf_test.cpp"],
50+
deps = [
51+
":fpclassify_test_fixture",
52+
"//libc:public_headers_deps",
53+
],
54+
)
55+
56+
libc_test(
57+
name = "fpclassifyl_test",
58+
srcs = ["fpclassifyl_test.cpp"],
59+
deps = [
60+
":fpclassify_test_fixture",
61+
"//libc:public_headers_deps",
62+
],
63+
)
64+
65+
libc_test(
66+
name = "fpclassify_c_test",
67+
srcs = ["fpclassify_test.c"],
68+
use_test_framework = False,
69+
deps = ["//libc:public_headers_deps"],
70+
)
71+
72+
libc_test_library(
73+
name = "isfinite_test_fixture",
74+
hdrs = ["IsFiniteTest.h"],
75+
deps = [
76+
"//libc:public_headers_deps",
77+
"//libc/test/UnitTest:LibcUnitTest",
78+
"//libc/test/UnitTest:fp_test_helpers",
79+
],
80+
)
81+
82+
libc_test(
83+
name = "isfinite_test",
84+
srcs = ["isfinite_test.cpp"],
85+
deps = [
86+
":isfinite_test_fixture",
87+
"//libc:public_headers_deps",
88+
],
89+
)
90+
91+
libc_test(
92+
name = "isfinitef_test",
93+
srcs = ["isfinitef_test.cpp"],
94+
deps = [
95+
":isfinite_test_fixture",
96+
"//libc:public_headers_deps",
97+
],
98+
)
99+
100+
libc_test(
101+
name = "isfinitel_test",
102+
srcs = ["isfinitel_test.cpp"],
103+
deps = [
104+
":isfinite_test_fixture",
105+
"//libc:public_headers_deps",
106+
],
107+
)
108+
109+
libc_test(
110+
name = "isfinite_c_test",
111+
srcs = ["isfinite_test.c"],
112+
use_test_framework = False,
113+
deps = ["//libc:public_headers_deps"],
114+
)
115+
116+
libc_test_library(
117+
name = "isinf_test_fixture",
118+
hdrs = ["IsInfTest.h"],
119+
deps = [
120+
"//libc:public_headers_deps",
121+
"//libc/test/UnitTest:LibcUnitTest",
122+
"//libc/test/UnitTest:fp_test_helpers",
123+
],
124+
)
125+
126+
libc_test(
127+
name = "isinf_test",
128+
srcs = ["isinf_test.cpp"],
129+
deps = [
130+
":isinf_test_fixture",
131+
"//libc:public_headers_deps",
132+
],
133+
)
134+
135+
libc_test(
136+
name = "isinff_test",
137+
srcs = ["isinff_test.cpp"],
138+
deps = [
139+
":isinf_test_fixture",
140+
"//libc:public_headers_deps",
141+
],
142+
)
143+
144+
libc_test(
145+
name = "isinfl_test",
146+
srcs = ["isinfl_test.cpp"],
147+
deps = [
148+
":isinf_test_fixture",
149+
"//libc:public_headers_deps",
150+
],
151+
)
152+
153+
libc_test(
154+
name = "isinf_c_test",
155+
srcs = ["isinf_test.c"],
156+
use_test_framework = False,
157+
deps = ["//libc:public_headers_deps"],
158+
)
159+
160+
libc_test_library(
161+
name = "isnan_test_fixture",
162+
hdrs = ["IsNanTest.h"],
163+
deps = [
164+
"//libc:public_headers_deps",
165+
"//libc/test/UnitTest:LibcUnitTest",
166+
"//libc/test/UnitTest:fp_test_helpers",
167+
],
168+
)
169+
170+
libc_test(
171+
name = "isnan_test",
172+
srcs = ["isnan_test.cpp"],
173+
deps = [
174+
":isnan_test_fixture",
175+
"//libc:public_headers_deps",
176+
],
177+
)
178+
179+
libc_test(
180+
name = "isnanf_test",
181+
srcs = ["isnanf_test.cpp"],
182+
deps = [
183+
":isnan_test_fixture",
184+
"//libc:public_headers_deps",
185+
],
186+
)
187+
188+
libc_test(
189+
name = "isnanl_test",
190+
srcs = ["isnanl_test.cpp"],
191+
deps = [
192+
":isnan_test_fixture",
193+
"//libc:public_headers_deps",
194+
],
195+
)
196+
197+
libc_test(
198+
name = "isnan_c_test",
199+
srcs = ["isnan_test.c"],
200+
use_test_framework = False,
201+
deps = ["//libc:public_headers_deps"],
202+
)
203+
204+
libc_test_library(
205+
name = "isnormal_test_fixture",
206+
hdrs = ["IsNormalTest.h"],
207+
deps = [
208+
"//libc:public_headers_deps",
209+
"//libc/test/UnitTest:LibcUnitTest",
210+
"//libc/test/UnitTest:fp_test_helpers",
211+
],
212+
)
213+
214+
libc_test(
215+
name = "isnormal_test",
216+
srcs = ["isnormal_test.cpp"],
217+
deps = [
218+
":isnormal_test_fixture",
219+
"//libc:public_headers_deps",
220+
],
221+
)
222+
223+
libc_test(
224+
name = "isnormalf_test",
225+
srcs = ["isnormalf_test.cpp"],
226+
deps = [
227+
":isnormal_test_fixture",
228+
"//libc:public_headers_deps",
229+
],
230+
)
231+
232+
libc_test(
233+
name = "isnormall_test",
234+
srcs = ["isnormall_test.cpp"],
235+
deps = [
236+
":isnormal_test_fixture",
237+
"//libc:public_headers_deps",
238+
],
239+
)
240+
241+
libc_test(
242+
name = "isnormal_c_test",
243+
srcs = ["isnormal_test.c"],
244+
use_test_framework = False,
245+
deps = ["//libc:public_headers_deps"],
246+
)
247+
248+
libc_test(
249+
name = "issubnormal_c_test",
250+
srcs = ["issubnormal_test.c"],
251+
use_test_framework = False,
252+
deps = ["//libc:public_headers_deps"],
253+
)
254+
255+
libc_test_library(
256+
name = "iszero_test_fixture",
257+
hdrs = ["IsZeroTest.h"],
258+
deps = [
259+
"//libc:public_headers_deps",
260+
"//libc/test/UnitTest:LibcUnitTest",
261+
"//libc/test/UnitTest:fp_test_helpers",
262+
],
263+
)
264+
265+
libc_test(
266+
name = "iszero_test",
267+
srcs = ["iszero_test.cpp"],
268+
deps = [
269+
":iszero_test_fixture",
270+
"//libc:public_headers_deps",
271+
],
272+
)
273+
274+
libc_test(
275+
name = "iszerof_test",
276+
srcs = ["iszerof_test.cpp"],
277+
deps = [
278+
":iszero_test_fixture",
279+
"//libc:public_headers_deps",
280+
],
281+
)
282+
283+
libc_test(
284+
name = "iszerol_test",
285+
srcs = ["iszerol_test.cpp"],
286+
deps = [
287+
":iszero_test_fixture",
288+
"//libc:public_headers_deps",
289+
],
290+
)
291+
292+
libc_test(
293+
name = "iszero_c_test",
294+
srcs = ["iszero_test.c"],
295+
use_test_framework = False,
296+
deps = ["//libc:public_headers_deps"],
297+
)
298+
299+
libc_test_library(
300+
name = "signbit_test_fixture",
301+
hdrs = ["SignbitTest.h"],
302+
deps = [
303+
"//libc:public_headers_deps",
304+
"//libc/test/UnitTest:LibcUnitTest",
305+
"//libc/test/UnitTest:fp_test_helpers",
306+
],
307+
)
308+
309+
libc_test(
310+
name = "signbit_test",
311+
srcs = ["signbit_test.cpp"],
312+
deps = [
313+
":signbit_test_fixture",
314+
"//libc:public_headers_deps",
315+
],
316+
)
317+
318+
libc_test(
319+
name = "signbitf_test",
320+
srcs = ["signbitf_test.cpp"],
321+
deps = [
322+
":signbit_test_fixture",
323+
"//libc:public_headers_deps",
324+
],
325+
)
326+
327+
libc_test(
328+
name = "signbitl_test",
329+
srcs = ["signbitl_test.cpp"],
330+
deps = [
331+
":signbit_test_fixture",
332+
"//libc:public_headers_deps",
333+
],
334+
)
335+
13336
libc_test(
14337
name = "stdbit_test",
15338
srcs = [
16339
"stdbit_stub.h",
17340
"stdbit_test.cpp",
18341
],
342+
deps = ["//libc:public_headers_deps"],
343+
)
344+
345+
libc_test(
346+
name = "signbit_c_test",
347+
srcs = ["signbit_test.c"],
348+
use_test_framework = False,
349+
deps = ["//libc:public_headers_deps"],
350+
)
351+
352+
libc_test(
353+
name = "stdckdint_test",
354+
srcs = ["stdckdint_test.cpp"],
355+
deps = ["//libc:public_headers_deps"],
356+
)
357+
358+
libc_test(
359+
name = "sys_queue_test",
360+
srcs = ["sys/queue_test.cpp"],
19361
deps = [
362+
"//libc:__support_char_vector",
363+
"//libc:__support_cpp_string",
20364
"//libc:public_headers_deps",
21365
],
22366
)

0 commit comments

Comments
 (0)