include.am 11.5 KB
Newer Older
1
2
3
4
# When the day comes that Tor requires Automake >= 1.12 change
# TESTS_ENVIRONMENT to AM_TESTS_ENVIRONMENT because the former is reserved for
# users while the later is reserved for developers.
TESTS_ENVIRONMENT = \
5
6
7
	export PYTHON="$(PYTHON)"; \
	export SHELL="$(SHELL)"; \
	export abs_top_srcdir="$(abs_top_srcdir)"; \
8
	export abs_top_builddir="$(abs_top_builddir)"; \
9
	export builddir="$(builddir)"; \
10
	export TESTING_TOR_BINARY="$(TESTING_TOR_BINARY)"; \
11
	export CARGO="$(CARGO)"; \
12
	export EXTRA_CARGO_OPTIONS="$(EXTRA_CARGO_OPTIONS)"; \
13
	export CARGO_ONLINE="$(CARGO_ONLINE)"; \
Nick Mathewson's avatar
Nick Mathewson committed
14
15
16
	export CCLD="$(CCLD)"; \
	chmod +x "$(abs_top_builddir)/link_rust.sh"; \
	export RUSTFLAGS="-C linker=$(abs_top_builddir)/link_rust.sh";
17

18
19
20
TESTSCRIPTS = \
	src/test/fuzz_static_testcases.sh \
	src/test/test_zero_length_keys.sh \
21
22
23
24
25
26
	src/test/test_workqueue_cancel.sh \
	src/test/test_workqueue_efd.sh \
	src/test/test_workqueue_efd2.sh \
	src/test/test_workqueue_pipe.sh \
	src/test/test_workqueue_pipe2.sh \
	src/test/test_workqueue_socketpair.sh \
27
	src/test/test_switch_id.sh
28

29
30
31
32
33
if USE_RUST
TESTSCRIPTS += \
	src/test/test_rust.sh
endif

34
if USEPYTHON
35
TESTSCRIPTS += src/test/test_ntor.sh src/test/test_hs_ntor.sh src/test/test_bt.sh
36
37
endif

38
TESTS += src/test/test src/test/test-slow src/test/test-memwipe \
39
40
	src/test/test_workqueue \
	src/test/test_keygen.sh \
41
	src/test/test_key_expiration.sh \
42
	src/test/test-timers \
43
	$(TESTSCRIPTS)
44

45
# These flavors are run using automake's test-driver and test-network.sh
46
47
TEST_CHUTNEY_FLAVORS = basic-min bridges-min hs-v2-min hs-v3-min \
	single-onion-v23
48
# only run if we can ping6 ::1 (localhost)
49
# IPv6-only v3 single onion services don't work yet, so we don't test the
50
51
52
# single-onion-v23-ipv6-md flavor
TEST_CHUTNEY_FLAVORS_IPV6 = bridges+ipv6-min ipv6-exit-min hs-v23-ipv6-md \
	single-onion-ipv6-md
53
# only run if we can find a stable (or simply another) version of tor
54
TEST_CHUTNEY_FLAVORS_MIXED = mixed+hs-v23
55

56
### This is a lovely feature, but it requires automake >= 1.12, and Tor
57
###  doesn't require that yet.
58
59
60
61
###
# TEST_EXTENSIONS = .sh
# SH_LOG_COMPILER = $(SHELL)

62
63
noinst_PROGRAMS+= src/test/bench
if UNITTESTS_ENABLED
64
65
66
noinst_PROGRAMS+= \
	src/test/test \
	src/test/test-slow \
Nick Mathewson's avatar
Nick Mathewson committed
67
	src/test/test-memwipe \
68
	src/test/test-child \
69
	src/test/test_workqueue \
70
71
	src/test/test-switch-id \
	src/test/test-timers
72
endif
Stewart Smith's avatar
Stewart Smith committed
73
74

