blob: a39428fb8d16cf0d232862643cb9988f0bbb26f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
add_custom_target(libc_stdio_unittests)
add_libc_test(
fileop_test
SUITE
libc_stdio_unittests
SRCS
fileop_test.cpp
DEPENDS
libc.include.stdio
libc.src.errno.errno
libc.src.stdio.clearerr
libc.src.stdio.fclose
libc.src.stdio.feof
libc.src.stdio.ferror
libc.src.stdio.fflush
libc.src.stdio.fileno
libc.src.stdio.fopen
libc.src.stdio.fputs
libc.src.stdio.fread
libc.src.stdio.fseek
libc.src.stdio.fwrite
libc.test.UnitTest.ErrnoCheckingTest
)
add_libc_test(
ungetc_test
SUITE
libc_stdio_unittests
SRCS
ungetc_test.cpp
DEPENDS
libc.include.stdio
libc.src.stdio.fclose
libc.src.stdio.fopen
libc.src.stdio.fread
libc.src.stdio.fseek
libc.src.stdio.fwrite
libc.src.stdio.ungetc
)
add_libc_test(
setbuf_test
SUITE
libc_stdio_unittests
SRCS
setbuf_test.cpp
DEPENDS
libc.include.stdio
libc.src.stdio.fclose
libc.src.stdio.fopen
libc.src.stdio.fread
libc.src.stdio.fwrite
libc.src.stdio.setbuf
libc.src.stdio.ungetc
)
add_libc_test(
setvbuf_test
SUITE
libc_stdio_unittests
SRCS
setvbuf_test.cpp
DEPENDS
libc.include.stdio
libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.fopen
libc.src.stdio.fread
libc.src.stdio.fwrite
libc.src.stdio.setvbuf
libc.test.UnitTest.ErrnoCheckingTest
)
add_libc_test(
unlocked_fileop_test
SUITE
libc_stdio_unittests
SRCS
unlocked_fileop_test.cpp
DEPENDS
libc.include.stdio
libc.src.errno.errno
libc.src.stdio.clearerr_unlocked
libc.src.stdio.fclose
libc.src.stdio.feof_unlocked
libc.src.stdio.ferror_unlocked
libc.src.stdio.flockfile
libc.src.stdio.fopen
libc.src.stdio.fread_unlocked
libc.src.stdio.funlockfile
libc.src.stdio.fwrite_unlocked
libc.test.UnitTest.ErrnoCheckingTest
)
add_libc_test(
fopencookie_test
SUITE
libc_stdio_unittests
SRCS
fopencookie_test.cpp
DEPENDS
libc.include.stdio
libc.hdr.types.size_t
libc.src.errno.errno
libc.src.stdio.clearerr
libc.src.stdio.fclose
libc.src.stdio.feof
libc.src.stdio.ferror
libc.src.stdio.fflush
libc.src.stdio.fopencookie
libc.src.stdio.fread
libc.src.stdio.fseek
libc.src.stdio.fwrite
libc.test.UnitTest.ErrnoCheckingTest
LINK_LIBRARIES
LibcMemoryHelpers
)
if(LIBC_CONF_PRINTF_DISABLE_FLOAT)
list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_FLOAT")
endif()
if(LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_DYADIC_FLOAT OR
LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320)
list(APPEND sprintf_test_copts "-DLIBC_COPT_FLOAT_TO_STR_REDUCED_PRECISION")
endif()
if(LIBC_CONF_PRINTF_DISABLE_INDEX_MODE)
list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_INDEX_MODE")
endif()
if(LIBC_CONF_PRINTF_DISABLE_WRITE_INT)
list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_WRITE_INT")
endif()
if(LIBC_CONF_PRINTF_DISABLE_FIXED_POINT)
list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_FIXED_POINT")
endif()
if(LIBC_CONF_PRINTF_DISABLE_STRERROR)
list(APPEND sprintf_test_copts "-DLIBC_COPT_PRINTF_DISABLE_STRERROR")
endif()
add_fp_unittest(
sprintf_test
UNIT_TEST_ONLY
SUITE
libc_stdio_unittests
SRCS
sprintf_test.cpp
DEPENDS
libc.src.stdio.sprintf
libc.src.__support.FPUtil.fp_bits
libc.include.inttypes
COMPILE_OPTIONS
${sprintf_test_copts}
)
add_libc_test(
snprintf_test
SUITE
libc_stdio_unittests
SRCS
snprintf_test.cpp
DEPENDS
libc.src.stdio.snprintf
)
if(LLVM_LIBC_FULL_BUILD)
# In fullbuild mode, fprintf's tests use the internal FILE for other functions.
list(APPEND fprintf_test_deps
libc.src.stdio.fclose
libc.src.stdio.ferror
libc.src.stdio.fopen
libc.src.stdio.fread
)
# This is to be used for tests which write to libc's platform streams
# under full build but write to system-lib's streams otherwise.
set(hermetic_test_only HERMETIC_TEST_ONLY)
else()
# Else in overlay mode they use the system's FILE.
set(use_system_file "-DLIBC_COPT_STDIO_USE_SYSTEM_FILE")
endif()
add_libc_test(
fprintf_test
SUITE
libc_stdio_unittests
SRCS
fprintf_test.cpp
DEPENDS
libc.src.stdio.fprintf
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
libc.src.__support.macros.properties.architectures
${fprintf_test_deps}
COMPILE_OPTIONS
${use_system_file}
)
add_libc_test(
printf_test
${hermetic_test_only}
SUITE
libc_stdio_unittests
SRCS
printf_test.cpp
DEPENDS
libc.src.stdio.printf
)
add_libc_test(
asprintf_test
SUITE
libc_stdio_unittests
SRCS
asprintf_test.cpp
DEPENDS
libc.src.stdio.asprintf
libc.src.string.memset
libc.include.stdlib
libc.src.stdio.sprintf
)
add_fp_unittest(
vsprintf_test
UNIT_TEST_ONLY
SUITE
libc_stdio_unittests
SRCS
vsprintf_test.cpp
DEPENDS
libc.src.stdio.vsprintf
)
add_libc_test(
vsnprintf_test
SUITE
libc_stdio_unittests
SRCS
vsnprintf_test.cpp
DEPENDS
libc.src.stdio.vsnprintf
)
add_libc_test(
vfprintf_test
SUITE
libc_stdio_unittests
SRCS
vfprintf_test.cpp
DEPENDS
libc.src.stdio.vfprintf
${fprintf_test_deps}
COMPILE_OPTIONS
${use_system_file}
)
add_libc_test(
vprintf_test
${hermetic_test_only}
SUITE
libc_stdio_unittests
SRCS
vprintf_test.cpp
DEPENDS
libc.src.stdio.vprintf
)
add_libc_test(
vasprintf_test
SUITE
libc_stdio_unittests
SRCS
vasprintf_test.cpp
DEPENDS
libc.src.stdio.vasprintf
libc.src.string.memset
libc.include.stdlib
)
if(LLVM_LIBC_FULL_BUILD)
# In fullbuild mode, fscanf's tests use the internal FILE for other functions.
list(APPEND fscanf_test_deps
libc.src.stdio.fclose
libc.src.stdio.ferror
libc.src.stdio.fopen
libc.src.stdio.fwrite
)
endif()
# FIXME: These tests currently fail on AMDGPU due to an optimization bug in the
# `amdgpu-attributor` pass. Disable until that's fixed.
if(NOT LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
add_libc_test(
fscanf_test
SUITE
libc_stdio_unittests
SRCS
fscanf_test.cpp
DEPENDS
libc.src.stdio.fscanf
${fscanf_test_deps}
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)
add_libc_test(
vfscanf_test
SUITE
libc_stdio_unittests
SRCS
vfscanf_test.cpp
DEPENDS
libc.src.stdio.vfscanf
${fscanf_test_deps}
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)
endif()
if(LIBC_CONF_SCANF_DISABLE_FLOAT)
list(APPEND sscanf_test_copts "-DLIBC_COPT_SCANF_DISABLE_FLOAT")
endif()
if(LIBC_CONF_SCANF_DISABLE_INDEX_MODE)
list(APPEND sscanf_test_copts "-DLIBC_COPT_SCANF_DISABLE_INDEX_MODE")
endif()
add_libc_test(
sscanf_test
SUITE
libc_stdio_unittests
SRCS
sscanf_test.cpp
DEPENDS
libc.src.stdio.sscanf
LINK_LIBRARIES
LibcFPTestHelpers
COMPILE_OPTIONS
${sscanf_test_copts}
)
add_libc_test(
vsscanf_test
SUITE
libc_stdio_unittests
SRCS
vsscanf_test.cpp
DEPENDS
libc.src.stdio.vsscanf
LINK_LIBRARIES
LibcFPTestHelpers
COMPILE_OPTIONS
${sscanf_test_copts}
)
add_libc_test(
puts_test
HERMETIC_TEST_ONLY # writes to libc's stdout
SUITE
libc_stdio_unittests
SRCS
puts_test.cpp
DEPENDS
libc.src.stdio.puts
)
add_libc_test(
perror_test
HERMETIC_TEST_ONLY # writes to libc's stderr
SUITE
libc_stdio_unittests
SRCS
perror_test.cpp
DEPENDS
libc.src.stdio.perror
libc.src.errno.errno
)
add_libc_test(
fputs_test
HERMETIC_TEST_ONLY # writes to libc's stdout and stderr
SUITE
libc_stdio_unittests
SRCS
fputs_test.cpp
DEPENDS
libc.src.stdio.fputs
libc.src.stdio.stdout
libc.src.stdio.stderr
)
add_libc_test(
fputc_test
HERMETIC_TEST_ONLY # writes to libc's stdout and stderr
SUITE
libc_stdio_unittests
SRCS
fputc_test.cpp
DEPENDS
libc.src.stdio.fputc
libc.src.stdio.putchar
libc.src.stdio.stdout
libc.src.stdio.stderr
)
add_libc_test(
fopen_test
SUITE
libc_stdio_unittests
SRCS
fopen_test.cpp
DEPENDS
libc.src.stdio.fread
libc.src.stdio.fwrite
libc.src.stdio.fclose
libc.src.stdio.fopen
)
add_libc_test(
putc_test
SUITE
libc_stdio_unittests
SRCS
putc_test.cpp
DEPENDS
libc.src.stdio.putc
libc.src.stdio.fclose
libc.src.stdio.ferror
libc.src.stdio.fopen
libc.src.stdio.fread
)
if(${LIBC_TARGET_OS} STREQUAL "linux")
add_libc_test(
remove_test
SUITE
libc_stdio_unittests
SRCS
remove_test.cpp
DEPENDS
libc.include.unistd
libc.src.errno.errno
libc.src.fcntl.open
libc.src.stdio.remove
libc.src.sys.stat.mkdirat
libc.src.unistd.access
libc.src.unistd.close
libc.test.UnitTest.ErrnoCheckingTest
)
add_libc_test(
rename_test
SUITE
libc_stdio_unittests
SRCS
rename_test.cpp
DEPENDS
libc.src.errno.errno
libc.src.fcntl.open
libc.src.stdio.rename
libc.src.unistd.access
libc.src.unistd.close
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
add_libc_test(
fdopen_test
SUITE
libc_stdio_unittests
SRCS
fdopen_test.cpp
DEPENDS
libc.src.fcntl.open
libc.src.stdio.fclose
libc.src.stdio.fdopen
libc.src.stdio.fgets
libc.src.stdio.fputs
libc.src.unistd.close
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
endif()
add_libc_test(
fgetc_test
SUITE
libc_stdio_unittests
SRCS
fgetc_test.cpp
DEPENDS
libc.include.stdio
libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.feof
libc.src.stdio.ferror
libc.src.stdio.fgetc
libc.src.stdio.fopen
libc.src.stdio.fwrite
libc.src.stdio.getc
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
add_libc_test(
fgetc_unlocked_test
SUITE
libc_stdio_unittests
SRCS
fgetc_unlocked_test.cpp
DEPENDS
libc.include.stdio
libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.ferror
libc.src.stdio.ferror_unlocked
libc.src.stdio.feof
libc.src.stdio.feof_unlocked
libc.src.stdio.fgetc_unlocked
libc.src.stdio.flockfile
libc.src.stdio.fopen
libc.src.stdio.funlockfile
libc.src.stdio.fwrite
libc.src.stdio.getc_unlocked
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
add_libc_test(
fgets_test
SUITE
libc_stdio_unittests
SRCS
fgets_test.cpp
DEPENDS
libc.include.stdio
libc.src.errno.errno
libc.src.stdio.fclose
libc.src.stdio.feof
libc.src.stdio.ferror
libc.src.stdio.fgets
libc.src.stdio.fopen
libc.src.stdio.fwrite
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
add_libc_test(
ftell_test
SUITE
libc_stdio_unittests
SRCS
ftell_test.cpp
DEPENDS
libc.include.stdio
libc.src.stdio.fclose
libc.src.stdio.fflush
libc.src.stdio.fopen
libc.src.stdio.fread
libc.src.stdio.fseek
libc.src.stdio.ftell
libc.src.stdio.fseeko
libc.src.stdio.ftello
libc.src.stdio.fwrite
libc.src.stdio.setvbuf
)
# Create an output directory for any temporary test files.
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testdata)
if(LIBC_TARGET_OS_IS_GPU)
return()
endif()
add_subdirectory(printf_core)
add_subdirectory(scanf_core)
add_subdirectory(testdata)
|