1 # GLIB - Library of useful C routines
3 #GTESTER = gtester # for non-GLIB packages
4 GTESTER = $(top_builddir)/glib/gtester # for the GLIB package
5 GTESTER_REPORT = $(top_builddir)/glib/gtester-report # for the GLIB package
8 # initialize variables for unconditional += appending
13 MAINTAINERCLEANFILES =
17 installed_test_LTLIBRARIES =
18 installed_test_PROGRAMS =
19 installed_test_SCRIPTS =
20 nobase_installed_test_DATA =
36 # test: run all tests in cwd and subdirs
37 test: test-nonrecursive
39 @ for subdir in $(SUBDIRS) . ; do \
40 test "$$subdir" = "." -o "$$subdir" = "po" || \
41 ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
44 # test-nonrecursive: run tests only in cwd
45 test-nonrecursive: ${TEST_PROGS}
46 @test -z "${TEST_PROGS}" || G_TEST_SRCDIR="$(abs_srcdir)" G_TEST_BUILDDIR="$(abs_builddir)" G_DEBUG=gc-friendly MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) ${GTESTER} --verbose ${TEST_PROGS}
51 # test-report: run tests in subdirs and generate report
52 # perf-report: run tests in subdirs with -m perf and generate report
53 # full-report: like test-report: with -m perf and -m slow
54 test-report perf-report full-report: ${TEST_PROGS}
55 @test -z "${TEST_PROGS}" || { \
57 test-report) test_options="-k";; \
58 perf-report) test_options="-k -m=perf";; \
59 full-report) test_options="-k -m=perf -m=slow";; \
61 if test -z "$$GTESTER_LOGDIR" ; then \
62 G_TEST_SRCDIR="$(abs_srcdir)" G_TEST_BUILDDIR="$(abs_builddir)" ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
63 elif test -n "${TEST_PROGS}" ; then \
64 G_TEST_SRCDIR="$(abs_srcdir)" G_TEST_BUILDDIR="$(abs_builddir)" ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
67 @ ignore_logdir=true ; \
68 if test -z "$$GTESTER_LOGDIR" ; then \
69 GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
70 ignore_logdir=false ; \
72 if test -d "$(top_srcdir)/.git" ; then \
73 REVISION=`git describe` ; \
75 REVISION=$(VERSION) ; \
77 for subdir in $(SUBDIRS) . ; do \
78 test "$$subdir" = "." -o "$$subdir" = "po" || \
79 ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
81 $$ignore_logdir || { \
82 echo '<?xml version="1.0"?>' > $@.xml ; \
83 echo '<report-collection>' >> $@.xml ; \
84 echo '<info>' >> $@.xml ; \
85 echo ' <package>$(PACKAGE)</package>' >> $@.xml ; \
86 echo ' <version>$(VERSION)</version>' >> $@.xml ; \
87 echo " <revision>$$REVISION</revision>" >> $@.xml ; \
88 echo '</info>' >> $@.xml ; \
89 for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
90 sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \
93 echo '</report-collection>' >> $@.xml ; \
94 rm -rf "$$GTESTER_LOGDIR"/ ; \
95 ${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
97 .PHONY: test test-report perf-report full-report test-nonrecursive
99 .PHONY: lcov genlcov lcov-clean
100 # use recursive makes in order to ignore errors during check
102 -$(MAKE) $(AM_MAKEFLAGS) -k check
103 $(MAKE) $(AM_MAKEFLAGS) genlcov
105 # we have to massage the lcov.info file slightly to hide the effect of libtool
106 # placing the objects files in the .libs/ directory separate from the *.c
107 # we also have to delete tests/.libs/libmoduletestplugin_*.gcda
109 rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda
110 $(LTP) --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum --compat-libtool
111 LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --show-details glib-lcov.info
112 @echo "file://$(abs_top_builddir)/glib-lcov/index.html"
115 -$(LTP) --directory $(top_builddir) -z
116 -rm -rf glib-lcov.info glib-lcov
117 -find -name '*.gcda' -print | xargs rm
119 # run tests in cwd as part of make check
120 check-local: test-nonrecursive
122 # We support a fairly large range of possible variables. It is expected that all types of files in a test suite
123 # will belong in exactly one of the following variables.
125 # First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
127 # test_programs, test_scripts, test_data, test_ltlibraries
129 # The above are used to list files that are involved in both uninstalled and installed testing. The
130 # test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
131 # Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
132 # installed in the same way as it appears in the package layout.
134 # In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
137 # installed_test_programs, uninstalled_test_programs
138 # installed_test_scripts, uninstalled_test_scripts
139 # installed_test_data, uninstalled_test_data
140 # installed_test_ltlibraries, uninstalled_test_ltlibraries
142 # Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts
143 # that should not themselves be run as testcases (but exist to be used from other testcases):
145 # test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
146 # test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
148 # Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
149 # file automatically end up in the tarball.
151 # dist_test_scripts, dist_test_data, dist_test_extra_scripts
152 # dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
153 # dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
155 # Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the
156 # standard automake convention of not disting programs scripts or data by default.
158 # test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
159 # variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
160 # gtester. That's a bit strange for scripts, but it's possible.
162 # we use test -z "$(TEST_PROGS)" above, so make sure we have no extra whitespace...
163 TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
164 $(dist_test_scripts) $(dist_uninstalled_test_scripts))
167 TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
168 $(dist_test_scripts) $(dist_uninstalled_test_scripts)
171 # Note: build even the installed-only targets during 'make check' to ensure that they still work.
172 # We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
173 # prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
174 # filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
175 all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
176 $(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs)
177 all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
178 $(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts)
179 all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \
180 $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts)
181 all_test_scripts += $(all_dist_test_scripts)
182 EXTRA_DIST += $(all_dist_test_scripts)
183 all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data)
184 all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
185 all_test_data += $(all_dist_test_data)
186 EXTRA_DIST += $(all_dist_test_data)
187 all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
189 if ENABLE_ALWAYS_BUILD_TESTS
190 noinst_LTLIBRARIES += $(all_test_ltlibs)
191 noinst_PROGRAMS += $(all_test_programs)
192 noinst_SCRIPTS += $(all_test_scripts)
193 noinst_DATA += $(all_test_data)
195 check_LTLIBRARIES += $(all_test_ltlibs)
196 check_PROGRAMS += $(all_test_programs)
197 check_SCRIPTS += $(all_test_scripts)
198 check_DATA += $(all_test_data)
201 if ENABLE_INSTALLED_TESTS
202 installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \
203 $(test_extra_programs) $(installed_test_extra_programs)
204 installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
205 $(test_extra_scripts) $(test_installed_extra_scripts)
206 installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
207 $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
208 nobase_installed_test_DATA += $(test_data) $(installed_test_data)
209 nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
210 installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
211 installed_testcases = $(test_programs) $(installed_test_programs) \
212 $(test_scripts) $(installed_test_scripts) \
213 $(dist_test_scripts) $(dist_installed_test_scripts)
215 installed_test_meta_DATA = $(installed_testcases:=.test)
217 %.test: %$(EXEEXT) Makefile
218 $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
219 echo 'Type=session' >> $@.tmp; \
220 echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \
223 CLEANFILES += $(installed_test_meta_DATA)