src_test_AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \
Nick Mathewson's avatar
Nick Mathewson committed
75
76
	-DLOCALSTATEDIR="\"$(localstatedir)\"" \
	-DBINDIR="\"$(bindir)\""	       \
77
78
	-DTOR_UNIT_TESTS                       \
	$(AM_CPPFLAGS)
Stewart Smith's avatar
Stewart Smith committed
79
80
81
82
83

# -L flags need to go in LDFLAGS. -l flags need to go in LDADD.
# This seems to matter nowhere but on Windows, but I assure you that it
# matters a lot there, and is quite hard to debug if you forget to do it.

rl1987's avatar
rl1987 committed
84
85
86
87
src_test_test_SOURCES =

if UNITTESTS_ENABLED
src_test_test_SOURCES += \
Ola Bini's avatar
Ola Bini committed
88
	src/test/log_test_helpers.c \
89
	src/test/hs_test_helpers.c \
Ola Bini's avatar
Ola Bini committed
90
	src/test/rend_test_helpers.c \
Stewart Smith's avatar
Stewart Smith committed
91
	src/test/test.c \
92
	src/test/test_accounting.c \
Stewart Smith's avatar
Stewart Smith committed
93
	src/test/test_addr.c \
94
	src/test/test_address.c \
95
	src/test/test_address_set.c \
96
	src/test/test_bridges.c \
97
	src/test/test_buffers.c \
98
	src/test/test_bwmgt.c \
99
	src/test/test_cell_formats.c \
100
	src/test/test_cell_queue.c \
101
	src/test/test_channel.c \
102
	src/test/test_channelpadding.c \
Andrea Shepard's avatar
Andrea Shepard committed
103
	src/test/test_channeltls.c \
104
	src/test/test_checkdir.c \
105
	src/test/test_circuitlist.c \
106
	src/test/test_circuitmux.c \
Taylor Yu's avatar
Taylor Yu committed
107
	src/test/test_circuitbuild.c \
108
	src/test/test_circuituse.c \
Mike Perry's avatar
Mike Perry committed
109
	src/test/test_circuitstats.c \
Ola Bini's avatar
Ola Bini committed
110
	src/test/test_compat_libevent.c \
111
	src/test/test_config.c \
112
	src/test/test_connection.c \
113
	src/test/test_conscache.c \
114
	src/test/test_consdiff.c \
115
	src/test/test_consdiffmgr.c \
Stewart Smith's avatar
Stewart Smith committed
116
	src/test/test_containers.c \
117
	src/test/test_controller.c \
118
	src/test/test_controller_events.c \
Stewart Smith's avatar
Stewart Smith committed
119
	src/test/test_crypto.c \
120
	src/test/test_crypto_ope.c \
Stewart Smith's avatar
Stewart Smith committed
121
122
	src/test/test_data.c \
	src/test/test_dir.c \
123
	src/test/test_dir_common.c \
124
	src/test/test_dir_handle_get.c \
125
	src/test/test_dos.c \
126
	src/test/test_entryconn.c \
127
	src/test/test_entrynodes.c \
128
	src/test/test_geoip.c \
129
	src/test/test_guardfraction.c \
Nick Mathewson's avatar
Nick Mathewson committed
130
	src/test/test_extorport.c \
131
	src/test/test_hs.c \
132
	src/test/test_hs_common.c \
133
	src/test/test_hs_config.c \
134
	src/test/test_hs_cell.c \
135
	src/test/test_hs_ntor.c \
136
	src/test/test_hs_service.c \
137
	src/test/test_hs_client.c  \
138
	src/test/test_hs_intropoint.c \
David Goulet's avatar
David Goulet committed
139
	src/test/test_hs_control.c \
140
	src/test/test_handles.c \
141
	src/test/test_hs_cache.c \
142
	src/test/test_hs_descriptor.c \
Stewart Smith's avatar
Stewart Smith committed
143
	src/test/test_introduce.c \
144
	src/test/test_keypin.c \
