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