summaryrefslogtreecommitdiffstats
path: root/src/bin/dhcp6/tests/Makefile.am
blob: e3518f1ad42999965370fc54b34355969d8d6567 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
SUBDIRS = .

# Add to the tarball:
EXTRA_DIST = get_config_unittest.cc.skel

TESTS_ENVIRONMENT = \
        $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)

# Shell tests
SHTESTS = dhcp6_process_tests.sh

# Run shell tests on "make check".
check_SCRIPTS = $(SHTESTS)
TESTS = $(SHTESTS)

# As with every file generated by ./configure, clean them up when running
# "make distclean", but not on "make clean".
DISTCLEANFILES  = $(SHTESTS)
DISTCLEANFILES += marker_file.h
DISTCLEANFILES += test_data_files_config.h
DISTCLEANFILES += test_libraries.h

# Don't install shell tests.
noinst_SCRIPTS = $(SHTESTS)

AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_builddir)/src
AM_CPPFLAGS += -DTOP_BUILDDIR="\"$(top_builddir)\""
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/bin/dhcp6/tests\"
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
AM_CPPFLAGS += -DCFG_EXAMPLES=\"$(abs_top_srcdir)/doc/examples/kea6\"
AM_CPPFLAGS += -DSYNTAX_FILE=\"$(abs_srcdir)/../dhcp6_parser.yy\"
AM_CPPFLAGS += -DKEA_LFC_EXECUTABLE=\"$(abs_top_builddir)/src/bin/lfc/kea-lfc\"

AM_CXXFLAGS = $(KEA_CXXFLAGS)

if USE_STATIC_LINK
AM_LDFLAGS = -static
endif

# Build shared libraries for testing. The libtool way to create a shared library
# is to specify "-avoid-version -export-dynamic -module" in the library LDFLAGS
# (see http://www.gnu.org/software/libtool/manual/html_node/Link-mode.html).
# Use of these switches will guarantee that the .so files are created in the
# .libs folder and they can be dlopened.
# Note that the shared libraries with callouts should not be used together with
# the --enable-static-link option. With this option, the bind10 libraries are
# statically linked with the program and if the callout invokes the methods
# which belong to these libraries, the library with the callout will get its
# own copy of the static objects (e.g. logger, ServerHooks) and that will lead
# to unexpected errors. For this reason, the --enable-static-link option is
# ignored for unit tests built here.

# -rpath /nowhere is a hack to trigger libtool to not create a
# convenience archive, resulting in shared modules

libco1_la_SOURCES  = callout_library_1.cc callout_library_common.h
libco1_la_CXXFLAGS = $(AM_CXXFLAGS)
libco1_la_CPPFLAGS = $(AM_CPPFLAGS)
libco1_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere

libco2_la_SOURCES  = callout_library_2.cc callout_library_common.h
libco2_la_CXXFLAGS = $(AM_CXXFLAGS)
libco2_la_CPPFLAGS = $(AM_CPPFLAGS)
libco2_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere

libco3_la_SOURCES  = callout_library_3.cc callout_library_common.h
libco3_la_CXXFLAGS = $(AM_CXXFLAGS)
libco3_la_CPPFLAGS = $(AM_CPPFLAGS)
libco3_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere

# Don't install test libraries.
noinst_LTLIBRARIES = libco1.la libco2.la libco3.la

if HAVE_GTEST

# C++ tests
PROGRAM_TESTS = dhcp6_unittests

