Skip to content

Commit 193dc72

Browse files
jtstogelAnthony Tran
authored andcommitted
[libc][bazel] Add bazel targets for libc/include/... tests. (llvm#141150)
This PR also sets `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 `//libc/test:LibcUnitTest`. This PR is missing tests for generated header includes since the current Bazel setup lacks generated headers or a mechanism to run hermetic tests. CMake version of the header include tests: https://github.com/llvm/llvm-project/blob/a2ce5647200ad40ae356affd44db7d054de444d2/libc/test/include/CMakeLists.txt#L515 See issue llvm#134780
1 parent edf91b8 commit 193dc72

File tree

3 files changed

+400
-11
lines changed

3 files changed

+400
-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
@@ -72,6 +72,9 @@ libc_test_library(
7272
"//libc:llvm_libc_macros_stdfix_macros",
7373
"//llvm:Support",
7474
],
75+
# Force linking in this library's `main()` to surface
76+
# a duplicate symbol error if a test defines its own main.
77+
alwayslink = True,
7578
)
7679

7780
libc_test_library(

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

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

0 commit comments

Comments
 (0)