145
	src/test/test_link_handshake.c \
146
	src/test/test_logging.c \
147
	src/test/test_mainloop.c \
Stewart Smith's avatar
Stewart Smith committed
148
	src/test/test_microdesc.c \
149
	src/test/test_nodelist.c \
150
	src/test/test_oom.c \
151
	src/test/test_oos.c \
152
	src/test/test_options.c \
153
	src/test/test_pem.c \
154
	src/test/test_periodic_event.c \
155
	src/test/test_policy.c \
156
	src/test/test_procmon.c \
157
	src/test/test_proto_http.c \
158
	src/test/test_proto_misc.c \
159
	src/test/test_protover.c \
Stewart Smith's avatar
Stewart Smith committed
160
	src/test/test_pt.c \
161
	src/test/test_relay.c \
162
	src/test/test_relaycell.c \
163
	src/test/test_relaycrypt.c \
Ola Bini's avatar
Ola Bini committed
164
	src/test/test_rendcache.c \
Stewart Smith's avatar
Stewart Smith committed
165
	src/test/test_replay.c \
166
	src/test/test_router.c \
167
	src/test/test_routerkeys.c \
168
	src/test/test_routerlist.c \
169
	src/test/test_routerset.c \
Andrea Shepard's avatar
Andrea Shepard committed
170
	src/test/test_scheduler.c \
David Goulet's avatar
David Goulet committed
171
	src/test/test_shared_random.c \
172
	src/test/test_socks.c \
173
	src/test/test_status.c \
174
	src/test/test_storagedir.c \
175
	src/test/test_threads.c \
Ola Bini's avatar
Ola Bini committed
176
	src/test/test_tortls.c \
Stewart Smith's avatar
Stewart Smith committed
177
	src/test/test_util.c \
Ola Bini's avatar
Ola Bini committed
178
	src/test/test_util_format.c \
Ola Bini's avatar
Ola Bini committed
179
	src/test/test_util_process.c \
180
	src/test/test_voting_schedule.c \
181
	src/test/test_helpers.c \
182
	src/test/test_dns.c \
183
	src/test/testing_common.c \
184
	src/test/testing_rsakeys.c \
185
	src/ext/tinytest.c
186
187
188
189
190

if USE_NSS
# ...
else
src_test_test_SOURCES += \
191
	src/test/test_crypto_openssl.c \
192
193
194
	src/test/test_tortls_openssl.c
endif

rl1987's avatar
rl1987 committed
195
endif
Stewart Smith's avatar
Stewart Smith committed
196

rl1987's avatar
rl1987 committed
197
198
199
src_test_test_slow_SOURCES =
if UNITTESTS_ENABLED
src_test_test_slow_SOURCES += \
200
201
202
203
	src/test/test_slow.c \
	src/test/test_crypto_slow.c \
	src/test/test_util_slow.c \
	src/test/testing_common.c \
204
	src/test/testing_rsakeys.c \
205
	src/ext/tinytest.c
rl1987's avatar
rl1987 committed
206
endif
207

Nick Mathewson's avatar
Nick Mathewson committed
208
209
210
src_test_test_memwipe_SOURCES = \
	src/test/test-memwipe.c

211
212
src_test_test_timers_SOURCES = \
	src/test/test-timers.c
213

214
215
src_test_test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)

216
src_test_test_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
Stewart Smith's avatar
Stewart Smith committed
217
218
219
220

src_test_bench_SOURCES = \
	src/test/bench.c

221
222
223
224
src_test_test_workqueue_SOURCES = \
	src/test/test_workqueue.c
src_test_test_workqueue_CPPFLAGS= $(src_test_AM_CPPFLAGS)
src_test_test_workqueue_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
225

226
227
228
229
src_test_test_switch_id_SOURCES = \
	src/test/test_switch_id.c
