1# GLIB - Library of useful C routines
2
3TESTS_ENVIRONMENT= \
4	G_TEST_SRCDIR="$(abs_srcdir)" 		\
5	G_TEST_BUILDDIR="$(abs_builddir)" 	\
6	G_DEBUG=gc-friendly 			\
7	MALLOC_CHECK_=2 			\
8	MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
9TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
10LOG_COMPILER = $(top_srcdir)/build/tap-test
11
12NULL =
13
14# initialize variables for unconditional += appending
15BUILT_SOURCES =
16BUILT_EXTRA_DIST =
17CLEANFILES = *.log *.trs
18DISTCLEANFILES =
19MAINTAINERCLEANFILES =
20EXTRA_DIST =
21TESTS =
22
23installed_test_LTLIBRARIES =
24installed_test_PROGRAMS =
25installed_test_SCRIPTS =
26installed_testdir =
27nobase_installed_test_DATA =
28installed_test_metadir =
29
30noinst_LTLIBRARIES =
31noinst_PROGRAMS =
32noinst_SCRIPTS =
33noinst_DATA =
34
35check_LTLIBRARIES =
36check_PROGRAMS =
37check_SCRIPTS =
38check_DATA =
39
40# We support a fairly large range of possible variables.  It is expected that all types of files in a test suite
41# will belong in exactly one of the following variables.
42#
43# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
44#
45#   test_programs, test_scripts, test_data, test_ltlibraries
46#
47# The above are used to list files that are involved in both uninstalled and installed testing.  The
48# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
49# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
50# installed in the same way as it appears in the package layout.
51#
52# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
53# like so:
54#
55#   installed_test_programs, uninstalled_test_programs
56#   installed_test_scripts, uninstalled_test_scripts
57#   installed_test_data, uninstalled_test_data
58#   installed_test_ltlibraries, uninstalled_test_ltlibraries
59#
60# Additionally, we support 'extra' infixes for programs and scripts.  This is used for support programs/scripts
61# that should not themselves be run as testcases (but exist to be used from other testcases):
62#
63#   test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
64#   test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
65#
66# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
67# file automatically end up in the tarball.
68#
69#   dist_test_scripts, dist_test_data, dist_test_extra_scripts
70#   dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
71#   dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
72#
73# Note that no file is automatically disted unless it appears in one of the dist_ variables.  This follows the
74# standard automake convention of not disting programs scripts or data by default.
75#
76# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
77# variants) will be run as part of the in-tree 'make check'.  These are all assumed to be runnable under
78# gtester.  That's a bit strange for scripts, but it's possible.
79
80TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
81         $(dist_test_scripts) $(dist_uninstalled_test_scripts)
82
83# Note: build even the installed-only targets during 'make check' to ensure that they still work.
84# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
85# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
86# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
87all_test_programs     = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
88                        $(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs)
89all_test_scripts      = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
90                        $(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts)
91all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \
92                        $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts)
93all_test_scripts     += $(all_dist_test_scripts)
94EXTRA_DIST           += $(all_dist_test_scripts)
95all_test_data         = $(test_data) $(uninstalled_test_data) $(installed_test_data)
96all_dist_test_data    = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
97all_test_data        += $(all_dist_test_data)
98EXTRA_DIST           += $(all_dist_test_data)
99all_test_ltlibs       = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
100
101if ENABLE_ALWAYS_BUILD_TESTS
102noinst_LTLIBRARIES += $(all_test_ltlibs)
103noinst_PROGRAMS += $(all_test_programs)
104noinst_SCRIPTS += $(all_test_scripts)
105noinst_DATA += $(all_test_data)
106else
107check_LTLIBRARIES += $(all_test_ltlibs)
108check_PROGRAMS += $(all_test_programs)
109check_SCRIPTS += $(all_test_scripts)
110check_DATA += $(all_test_data)
111endif
112
113if ENABLE_INSTALLED_TESTS
114installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \
115                          $(test_extra_programs) $(installed_test_extra_programs)
116installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
117                          $(test_extra_scripts) $(test_installed_extra_scripts)
118installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
119                          $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
120nobase_installed_test_DATA += $(test_data) $(installed_test_data)
121nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
122installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
123installed_testcases = $(test_programs) $(installed_test_programs) \
124                      $(test_scripts) $(installed_test_scripts) \
125                      $(dist_test_scripts) $(dist_installed_test_scripts)
126
127installed_test_meta_DATA = $(installed_testcases:=.test)
128
129%.test: %$(EXEEXT) Makefile
130	$(AM_V_GEN) (echo '[Test]' > $@.tmp; \
131	echo 'Type=session' >> $@.tmp; \
132	echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \
133	mv $@.tmp $@)
134
135CLEANFILES += $(installed_test_meta_DATA)
136endif
137