1 ## Makefile for the testsuite subdirectory of the GNU C++ Standard library.
3 ## Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 ## This file is part of the libstdc++ version 3 distribution.
6 ## Process this file with automake to produce Makefile.in.
8 ## This file is part of the GNU ISO C++ Library. This library is free
9 ## software; you can redistribute it and/or modify it under the
10 ## terms of the GNU General Public License as published by the
11 ## Free Software Foundation; either version 3, or (at your option)
14 ## This library is distributed in the hope that it will be useful,
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ## GNU General Public License for more details.
19 ## You should have received a copy of the GNU General Public License along
20 ## with this library; see the file COPYING3. If not see
21 ## <http://www.gnu.org/licenses/>.
23 AUTOMAKE_OPTIONS = nostdinc
24 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
27 include $(top_srcdir)/fragment.am
29 # Generated lists of files to run. All of these names are valid make
30 # targets, if you wish to generate a list manually.
33 testsuite_files_interactive \
34 testsuite_files_performance \
37 # This rule generates all of the testsuite_files* lists at once.
39 ${glibcxx_srcdir}/scripts/create_testsuite_files \
40 ${glibcxx_srcdir}/testsuite `${PWD_COMMAND}`
42 # We need more things in site.exp, but automake completely controls the
43 # creation of that file; there's no way to append to it without messing up
44 # the dependancy chains. So we overrule automake. This rule is exactly
45 # what it would have generated, plus our own additions.
47 @echo 'Making a new site.exp file...'
48 @echo '## these variables are automatically generated by make ##' >site.tmp
49 @echo '# Do not edit here. If you wish to override these values' >>site.tmp
50 @echo '# edit the last section' >>site.tmp
51 @echo 'set tool libstdc++' >>site.tmp
52 @echo 'set srcdir $(srcdir)' >>site.tmp
53 @echo "set objdir `pwd`" >>site.tmp
54 @echo 'set build_alias "$(build_alias)"' >>site.tmp
55 @echo 'set build_triplet $(build_triplet)' >>site.tmp
56 @echo 'set host_alias "$(host_alias)"' >>site.tmp
57 @echo 'set host_triplet $(host_triplet)' >>site.tmp
58 @echo 'set target_alias "$(target_alias)"' >>site.tmp
59 @echo 'set target_triplet $(target_triplet)' >>site.tmp
60 @echo 'set libiconv "$(LIBICONV)"' >>site.tmp
61 @echo 'set baseline_dir "$(baseline_dir)"' >> site.tmp
62 @echo 'set baseline_subdir_switch "$(baseline_subdir_switch)"' >> site.tmp
63 @echo 'set TEST_GCC_EXEC_PREFIX "$(libdir)/gcc/"' >> site.tmp
64 @echo 'set v3-use-std-list 1' >> site.tmp
65 @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
66 @test ! -f site.exp || \
67 sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
69 @test ! -f site.exp || mv site.exp site.bak
73 extract_symvers = $(glibcxx_builddir)/scripts/extract_symvers
75 baseline_subdir := $(shell $(CXX) $(baseline_subdir_switch))
78 -@(output=${baseline_dir}/${baseline_subdir}/baseline_symbols.txt; \
79 if test ! -f $${output}; then \
80 echo "Baseline file doesn't exist."; \
81 echo "Try 'make new-abi-baseline' to create it."; \
86 -@$(mkinstalldirs) ${baseline_dir}/${baseline_subdir}
87 -@(output=${baseline_dir}/${baseline_subdir}/baseline_symbols.txt; \
88 if test -f $${output}; then \
89 output=$${output}.new; \
90 t=`echo $${output} | sed 's=.*config/abi/=='`; \
91 echo "Baseline file already exists, writing to $${t} instead."; \
93 ${extract_symvers} ../src/.libs/libstdc++.so $${output})
96 -@test -d $* || mkdir $*
97 @srcdir=`cd $(srcdir); ${PWD_COMMAND}`;
98 @objdir=`${PWD_COMMAND}`/$*; \
99 sed -e "s|^set srcdir .*$$|set srcdir $$srcdir|" \
100 -e "s|^set objdir .*$$|set objdir $$objdir|" \
101 site.exp > $*/site.exp.tmp
103 @test ! -f $*/site.exp || mv $*/site.exp $*/site.bak
104 @mv $*/site.exp.tmp $*/site.exp
106 check_p_numbers0:=1 2 3 4 5 6 7 8 9
107 check_p_numbers1:=0 $(check_p_numbers0)
108 check_p_numbers2:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers1)))
109 check_p_numbers3:=$(addprefix 0,$(check_p_numbers1)) $(check_p_numbers2)
110 check_p_numbers4:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers3)))
111 check_p_numbers5:=$(addprefix 0,$(check_p_numbers3)) $(check_p_numbers4)
112 check_p_numbers6:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers5)))
113 check_p_numbers:=$(check_p_numbers0) $(check_p_numbers2) $(check_p_numbers4) $(check_p_numbers6)
114 check_p_subdirs=$(wordlist 1,$(if $(GCC_TEST_PARALLEL_SLOTS),$(GCC_TEST_PARALLEL_SLOTS),128),$(check_p_numbers))
115 check_DEJAGNU_normal_targets = $(addprefix check-DEJAGNUnormal,$(check_p_subdirs))
116 $(check_DEJAGNU_normal_targets): check-DEJAGNUnormal%: normal%/site.exp
118 # Run the testsuite in normal mode.
119 check-DEJAGNU $(check_DEJAGNU_normal_targets): check-DEJAGNU%: site.exp
120 @$(if $*,@)AR="$(AR)"; export AR; \
121 RANLIB="$(RANLIB)"; export RANLIB; \
122 if [ -z "$*" ] && [ -n "$(filter -j%, $(MFLAGS))" ]; then \
123 rm -rf normal-parallel || true; \
124 mkdir normal-parallel; \
125 $(MAKE) $(AM_MAKEFLAGS) $(check_DEJAGNU_normal_targets); \
126 rm -rf normal-parallel || true; \
127 for idx in $(check_p_subdirs); do \
128 if [ -d normal$$idx ]; then \
129 mv -f normal$$idx/libstdc++.sum normal$$idx/libstdc++.sum.sep; \
130 mv -f normal$$idx/libstdc++.log normal$$idx/libstdc++.log.sep; \
133 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
134 normal[0-9]*/libstdc++.sum.sep > libstdc++.sum; \
135 $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
136 normal[0-9]*/libstdc++.log.sep > libstdc++.log; \
139 srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
140 EXPECT=$(EXPECT); export EXPECT; \
141 runtest=$(RUNTEST); \
142 if [ -z "$$runtest" ]; then runtest=runtest; fi; \
144 if [ -n "$*" ]; then \
145 if [ -f normal-parallel/finished ]; then rm -rf "$*"; exit 0; fi; \
146 GCC_RUNTEST_PARALLELIZE_DIR=`${PWD_COMMAND}`/normal-parallel; \
147 export GCC_RUNTEST_PARALLELIZE_DIR; \
150 if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
151 $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \
153 if [ -n "$*" ]; then \
154 touch $$GCC_RUNTEST_PARALLELIZE_DIR/finished; \
157 echo "WARNING: could not find \`runtest'" 1>&2; :;\
161 $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
162 .PHONY: check-DEJAGNU
164 # Use 'new-abi-baseline' to create an initial symbol file. Then run
165 # 'check-abi' to test for changes against that file.
166 check-abi: site.exp baseline_symbols
167 -@runtest $(AM_RUNTESTFLAGS) --tool libstdc++ $(RUNTESTFLAGS) abi.exp
169 # Runs the testsuite, but in compile only mode.
170 # Can be used to test sources with non-GNU FE's at various warning
171 # levels and for checking compile time across releases.
173 compile_script=${glibcxx_srcdir}/scripts/check_compile
174 check-compile: testsuite_files ${compile_script}
175 -@(chmod + ${compile_script}; \
176 ${compile_script} ${glibcxx_srcdir} ${glibcxx_builddir})
179 # Runs the testsuite/performance tests.
180 # Some of these tests create large (~75MB) files, allocate huge
181 # ammounts of memory, or otherwise tie up machine resources. Thus,
182 # running this is off by default.
183 # XXX Need to add dependency on libtestc++.a
184 check_performance_script=${glibcxx_srcdir}/scripts/check_performance
185 check-performance: testsuite_files_performance ${performance_script}
186 -@(chmod + ${check_performance_script}; \
187 CXXFLAGS='$(CXXFLAGS)'; export CXXFLAGS; \
188 ${check_performance_script} ${glibcxx_srcdir} ${glibcxx_builddir})
190 # Runs the simd tests.
191 check-simd: $(srcdir)/experimental/simd/generate_makefile.sh \
192 ${glibcxx_srcdir}/scripts/check_simd \
193 testsuite_files_simd \
194 ${glibcxx_builddir}/scripts/testsuite_flags
196 @echo "Generating simd testsuite subdirs and Makefiles ..."
197 @${glibcxx_srcdir}/scripts/check_simd "${glibcxx_srcdir}" "${glibcxx_builddir}" "$(CXXFLAGS)" | \
198 while read subdir; do \
199 $(MAKE) -C "$${subdir}"; \
200 tail -n20 $${subdir}/simd_testsuite.sum | \
201 grep -A20 -B1 'Summary ===' >> .simd.summary; \
203 cat .simd.summary && rm .simd.summary
205 # Runs the testsuite in debug mode.
206 debug_flags = "unix/-D_GLIBCXX_DEBUG"
208 # Runs the testsuite in parallel mode.
209 libgomp_dir=${glibcxx_builddir}/../libgomp
210 libgomp_flags=-B${glibcxx_builddir}/../libgomp \
211 -I${glibcxx_builddir}/../libgomp \
212 -L${glibcxx_builddir}/../libgomp/.libs -lgomp
214 atomic_flags=$(ATOMIC_FLAGS)
215 parallel_flags="unix/-D_GLIBCXX_PARALLEL/-fopenmp"
217 check-debug: site.exp
218 outputdir=debug; export outputdir; \
219 if test ! -d $${outputdir}; then \
220 mkdir $${outputdir}; \
222 srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
223 EXPECT=$(EXPECT); export EXPECT; \
224 $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(debug_flags)" check-DEJAGNU;
226 check-parallel: site.exp
227 -@(if test ! -d $${libgomp_dir}; then \
228 echo "Testing parallel mode failed as libgomp not present."; \
231 outputdir=parallel; export outputdir; \
232 if test ! -d $${outputdir}; then \
233 mkdir $${outputdir}; \
235 srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
236 EXPECT=$(EXPECT); export EXPECT; \
237 $(MAKE) CXXFLAGS="$(atomic_flags) $(libgomp_flags)" RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(parallel_flags)" check-DEJAGNU; )
239 check-performance-parallel: testsuite_files_performance ${performance_script}
240 -@(chmod + ${check_performance_script}; \
241 CXXFLAGS="-D_GLIBCXX_PARALLEL -fopenmp $(atomic_flags) $(libgomp_flags)"; export CXXFLAGS; \
242 ${check_performance_script} ${glibcxx_srcdir} ${glibcxx_builddir})
244 .PHONY: baseline_symbols new-abi-baseline \
245 check-abi check-compile check-performance check-parallel
247 # By adding these files here, automake will remove them for 'make clean'
248 CLEANFILES = *.txt *.tst *.exe core* filebuf_* tmp* ostream_* *.log *.sum \
249 testsuite_* site.exp abi_check baseline_symbols *TEST* *.dat \
250 *.ii *.s *.o *.cc *.x *.a *.so *.xml *.raw *.out *.gdb
252 # To remove directories.
254 rm -rf de fr debug parallel binaries normal* simd