src_test_test_switch_id_CPPFLAGS= $(src_test_AM_CPPFLAGS)
src_test_test_switch_id_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
230
src_test_test_switch_id_LDFLAGS = @TOR_LDFLAGS_zlib@
231
src_test_test_switch_id_LDADD = \
232
	$(TOR_UTIL_TESTING_LIBS) \
233
	$(rust_ldadd) \
234
	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
235
	@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_USERENV@ \
236
	@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
237

238
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
Nick Mathewson's avatar
Nick Mathewson committed
239
	@TOR_LDFLAGS_libevent@
240
src_test_test_LDADD = \
Nick Mathewson's avatar
Nick Mathewson committed
241
	$(TOR_INTERNAL_TESTING_LIBS) \
242
	$(rust_ldadd) \
Stewart Smith's avatar
Stewart Smith committed
243
	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
244
	$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
245
246
	@CURVE25519_LIBS@ \
	@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
Stewart Smith's avatar
Stewart Smith committed
247

248
249
250
251
252
src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
src_test_test_slow_LDADD = $(src_test_test_LDADD)
src_test_test_slow_LDFLAGS = $(src_test_test_LDFLAGS)

Nick Mathewson's avatar
Nick Mathewson committed
253
src_test_test_memwipe_CPPFLAGS = $(src_test_test_CPPFLAGS)
254
# Don't use bugtrap cflags here: memwipe tests require memory violations.
255
src_test_test_memwipe_CFLAGS = $(TEST_CFLAGS)
Nick Mathewson's avatar
Nick Mathewson committed
256
src_test_test_memwipe_LDADD = $(src_test_test_LDADD)
257
258
# The LDFLAGS need to include the bugtrap cflags, or else we won't link
# successfully with the libraries built with them.
259
src_test_test_memwipe_LDFLAGS = $(src_test_test_LDFLAGS) @CFLAGS_BUGTRAP@
Nick Mathewson's avatar
Nick Mathewson committed
260

261
src_test_bench_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
Nick Mathewson's avatar
Nick Mathewson committed
262
	@TOR_LDFLAGS_libevent@
263
src_test_bench_LDADD = \
Nick Mathewson's avatar
Nick Mathewson committed
264
	$(TOR_INTERNAL_LIBS) \
265
	$(rust_ldadd) \
Stewart Smith's avatar
Stewart Smith committed
266
	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
267
	$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
268
269
	@CURVE25519_LIBS@ \
	@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
Stewart Smith's avatar
Stewart Smith committed
270

271
src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
Nick Mathewson's avatar
Nick Mathewson committed
272
	@TOR_LDFLAGS_libevent@
273
src_test_test_workqueue_LDADD = \
Nick Mathewson's avatar
Nick Mathewson committed
274
	$(TOR_INTERNAL_TESTING_LIBS) \
275
	$(rust_ldadd) \
276
	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
277
	$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
278
279
	@CURVE25519_LIBS@ \
	@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
280

281
282
283
src_test_test_timers_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_timers_CFLAGS = $(src_test_test_CFLAGS)
src_test_test_timers_LDADD = \
284
	src/lib/libtor-evloop-testing.a \
285
286
	$(TOR_CRYPTO_TESTING_LIBS) \
	$(TOR_UTIL_TESTING_LIBS) \
287
	$(rust_ldadd) \
288
	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
289
	$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
290
291
	@CURVE25519_LIBS@ \
	@TOR_LZMA_LIBS@
292
293
src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)

Stewart Smith's avatar
Stewart Smith committed
294
noinst_HEADERS+= \
295
	src/test/fakechans.h \
296
	src/test/hs_test_helpers.h \
297
	src/test/log_test_helpers.h \
Nick Mathewson's avatar
Nick Mathewson committed
298
	src/test/rend_test_helpers.h \
299
	src/test/test.h \
300
	src/test/test_helpers.h \
301
	src/test/test_dir_common.h \
302
	src/test/test_connection.h \
303
	src/test/test_descriptors.inc \
