1SUBDIRS = .
2
3# Add to the tarball:
4EXTRA_DIST = get_config_unittest.cc.skel
5
6TESTS_ENVIRONMENT = \
7        $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
8
9# Shell tests
10SHTESTS = dhcp4_process_tests.sh
11
12# Run shell tests on "make check".
13check_SCRIPTS = $(SHTESTS)
14TESTS = $(SHTESTS)
15
16# As with every file generated by ./configure, clean them up when running
17# "make distclean", but not on "make clean".
18DISTCLEANFILES = $(SHTESTS)
19
20# Don't install tests.
21noinst_SCRIPTS = $(SHTESTS)
22
23if HAVE_GTEST
24
25# C++ tests
26PROGRAM_TESTS = dhcp4_unittests
27
28AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
29AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_builddir)/src
30AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
31AM_CPPFLAGS += $(BOOST_INCLUDES)
32AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/bin/dhcp4/tests\"
33AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
34AM_CPPFLAGS += -DCFG_EXAMPLES=\"$(abs_top_srcdir)/doc/examples/kea4\"
35AM_CPPFLAGS += -DSYNTAX_FILE=\"$(abs_srcdir)/../dhcp4_parser.yy\"
36AM_CPPFLAGS += -DKEA_LFC_EXECUTABLE=\"$(abs_top_builddir)/src/bin/lfc/kea-lfc\"
37
38AM_CXXFLAGS = $(KEA_CXXFLAGS)
39
40if USE_STATIC_LINK
41AM_LDFLAGS = -static
42endif
43
44# Build shared libraries for testing. The libtool way to create a shared library
45# is to specify "-avoid-version -export-dynamic -module" in the library LDFLAGS
46# (see http://www.gnu.org/software/libtool/manual/html_node/Link-mode.html).
47# Use of these switches will guarantee that the .so files are created in the
48# .libs folder and they can be dlopened.
49# Note that the shared libraries with callouts should not be used together with
50# the --enable-static-link option. With this option, the bind10 libraries are
51# statically linked with the program and if the callout invokes the methods
52# which belong to these libraries, the library with the callout will get its
53# own copy of the static objects (e.g. logger, ServerHooks) and that will lead
54# to unexpected errors. For this reason, the --enable-static-link option is
55# ignored for unit tests built here.
56
57# -rpath /nowhere is a hack to trigger libtool to not create a
58# convenience archive, resulting in shared modules
59
60libco1_la_SOURCES  = callout_library_1.cc callout_library_common.h
61libco1_la_CXXFLAGS = $(AM_CXXFLAGS)
62libco1_la_CPPFLAGS = $(AM_CPPFLAGS)
63libco1_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
64
65libco2_la_SOURCES  = callout_library_2.cc callout_library_common.h
66libco2_la_CXXFLAGS = $(AM_CXXFLAGS)
67libco2_la_CPPFLAGS = $(AM_CPPFLAGS)
68libco2_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
69
70libco3_la_SOURCES  = callout_library_3.cc callout_library_common.h
71libco3_la_CXXFLAGS = $(AM_CXXFLAGS)
72libco3_la_CPPFLAGS = $(AM_CPPFLAGS)
73libco3_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
74
75dhcp4_unittests_SOURCES  = d2_unittest.h d2_unittest.cc
76dhcp4_unittests_SOURCES += dhcp4_unittests.cc
77dhcp4_unittests_SOURCES += dhcp4_srv_unittest.cc
78dhcp4_unittests_SOURCES += dhcp4_test_utils.cc dhcp4_test_utils.h
79dhcp4_unittests_SOURCES += direct_client_unittest.cc
80dhcp4_unittests_SOURCES += ctrl_dhcp4_srv_unittest.cc
81dhcp4_unittests_SOURCES += classify_unittest.cc
82dhcp4_unittests_SOURCES += config_backend_unittest.cc
83dhcp4_unittests_SOURCES += config_parser_unittest.cc
84dhcp4_unittests_SOURCES += fqdn_unittest.cc
85dhcp4_unittests_SOURCES += marker_file.cc
86dhcp4_unittests_SOURCES += dhcp4_client.cc dhcp4_client.h
87dhcp4_unittests_SOURCES += hooks_unittest.cc
88dhcp4_unittests_SOURCES += inform_unittest.cc
89dhcp4_unittests_SOURCES += dora_unittest.cc
90dhcp4_unittests_SOURCES += host_options_unittest.cc
91dhcp4_unittests_SOURCES += release_unittest.cc
92dhcp4_unittests_SOURCES += parser_unittest.cc
93dhcp4_unittests_SOURCES += out_of_range_unittest.cc
94dhcp4_unittests_SOURCES += decline_unittest.cc
95dhcp4_unittests_SOURCES += kea_controller_unittest.cc
96dhcp4_unittests_SOURCES += dhcp4to6_ipc_unittest.cc
97dhcp4_unittests_SOURCES += simple_parser4_unittest.cc
98dhcp4_unittests_SOURCES += get_config_unittest.cc get_config_unittest.h
99dhcp4_unittests_SOURCES += shared_network_unittest.cc
100dhcp4_unittests_SOURCES += host_unittest.cc
101dhcp4_unittests_SOURCES += vendor_opts_unittest.cc
102dhcp4_unittests_SOURCES += client_handler_unittest.cc
103
104nodist_dhcp4_unittests_SOURCES = marker_file.h test_libraries.h
105
106dhcp4_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
107dhcp4_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS)
108if HAVE_MYSQL
109dhcp4_unittests_LDFLAGS += $(MYSQL_LIBS)
110endif
111if HAVE_PGSQL
112dhcp4_unittests_LDFLAGS += $(PGSQL_LIBS)
113endif
114if HAVE_CQL
115dhcp4_unittests_LDFLAGS += $(CQL_LIBS)
116endif
117dhcp4_unittests_LDFLAGS += $(GTEST_LDFLAGS)
118
119dhcp4_unittests_LDADD = $(top_builddir)/src/bin/dhcp4/libdhcp4.la
120dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
121dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
122dhcp4_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
123dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
124dhcp4_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
125dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
126dhcp4_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
127dhcp4_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
128dhcp4_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
129dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
130dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
131dhcp4_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
132
133if HAVE_MYSQL
134dhcp4_unittests_LDADD += $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la
135dhcp4_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
136endif
137if HAVE_PGSQL
138dhcp4_unittests_LDADD += $(top_builddir)/src/lib/pgsql/testutils/libpgsqltest.la
139dhcp4_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
140endif
141if HAVE_CQL
142dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cql/testutils/libcqltest.la
143dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cql/libkea-cql.la
144endif
145
146dhcp4_unittests_LDADD += $(top_builddir)/src/lib/database/testutils/libdatabasetest.la
147dhcp4_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
148dhcp4_unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
149
150dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
151
152dhcp4_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
153
154dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
155dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
156
157dhcp4_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
158dhcp4_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
159dhcp4_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
160dhcp4_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
161dhcp4_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)
162
163# Run C++ tests on "make check".
164TESTS += $(PROGRAM_TESTS)
165
166# As with every file generated by ./configure, clean them up when running
167# "make distclean", but not on "make clean".
168DISTCLEANFILES += marker_file.h
169DISTCLEANFILES += test_data_files_config.h
170DISTCLEANFILES += test_libraries.h
171
172# Don't install test libraries.
173noinst_LTLIBRARIES = libco1.la libco2.la libco3.la
174
175# Don't install C++ tests.
176noinst_PROGRAMS = $(PROGRAM_TESTS)
177
178# Use this target if you want to rebuild the get-config unit-tests.
179#
180# TODO: We could also automate the replacement step with some variation
181# of this: https://stackoverflow.com/questions/6790631
182rebuild-tests:
183	rm -f x u get_config_unittest.cc
184	cp -f get_config_unittest.cc.skel get_config_unittest.cc
185	$(MAKE) CXXFLAGS=-DEXTRACT_CONFIG V=1
186	./dhcp4_unittests --gtest_filter="Dhcp4Parser*" > /dev/null 2> x
187	echo "Please copy content of x file into EXTRACTED_CONFIGS in get_config_unittest.cc"
188	read -p "Press ENTER when ready"
189	$(MAKE) CXXFLAGS=-DGENERATE_ACTION V=1
190	./dhcp4_unittests --gtest_filter="Dhcp4GetConfig*" > /dev/null 2> u
191	echo "Please copy content of u file into UNPARSED_CONFIGS in get_config_unittest.cc"
192	read -p "Press ENTER when ready"
193	touch get_config_unittest.cc
194	$(MAKE)
195
196endif
197