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