xref: /llvm-project/libc/test/src/__support/CMakeLists.txt (revision 51a0919412cf1868de689e03024c6f761a1b8b0a)
1add_custom_target(libc-support-tests)
2
3if(NOT LIBC_TARGET_OS_IS_GPU)
4  add_libc_test(
5    block_test
6    SUITE
7      libc-support-tests
8    SRCS
9      block_test.cpp
10    DEPENDS
11      libc.src.__support.CPP.array
12      libc.src.__support.CPP.bit
13      libc.src.__support.CPP.span
14      libc.src.__support.block
15      libc.src.string.memcpy
16  )
17
18  add_libc_test(
19    freelist_test
20    SUITE
21      libc-support-tests
22    SRCS
23      freelist_test.cpp
24    DEPENDS
25      libc.src.__support.CPP.array
26      libc.src.__support.CPP.span
27      libc.src.__support.block
28      libc.src.__support.freelist
29  )
30
31  add_libc_test(
32    freetrie_test
33    SUITE
34      libc-support-tests
35    SRCS
36      freetrie_test.cpp
37    DEPENDS
38      libc.src.__support.CPP.optional
39      libc.src.__support.block
40      libc.src.__support.freetrie
41  )
42
43  add_libc_test(
44    freestore_test
45    SUITE
46      libc-support-tests
47    SRCS
48      freestore_test.cpp
49    DEPENDS
50      libc.src.__support.CPP.optional
51      libc.src.__support.block
52      libc.src.__support.freelist
53      libc.src.__support.freestore
54      libc.src.__support.freetrie
55  )
56endif()
57
58# TODO: FreeListHeap uses the _end symbol which conflicts with the _end symbol
59# defined by GPU start.cpp files so for now we exclude this test on GPU.
60if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_GPU)
61  add_libc_test(
62    freelist_heap_test
63    SUITE
64      libc-support-tests
65    SRCS
66      fake_heap.s
67      freelist_heap_test.cpp
68    DEPENDS
69      libc.src.__support.CPP.span
70      libc.src.__support.freelist_heap
71      libc.src.string.memcmp
72      libc.src.string.memcpy
73  )
74endif()
75
76add_libc_test(
77  blockstore_test
78  SUITE
79    libc-support-tests
80  SRCS
81    blockstore_test.cpp
82  DEPENDS
83    libc.src.__support.blockstore
84)
85
86add_libc_test(
87  endian_internal_test
88  SUITE
89    libc-support-tests
90  SRCS
91    endian_internal_test.cpp
92  DEPENDS
93    libc.src.__support.common
94)
95
96add_libc_test(
97  math_extras_test
98  SUITE
99    libc-support-tests
100  SRCS
101    math_extras_test.cpp
102  DEPENDS
103    libc.src.__support.integer_literals
104    libc.src.__support.math_extras
105    libc.src.__support.uint128
106)
107
108add_libc_test(
109  high_precision_decimal_test
110  SUITE
111    libc-support-tests
112  SRCS
113  high_precision_decimal_test.cpp
114  DEPENDS
115    libc.src.__support.high_precision_decimal
116    libc.src.__support.uint128
117)
118
119add_libc_test(
120  str_to_float_test
121  SUITE
122    libc-support-tests
123  SRCS
124    str_to_float_test.cpp
125    str_to_double_test.cpp
126    str_to_long_double_test.cpp
127  DEPENDS
128    libc.src.__support.integer_literals
129    libc.src.__support.str_to_float
130    libc.src.__support.uint128
131    libc.src.errno.errno
132)
133
134
135add_libc_test(
136  str_to_integer_test
137  SUITE
138    libc-support-tests
139  SRCS
140    str_to_integer_test.cpp
141  DEPENDS
142    libc.src.__support.integer_literals
143    libc.src.__support.str_to_integer
144    libc.src.errno.errno
145)
146
147add_libc_test(
148  integer_to_string_test
149  SUITE
150    libc-support-tests
151  SRCS
152    integer_to_string_test.cpp
153  DEPENDS
154    libc.src.__support.big_int
155    libc.src.__support.CPP.limits
156    libc.src.__support.CPP.string_view
157    libc.src.__support.integer_literals
158    libc.src.__support.integer_to_string
159    libc.src.__support.uint128
160)
161
162add_libc_test(
163  arg_list_test
164  SUITE
165    libc-support-tests
166  SRCS
167    arg_list_test.cpp
168  DEPENDS
169    libc.src.__support.arg_list
170    libc.src.__support.macros.properties.os
171)
172
173# TODO: clang-cl generates calls into runtime library functions to
174# handle 128-bit integer arithmetics and conversions which are not yet
175# available on Windows. Re-enable 128-bit integer support on Windows once
176# these functions are ready.
177if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX AND NOT LIBC_TARGET_OS_IS_WINDOWS)
178  add_libc_test(
179    big_int_test
180    SUITE
181      libc-support-tests
182    SRCS
183      big_int_test.cpp
184    DEPENDS
185      libc.src.__support.big_int
186      libc.src.__support.CPP.optional
187      libc.src.__support.macros.properties.types
188  )
189endif()
190
191add_libc_test(
192  integer_literals_test
193  SUITE
194    libc-support-tests
195  SRCS
196    integer_literals_test.cpp
197  DEPENDS
198    libc.src.__support.CPP.optional
199    libc.src.__support.integer_literals
200    libc.src.__support.macros.properties.types
201)
202
203add_libc_test(
204  fixedvector_test
205  SUITE
206    libc-support-tests
207  SRCS
208    fixedvector_test.cpp
209  DEPENDS
210    libc.src.__support.CPP.array
211    libc.src.__support.fixedvector
212)
213
214add_libc_test(
215  char_vector_test
216  SUITE
217    libc-support-tests
218  SRCS
219    char_vector_test.cpp
220  DEPENDS
221    libc.src.__support.char_vector
222)
223
224add_libc_test(
225  hash_test
226  SUITE
227    libc-support-tests
228  SRCS
229    hash_test.cpp
230  DEPENDS
231    libc.src.__support.hash
232    libc.src.__support.CPP.new
233    libc.src.stdlib.rand
234    libc.src.stdlib.srand
235    libc.src.string.memset
236  COMPILE_OPTIONS
237    -O3
238  UNIT_TEST_ONLY
239    # Aligned Allocation is not supported in hermetic builds.
240)
241
242add_libc_test(
243  memory_size_test
244  SUITE
245    libc-support-tests
246  SRCS
247    memory_size_test.cpp
248  DEPENDS
249    libc.src.__support.memory_size
250)
251
252# FIXME: We shouldn't have regular executables created because we could be
253#        cross-compiling the tests and running through an emulator.
254if(NOT LIBC_TARGET_OS_IS_GPU)
255  add_executable(
256    libc_str_to_float_comparison_test
257    str_to_float_comparison_test.cpp
258  )
259
260  target_link_libraries(libc_str_to_float_comparison_test
261    PRIVATE
262      "${LIBC_TARGET}"
263  )
264
265  add_executable(
266    libc_system_str_to_float_comparison_test
267    str_to_float_comparison_test.cpp
268  )
269
270  set(float_test_file ${CMAKE_CURRENT_SOURCE_DIR}/str_to_float_comparison_data.txt)
271
272  add_custom_command(TARGET libc_str_to_float_comparison_test
273                     POST_BUILD
274                     COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:libc_str_to_float_comparison_test> ${float_test_file}
275                     DEPENDS ${float_test_file}
276                     COMMENT "Test the strtof and strtod implementations against precomputed results."
277                     VERBATIM)
278endif()
279
280add_subdirectory(CPP)
281add_subdirectory(File)
282add_subdirectory(RPC)
283add_subdirectory(OSUtil)
284add_subdirectory(FPUtil)
285add_subdirectory(fixed_point)
286add_subdirectory(HashTable)
287add_subdirectory(time)
288add_subdirectory(threads)
289