# This list is ordered alphabetically. When adding new files, please maintain
# this order.
dhcp6_unittests_SOURCES  = classify_unittests.cc
dhcp6_unittests_SOURCES += client_handler_unittest.cc
dhcp6_unittests_SOURCES += config_parser_unittest.cc
dhcp6_unittests_SOURCES += config_backend_unittest.cc
dhcp6_unittests_SOURCES += confirm_unittest.cc
dhcp6_unittests_SOURCES += ctrl_dhcp6_srv_unittest.cc
dhcp6_unittests_SOURCES += d2_unittest.cc d2_unittest.h
dhcp6_unittests_SOURCES += decline_unittest.cc
dhcp6_unittests_SOURCES += dhcp6_client.cc dhcp6_client.h
dhcp6_unittests_SOURCES += dhcp6_message_test.cc dhcp6_message_test.h
dhcp6_unittests_SOURCES += dhcp6_srv_unittest.cc
dhcp6_unittests_SOURCES += dhcp6_test_utils.cc dhcp6_test_utils.h
dhcp6_unittests_SOURCES += dhcp6_unittests.cc
dhcp6_unittests_SOURCES += dhcp6to4_ipc_unittest.cc
dhcp6_unittests_SOURCES += fqdn_unittest.cc
dhcp6_unittests_SOURCES += get_config_unittest.cc get_config_unittest.h
dhcp6_unittests_SOURCES += hooks_unittest.cc
dhcp6_unittests_SOURCES += host_unittest.cc
dhcp6_unittests_SOURCES += infrequest_unittest.cc
dhcp6_unittests_SOURCES += kea_controller_unittest.cc
dhcp6_unittests_SOURCES += marker_file.cc
dhcp6_unittests_SOURCES += parser_unittest.cc
dhcp6_unittests_SOURCES += rebind_unittest.cc
dhcp6_unittests_SOURCES += renew_unittest.cc
dhcp6_unittests_SOURCES += sarr_unittest.cc
dhcp6_unittests_SOURCES += simple_parser6_unittest.cc
dhcp6_unittests_SOURCES += shared_network_unittest.cc
dhcp6_unittests_SOURCES += tee_times_unittest.cc
dhcp6_unittests_SOURCES += vendor_opts_unittest.cc

nodist_dhcp6_unittests_SOURCES  = marker_file.h test_libraries.h

dhcp6_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
dhcp6_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS)
if HAVE_MYSQL
dhcp6_unittests_LDFLAGS += $(MYSQL_LIBS)
endif
if HAVE_PGSQL
dhcp6_unittests_LDFLAGS += $(PGSQL_LIBS)
endif
dhcp6_unittests_LDFLAGS += $(GTEST_LDFLAGS)

dhcp6_unittests_LDADD = $(top_builddir)/src/bin/dhcp6/libdhcp6.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la

if HAVE_MYSQL
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
if HAVE_PGSQL
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/pgsql/testutils/libpgsqltest.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
endif

dhcp6_unittests_LDADD += $(top_builddir)/src/lib/database/testutils/libdatabasetest.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
dhcp6_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
dhcp6_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)

# Run C++ tests on "make check".
TESTS += $(PROGRAM_TESTS)

# Don't install C++ tests.
noinst_PROGRAMS = $(PROGRAM_TESTS)

# Use this target if you want to rebuild the get-config unit-tests.
#
# TODO: We could also automate the replacement step with some variation
# of this: https://stackoverflow.com/questions/6790631
rebuild-tests:
	rm -f x u get_config_unittest.cc
	cp -f get_config_unittest.cc.skel get_config_unittest.cc
	$(MAKE) CXXFLAGS=-DEXTRACT_CONFIG V=1
	./dhcp6_unittests --gtest_filter="Dhcp6Parser*" > /dev/null 2> x
	echo "Please copy content of x file into EXTRACTED_CONFIGS in get_config_unittest.cc"
	read -p "Press ENTER when ready"
	$(MAKE) CXXFLAGS=-DGENERATE_ACTION V=1
	./dhcp6_unittests --gtest_filter="Dhcp6GetConfig*" > /dev/null 2> u
	echo "Please copy content of u file into UNPARSED_CONFIGS in get_config_unittest.cc"
	read -p "Press ENTER when ready"
	touch get_config_unittest.cc
	$(MAKE)

endif