304
305
	src/test/example_extrainfo.inc \
	src/test/failing_routerdescs.inc \
Nick Mathewson's avatar
Nick Mathewson committed
306
	src/test/ed25519_vectors.inc \
Nick Mathewson's avatar
Nick Mathewson committed
307
	src/test/test_descriptors.inc \
308
	src/test/test_hs_descriptor.inc \
Nick Mathewson's avatar
Nick Mathewson committed
309
	src/test/vote_descriptors.inc
Stewart Smith's avatar
Stewart Smith committed
310

311
noinst_PROGRAMS+= src/test/test-ntor-cl
312
noinst_PROGRAMS+= src/test/test-hs-ntor-cl
313
src_test_test_ntor_cl_SOURCES  = src/test/test_ntor_cl.c
314
src_test_test_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
315
src_test_test_ntor_cl_LDADD = \
Nick Mathewson's avatar
Nick Mathewson committed
316
	$(TOR_INTERNAL_LIBS) \
317
	$(rust_ldadd) \
318
	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
319
	$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
320
	@CURVE25519_LIBS@ @TOR_LZMA_LIBS@
321
src_test_test_ntor_cl_AM_CPPFLAGS =	       \
322
	$(AM_CPPFLAGS)
323

324
src_test_test_hs_ntor_cl_SOURCES  = src/test/test_hs_ntor_cl.c
325
src_test_test_hs_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
326
327
src_test_test_hs_ntor_cl_LDADD = \
	$(TOR_INTERNAL_LIBS) \
328
	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
329
	$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
330
src_test_test_hs_ntor_cl_AM_CPPFLAGS =	       \
331
	$(AM_CPPFLAGS)
332
333


334
if UNITTESTS_ENABLED
Nick Mathewson's avatar
Nick Mathewson committed
335
336
noinst_PROGRAMS += src/test/test-bt-cl
src_test_test_bt_cl_SOURCES = src/test/test_bt_cl.c
337
338
src_test_test_bt_cl_LDADD = \
	$(TOR_UTIL_TESTING_LIBS) \
339
	$(rust_ldadd) \
Nick Mathewson's avatar
Nick Mathewson committed
340
	@TOR_LIB_MATH@ \
341
	@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@
Nick Mathewson's avatar
Nick Mathewson committed
342
src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
343
src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
344
endif
Nick Mathewson's avatar
Nick Mathewson committed
345

346
347
348
EXTRA_DIST += \
	src/test/bt_test.py \
	src/test/ntor_ref.py \
349
	src/test/hs_ntor_ref.py \
350
351
	src/test/hs_build_address.py \
	src/test/hs_indexes.py \
Nick Mathewson's avatar
Nick Mathewson committed
352
	src/test/fuzz_static_testcases.sh \
353
	src/test/slownacl_curve25519.py \
Nick Mathewson's avatar
Nick Mathewson committed
354
	src/test/zero_length_keys.sh \
Nick Mathewson's avatar
Nick Mathewson committed
355
	src/test/rust_supp.txt \
356
	src/test/test_keygen.sh \
357
	src/test/test_key_expiration.sh \
358
	src/test/test_zero_length_keys.sh \
359
	src/test/test_ntor.sh src/test/test_hs_ntor.sh src/test/test_bt.sh \
Nick Mathewson's avatar
Nick Mathewson committed
360
	src/test/test-network.sh \
361
	src/test/test_rust.sh \
362
363
364
365
366
367
368
369
	src/test/test_switch_id.sh \
	src/test/test_workqueue_cancel.sh \
	src/test/test_workqueue_efd.sh \
	src/test/test_workqueue_efd2.sh \
	src/test/test_workqueue_pipe.sh \
	src/test/test_workqueue_pipe2.sh \
	src/test/test_workqueue_socketpair.sh

370
test-rust:
371
	$(TESTS_ENVIRONMENT) "$(abs_top_srcdir)/src/test/test_rust.sh"