malloc/Makefile: Split and sort tests
[glibc.git] / libio / Makefile
blob0c1f16ee3b54c2d32fe930aed398c2a049d8175b
1 # Copyright (C) 1995-2024 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
19 # Specific makefile for libio.
21 subdir := libio
23 include ../Makeconfig
25 headers := stdio.h \
26 bits/stdio.h bits/stdio2.h bits/stdio2-decl.h bits/stdio-ldbl.h \
27 bits/types/FILE.h bits/types/__FILE.h bits/types/struct_FILE.h \
28 bits/types/__fpos_t.h bits/types/__fpos64_t.h \
29 bits/types/cookie_io_functions_t.h
31 routines := \
32 filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \
33 iofopncook iofputs iofread iofsetpos ioftell wfiledoalloc \
34 iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs \
35 ioseekoff ioseekpos iosetbuffer iosetvbuf ioungetc \
36 iovsprintf iovsscanf \
37 iofgetpos64 iofopen64 iofsetpos64 \
38 fputwc fputwc_u getwc getwc_u getwchar getwchar_u iofgetws iofgetws_u \
39 iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \
40 putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf \
41 wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops \
42 wstrops wfileops iofwide fwide wmemstream \
44 clearerr feof ferror fileno fputc freopen fseek getc getchar \
45 memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \
46 iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello \
47 freopen64 fseeko64 ftello64 \
49 __fbufsize __freading __fwriting __freadable __fwritable __flbf \
50 __fpurge __fpending __fsetlocking \
52 libc_fatal fmemopen oldfmemopen vtables
54 gen-as-const-headers += libio-macros.sym
56 # Exclude fortified routines from being built with _FORTIFY_SOURCE
57 routines_no_fortify += \
58 fwprintf \
59 iofgets \
60 iofgets_u \
61 iofgetws \
62 iofgetws_u \
63 swprintf \
64 vasprintf \
65 vsnprintf \
66 vswprintf \
67 vwprintf \
68 wprintf \
69 # routines_no_fortify
71 tests = \
72 bug-fopena+ \
73 bug-fseek \
74 bug-ftell \
75 bug-memstream1 \
76 bug-mmap-fflush \
77 bug-rewind \
78 bug-rewind2 \
79 bug-ungetc \
80 bug-ungetc2 \
81 bug-ungetc3 \
82 bug-ungetc4 \
83 bug-ungetwc1 \
84 bug-ungetwc2 \
85 bug-wfflush \
86 bug-wmemstream1 \
87 bug-wsetpos \
88 test-fmemopen \
89 tst-atime \
90 tst-bz22415 \
91 tst-bz24051 \
92 tst-bz24153 \
93 tst-bz28828 \
94 tst-eof \
95 tst-ext \
96 tst-ext2 \
97 tst-fgetc-after-eof \
98 tst-fgetwc \
99 tst-fgetws \
100 tst-fopenloc2 \
101 tst-fputws \
102 tst-freopen \
103 tst-fseek \
104 tst-ftell-active-handler \
105 tst-ftell-append \
106 tst-ftell-partial-wide \
107 tst-fwrite-error \
108 tst-getdelim \
109 tst-memstream1 \
110 tst-memstream2 \
111 tst-memstream3 \
112 tst-memstream4 \
113 tst-mmap-eofsync \
114 tst-mmap-fflushsync \
115 tst-mmap-offend \
116 tst-mmap-setvbuf \
117 tst-mmap2-eofsync \
118 tst-popen1 \
119 tst-setvbuf1 \
120 tst-sprintf-chk-ub \
121 tst-sprintf-ub \
122 tst-sscanf \
123 tst-swscanf \
124 tst-ungetwc1 \
125 tst-ungetwc2 \
126 tst-wfile-sync \
127 tst-widetext \
128 tst-wmemstream1 \
129 tst-wmemstream2 \
130 tst-wmemstream3 \
131 tst-wmemstream4 \
132 tst-wmemstream5 \
133 tst_getwc \
134 tst_putwc \
135 tst_swprintf \
136 tst_swscanf \
137 tst_wprintf \
138 tst_wprintf2 \
139 tst_wscanf \
140 # tests
142 tests-internal = tst-vtables tst-vtables-interposed
144 ifeq (yes,$(build-shared))
145 # Add test-fopenloc only if shared library is enabled since it depends on
146 # shared localedata objects.
147 tests += tst-fopenloc
148 # Add tst-bz24228 only if shared library is enabled since it can never meet its
149 # objective with static linking because the relevant code just is not there.
150 tests += tst-bz24228
151 endif
152 test-srcs = test-freopen
154 ifeq ($(build-shared),yes)
155 routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
156 oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos \
157 oldiofsetpos64
158 endif
160 ifeq (yes,$(libc-reentrant))
161 routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \
162 iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u \
163 iofputs_u
164 endif
166 CPPFLAGS += $(libio-mtsafe)
168 # Support for exception handling.
169 CFLAGS-fileops.c += -fexceptions
170 CFLAGS-fputc.c += -fexceptions
171 CFLAGS-fputwc.c += -fexceptions
172 CFLAGS-freopen64.c += -fexceptions
173 CFLAGS-freopen.c += -fexceptions
174 CFLAGS-fseek.c += -fexceptions
175 CFLAGS-fseeko64.c += -fexceptions
176 CFLAGS-fseeko.c += -fexceptions
177 CFLAGS-ftello64.c += -fexceptions
178 CFLAGS-ftello.c += -fexceptions
179 CFLAGS-fwide.c += -fexceptions
180 CFLAGS-genops.c += -fexceptions
181 CFLAGS-getc.c += -fexceptions
182 CFLAGS-getchar.c += -fexceptions
183 CFLAGS-getwc.c += -fexceptions
184 CFLAGS-getwchar.c += -fexceptions
185 CFLAGS-iofclose.c += -fexceptions
186 CFLAGS-iofflush.c += -fexceptions $(config-cflags-wno-ignored-attributes)
187 CFLAGS-iofgetpos64.c += -fexceptions
188 CFLAGS-iofgetpos.c += -fexceptions
189 CFLAGS-iofgets.c += -fexceptions
190 CFLAGS-iofgetws.c += -fexceptions
191 CFLAGS-iofputs.c += -fexceptions $(config-cflags-wno-ignored-attributes)
192 CFLAGS-iofputws.c += -fexceptions
193 CFLAGS-iofread.c += -fexceptions
194 CFLAGS-iofsetpos64.c += -fexceptions
195 CFLAGS-iofsetpos.c += -fexceptions
196 CFLAGS-ioftell.c += -fexceptions
197 CFLAGS-iofwrite.c += -fexceptions $(config-cflags-wno-ignored-attributes)
198 CFLAGS-iogetdelim.c += -fexceptions
199 CFLAGS-iogetline.c += -fexceptions
200 CFLAGS-iogets.c += -fexceptions
201 CFLAGS-iogetwline.c += -fexceptions
202 CFLAGS-ioputs.c += -fexceptions
203 CFLAGS-ioseekoff.c += -fexceptions
204 CFLAGS-ioseekpos.c += -fexceptions
205 CFLAGS-iosetbuffer.c += -fexceptions
206 CFLAGS-iosetvbuf.c += -fexceptions
207 CFLAGS-ioungetc.c += -fexceptions
208 CFLAGS-ioungetwc.c += -fexceptions
209 CFLAGS-oldfileops.c += -fexceptions
210 CFLAGS-oldiofclose.c += -fexceptions
211 CFLAGS-oldiofgetpos64.c += -fexceptions
212 CFLAGS-oldiofgetpos.c += -fexceptions
213 CFLAGS-oldiofsetpos64.c += -fexceptions
214 CFLAGS-oldiofsetpos.c += -fexceptions
215 CFLAGS-peekc.c += -fexceptions
216 CFLAGS-putc.c += -fexceptions
217 CFLAGS-putchar.c += -fexceptions
218 CFLAGS-putwc.c += -fexceptions
219 CFLAGS-putwchar.c += -fexceptions
220 CFLAGS-rewind.c += -fexceptions
221 CFLAGS-wfileops.c += -fexceptions
222 CFLAGS-wgenops.c += -fexceptions
223 CFLAGS-oldiofopen.c += -fexceptions
224 CFLAGS-iofopen.c += -fexceptions
225 CFLAGS-iofopen64.c += -fexceptions
226 CFLAGS-oldtmpfile.c += -fexceptions
227 CFLAGS-fileno.c += $(config-cflags-wno-ignored-attributes)
228 CFLAGS-feof_u.c += $(config-cflags-wno-ignored-attributes)
229 CFLAGS-ferror_u.c += $(config-cflags-wno-ignored-attributes)
230 CFLAGS-getc_u.c += $(config-cflags-wno-ignored-attributes)
231 CFLAGS-iofflush_u.c += $(config-cflags-wno-ignored-attributes)
232 CFLAGS-putc_u.c += $(config-cflags-wno-ignored-attributes)
233 CFLAGS-iofgets_u.c += $(config-cflags-wno-ignored-attributes)
234 CFLAGS-iofputs_u.c += $(config-cflags-wno-ignored-attributes)
235 # XXX Do we need filedoalloc and wfiledoalloc? Others?
237 # Prevent fortification as these are built with -O0
238 CFLAGS-tst-bz24051.c += $(no-fortify-source)
239 CFLAGS-tst-bz24153.c += $(no-fortify-source)
241 CFLAGS-tst_putwc.c += -DOBJPFX=\"$(objpfx)\"
243 # These test cases intentionally use overlapping arguments
244 CFLAGS-tst-sprintf-ub.c += -Wno-restrict $(no-fortify-source)
245 CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict $(no-fortify-source)
247 LDFLAGS-tst-bz24228 = -Wl,--version-script=tst-bz24228.map
249 tst_wprintf2-ARGS = "Some Text"
251 test-fmemopen-ENV = MALLOC_TRACE=$(objpfx)test-fmemopen.mtrace \
252 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
253 tst-fopenloc-ENV = MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace \
254 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
255 tst-bz22415-ENV = MALLOC_TRACE=$(objpfx)tst-bz22415.mtrace \
256 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
257 tst-bz24228-ENV = MALLOC_TRACE=$(objpfx)tst-bz24228.mtrace \
258 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
260 generated += test-fmemopen.mtrace test-fmemopen.check
261 generated += tst-fopenloc.mtrace tst-fopenloc.check
262 generated += tst-bz22415.mtrace tst-bz22415.check
264 aux := fileops genops stdfiles stdio strops
266 ifeq ($(build-shared),yes)
267 generated += tst-bz24228.mtrace tst-bz24228.check
268 aux += oldfileops oldstdfiles
269 tests += \
270 tst-stderr-compat \
271 # tests
272 tests-2.0 += \
273 tst-stderr-compat \
274 # tests-2.0
275 endif
277 shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \
278 oldstdfiles oldiopopen oldpclose oldtmpfile \
279 oldiofgetpos oldiofgetpos64 oldiofsetpos \
280 oldiofsetpos64
282 ifeq ($(run-built-tests),yes)
283 tests-special += $(objpfx)test-freopen.out $(objpfx)test-fmemopen-mem.out \
284 $(objpfx)tst-bz22415-mem.out
285 ifeq (yes,$(build-shared))
286 # Run tst-fopenloc-cmp.out and tst-openloc-mem.out only if shared
287 # library is enabled since they depend on tst-fopenloc.out.
288 tests-special += $(objpfx)tst-fopenloc-cmp.out $(objpfx)tst-fopenloc-mem.out \
289 $(objpfx)tst-bz24228-mem.out
290 endif
292 tests += \
293 tst-cleanup-default \
294 tst-cleanup-default-static \
295 # tests
296 tests-static += tst-cleanup-default-static
297 tests-special += $(objpfx)tst-cleanup-default-cmp.out $(objpfx)tst-cleanup-default-static-cmp.out
298 LDFLAGS-tst-cleanup-default = -Wl,--gc-sections
299 LDFLAGS-tst-cleanup-default-static = -Wl,--gc-sections
301 ifeq ($(have-gnu-retain)$(have-z-start-stop-gc),yesyes)
302 tests += \
303 tst-cleanup-nostart-stop-gc \
304 tst-cleanup-nostart-stop-gc-static \
305 tst-cleanup-start-stop-gc \
306 tst-cleanup-start-stop-gc-static \
307 # tests
308 tests-static += \
309 tst-cleanup-nostart-stop-gc-static \
310 tst-cleanup-start-stop-gc-static \
311 # tests-static
312 tests-special += $(objpfx)tst-cleanup-start-stop-gc-cmp.out \
313 $(objpfx)tst-cleanup-start-stop-gc-static-cmp.out \
314 $(objpfx)tst-cleanup-nostart-stop-gc-cmp.out \
315 $(objpfx)tst-cleanup-nostart-stop-gc-static-cmp.out
316 LDFLAGS-tst-cleanup-start-stop-gc := -Wl,--gc-sections,-z,start-stop-gc
317 LDFLAGS-tst-cleanup-start-stop-gc-static := -Wl,--gc-sections,-z,start-stop-gc
318 LDFLAGS-tst-cleanup-nostart-stop-gc := -Wl,--gc-sections,-z,nostart-stop-gc
319 LDFLAGS-tst-cleanup-nostart-stop-gc-static := -Wl,--gc-sections,-z,nostart-stop-gc
320 endif
321 endif
323 include ../Rules
325 ifeq ($(run-built-tests),yes)
326 LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
327 ja_JP.EUC-JP ja_JP.UTF-8
328 include ../gen-locales.mk
330 $(objpfx)bug-ftell.out: $(gen-locales)
331 $(objpfx)bug-ungetwc1.out: $(gen-locales)
332 $(objpfx)bug-ungetwc2.out: $(gen-locales)
333 $(objpfx)tst-fgetwc.out: $(gen-locales)
334 $(objpfx)tst-fgetws.out: $(gen-locales)
335 $(objpfx)tst-fopenloc.out: $(gen-locales)
336 $(objpfx)tst-fputws.out: $(gen-locales)
337 $(objpfx)tst-fseek.out: $(gen-locales)
338 $(objpfx)tst-ftell-active-handler.out: $(gen-locales)
339 $(objpfx)tst-ftell-append.out: $(gen-locales)
340 $(objpfx)tst-ftell-partial-wide.out: $(gen-locales)
341 $(objpfx)tst-setvbuf1.out: $(gen-locales)
342 $(objpfx)tst-swscanf.out: $(gen-locales)
343 $(objpfx)tst-ungetwc1.out: $(gen-locales)
344 $(objpfx)tst-ungetwc2.out: $(gen-locales)
345 $(objpfx)tst-widetext.out: $(gen-locales)
346 $(objpfx)tst_wprintf2.out: $(gen-locales)
347 $(objpfx)tst-wfile-sync.out: $(gen-locales)
348 endif
350 define gen-tst-cleanup
351 $(objpfx)tst-cleanup-$1-cmp.out: tst-cleanup.exp $(objpfx)tst-cleanup-$1.out
352 cmp $$^ > $$@; $$(evaluate-test)
353 endef
355 $(foreach t,default default-static start-stop-gc start-stop-gc-static nostart-stop-gc nostart-stop-gc-static, \
356 $(eval $(call gen-tst-cleanup,$(t))))
358 $(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen
359 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' \
360 $(common-objpfx)libio/; \
361 $(evaluate-test)
363 $(objpfx)tst-fopenloc-cmp.out: ../iconvdata/testdata/ISO-8859-1..UTF8 \
364 $(objpfx)tst-fopenloc.out
365 cmp $^ > $@; \
366 $(evaluate-test)
368 $(objpfx)test-fmemopen-mem.out: $(objpfx)test-fmemopen.out
369 $(common-objpfx)malloc/mtrace $(objpfx)test-fmemopen.mtrace > $@; \
370 $(evaluate-test)
372 $(objpfx)tst-fopenloc-mem.out: $(objpfx)tst-fopenloc.out
373 $(common-objpfx)malloc/mtrace $(objpfx)tst-fopenloc.mtrace > $@; \
374 $(evaluate-test)
376 $(objpfx)tst-bz22415-mem.out: $(objpfx)tst-bz22415.out
377 $(common-objpfx)malloc/mtrace $(objpfx)tst-bz22415.mtrace > $@; \
378 $(evaluate-test)
380 $(objpfx)tst-bz24228-mem.out: $(objpfx)tst-bz24228.out
381 $(common-objpfx)malloc/mtrace $(objpfx)tst-bz24228.mtrace > $@; \
382 $(evaluate-test)