include.am 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. # When the day comes that Tor requires Automake >= 1.12 change
  2. # TESTS_ENVIRONMENT to AM_TESTS_ENVIRONMENT because the former is reserved for
  3. # users while the later is reserved for developers.
  4. TESTS_ENVIRONMENT = \
  5. export PYTHON="$(PYTHON)"; \
  6. export SHELL="$(SHELL)"; \
  7. 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)"; \
  14. export CCLD="$(CCLD)"; \
  15. export RUSTFLAGS="-C linker=`echo '$(CC)' | cut -d' ' -f 1` $(RUST_LINKER_OPTIONS)";
  16. TESTSCRIPTS = \
  17. src/test/fuzz_static_testcases.sh \
  18. src/test/test_zero_length_keys.sh \
  19. src/test/test_workqueue_cancel.sh \
  20. src/test/test_workqueue_efd.sh \
  21. src/test/test_workqueue_efd2.sh \
  22. src/test/test_workqueue_pipe.sh \
  23. src/test/test_workqueue_pipe2.sh \
  24. src/test/test_workqueue_socketpair.sh \
  25. src/test/test_switch_id.sh
  26. if USE_RUST
  27. TESTSCRIPTS += \
  28. src/test/test_rust.sh
  29. endif
  30. if USEPYTHON
  31. TESTSCRIPTS += src/test/test_ntor.sh src/test/test_hs_ntor.sh src/test/test_bt.sh
  32. TESTSCRIPTS += src/test/test_rebind.sh
  33. endif
  34. TESTS += src/test/test src/test/test-slow src/test/test-memwipe \
  35. src/test/test_workqueue \
  36. src/test/test_keygen.sh \
  37. src/test/test_key_expiration.sh \
  38. src/test/test-timers \
  39. $(TESTSCRIPTS)
  40. # These flavors are run using automake's test-driver and test-network.sh
  41. TEST_CHUTNEY_FLAVORS = basic-min bridges-min hs-v2-min hs-v3-min \
  42. single-onion-v23
  43. # only run if we can ping6 ::1 (localhost)
  44. # IPv6-only v3 single onion services don't work yet, so we don't test the
  45. # single-onion-v23-ipv6-md flavor
  46. TEST_CHUTNEY_FLAVORS_IPV6 = bridges+ipv6-min ipv6-exit-min hs-v23-ipv6-md \
  47. single-onion-ipv6-md
  48. # only run if we can find a stable (or simply another) version of tor
  49. TEST_CHUTNEY_FLAVORS_MIXED = mixed+hs-v2
  50. ### This is a lovely feature, but it requires automake >= 1.12, and Tor
  51. ### doesn't require that yet.
  52. ###
  53. # TEST_EXTENSIONS = .sh
  54. # SH_LOG_COMPILER = $(SHELL)
  55. noinst_PROGRAMS+= src/test/bench
  56. if UNITTESTS_ENABLED
  57. noinst_PROGRAMS+= \
  58. src/test/test \
  59. src/test/test-slow \
  60. src/test/test-memwipe \
  61. src/test/test-child \
  62. src/test/test_workqueue \
  63. src/test/test-switch-id \
  64. src/test/test-timers
  65. endif
  66. src_test_AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \
  67. -DLOCALSTATEDIR="\"$(localstatedir)\"" \
  68. -DBINDIR="\"$(bindir)\"" \
  69. -DTOR_UNIT_TESTS \
  70. $(AM_CPPFLAGS)
  71. # -L flags need to go in LDFLAGS. -l flags need to go in LDADD.
  72. # This seems to matter nowhere but on Windows, but I assure you that it
  73. # matters a lot there, and is quite hard to debug if you forget to do it.
  74. src_test_test_SOURCES =
  75. if UNITTESTS_ENABLED
  76. src_test_test_SOURCES += \
  77. src/test/log_test_helpers.c \
  78. src/test/hs_test_helpers.c \
  79. src/test/rend_test_helpers.c \
  80. src/test/test.c \
  81. src/test/test_accounting.c \
  82. src/test/test_addr.c \
  83. src/test/test_address.c \
  84. src/test/test_address_set.c \
  85. src/test/test_bridges.c \
  86. src/test/test_buffers.c \
  87. src/test/test_bwmgt.c \
  88. src/test/test_cell_formats.c \
  89. src/test/test_cell_queue.c \
  90. src/test/test_channel.c \
  91. src/test/test_channelpadding.c \
  92. src/test/test_channeltls.c \
  93. src/test/test_checkdir.c \
  94. src/test/test_circuitlist.c \
  95. src/test/test_circuitmux.c \
  96. src/test/test_circuitbuild.c \
  97. src/test/test_circuituse.c \
  98. src/test/test_circuitstats.c \
  99. src/test/test_compat_libevent.c \
  100. src/test/test_config.c \
  101. src/test/test_connection.c \
  102. src/test/test_conscache.c \
  103. src/test/test_consdiff.c \
  104. src/test/test_consdiffmgr.c \
  105. src/test/test_containers.c \
  106. src/test/test_controller.c \
  107. src/test/test_controller_events.c \
  108. src/test/test_crypto.c \
  109. src/test/test_crypto_ope.c \
  110. src/test/test_data.c \
  111. src/test/test_dir.c \
  112. src/test/test_dir_common.c \
  113. src/test/test_dir_handle_get.c \
  114. src/test/test_dos.c \
  115. src/test/test_entryconn.c \
  116. src/test/test_entrynodes.c \
  117. src/test/test_geoip.c \
  118. src/test/test_guardfraction.c \
  119. src/test/test_extorport.c \
  120. src/test/test_hs.c \
  121. src/test/test_hs_common.c \
  122. src/test/test_hs_config.c \
  123. src/test/test_hs_cell.c \
  124. src/test/test_hs_ntor.c \
  125. src/test/test_hs_service.c \
  126. src/test/test_hs_client.c \
  127. src/test/test_hs_intropoint.c \
  128. src/test/test_hs_control.c \
  129. src/test/test_handles.c \
  130. src/test/test_hs_cache.c \
  131. src/test/test_hs_descriptor.c \
  132. src/test/test_introduce.c \
  133. src/test/test_keypin.c \
  134. src/test/test_link_handshake.c \
  135. src/test/test_logging.c \
  136. src/test/test_mainloop.c \
  137. src/test/test_microdesc.c \
  138. src/test/test_nodelist.c \
  139. src/test/test_oom.c \
  140. src/test/test_oos.c \
  141. src/test/test_options.c \
  142. src/test/test_pem.c \
  143. src/test/test_periodic_event.c \
  144. src/test/test_policy.c \
  145. src/test/test_procmon.c \
  146. src/test/test_proto_http.c \
  147. src/test/test_proto_misc.c \
  148. src/test/test_protover.c \
  149. src/test/test_pt.c \
  150. src/test/test_relay.c \
  151. src/test/test_relaycell.c \
  152. src/test/test_relaycrypt.c \
  153. src/test/test_rendcache.c \
  154. src/test/test_replay.c \
  155. src/test/test_router.c \
  156. src/test/test_routerkeys.c \
  157. src/test/test_routerlist.c \
  158. src/test/test_routerset.c \
  159. src/test/test_scheduler.c \
  160. src/test/test_shared_random.c \
  161. src/test/test_socks.c \
  162. src/test/test_status.c \
  163. src/test/test_storagedir.c \
  164. src/test/test_threads.c \
  165. src/test/test_tortls.c \
  166. src/test/test_util.c \
  167. src/test/test_util_format.c \
  168. src/test/test_util_process.c \
  169. src/test/test_voting_schedule.c \
  170. src/test/test_x509.c \
  171. src/test/test_helpers.c \
  172. src/test/test_dns.c \
  173. src/test/testing_common.c \
  174. src/test/testing_rsakeys.c \
  175. src/ext/tinytest.c
  176. if USE_NSS
  177. # ...
  178. else
  179. src_test_test_SOURCES += \
  180. src/test/test_crypto_openssl.c \
  181. src/test/test_tortls_openssl.c
  182. endif
  183. endif
  184. src_test_test_slow_SOURCES =
  185. if UNITTESTS_ENABLED
  186. src_test_test_slow_SOURCES += \
  187. src/test/test_slow.c \
  188. src/test/test_crypto_slow.c \
  189. src/test/test_util_slow.c \
  190. src/test/testing_common.c \
  191. src/test/testing_rsakeys.c \
  192. src/ext/tinytest.c
  193. endif
  194. src_test_test_memwipe_SOURCES = \
  195. src/test/test-memwipe.c
  196. src_test_test_timers_SOURCES = \
  197. src/test/test-timers.c
  198. src_test_test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  199. src_test_test_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
  200. src_test_bench_SOURCES = \
  201. src/test/bench.c
  202. src_test_test_workqueue_SOURCES = \
  203. src/test/test_workqueue.c
  204. src_test_test_workqueue_CPPFLAGS= $(src_test_AM_CPPFLAGS)
  205. src_test_test_workqueue_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  206. src_test_test_switch_id_SOURCES = \
  207. src/test/test_switch_id.c
  208. src_test_test_switch_id_CPPFLAGS= $(src_test_AM_CPPFLAGS)
  209. src_test_test_switch_id_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  210. src_test_test_switch_id_LDFLAGS = @TOR_LDFLAGS_zlib@
  211. src_test_test_switch_id_LDADD = \
  212. $(TOR_UTIL_TESTING_LIBS) \
  213. $(rust_ldadd) \
  214. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
  215. @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_USERENV@ \
  216. @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  217. src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
  218. @TOR_LDFLAGS_libevent@
  219. src_test_test_LDADD = \
  220. $(TOR_INTERNAL_TESTING_LIBS) \
  221. $(rust_ldadd) \
  222. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  223. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  224. @CURVE25519_LIBS@ \
  225. @TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  226. src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
  227. src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
  228. src_test_test_slow_LDADD = $(src_test_test_LDADD)
  229. src_test_test_slow_LDFLAGS = $(src_test_test_LDFLAGS)
  230. src_test_test_memwipe_CPPFLAGS = $(src_test_test_CPPFLAGS)
  231. # Don't use bugtrap cflags here: memwipe tests require memory violations.
  232. src_test_test_memwipe_CFLAGS = $(TEST_CFLAGS)
  233. src_test_test_memwipe_LDADD = $(src_test_test_LDADD)
  234. # The LDFLAGS need to include the bugtrap cflags, or else we won't link
  235. # successfully with the libraries built with them.
  236. src_test_test_memwipe_LDFLAGS = $(src_test_test_LDFLAGS) @CFLAGS_BUGTRAP@
  237. src_test_bench_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
  238. @TOR_LDFLAGS_libevent@
  239. src_test_bench_LDADD = \
  240. $(TOR_INTERNAL_LIBS) \
  241. $(rust_ldadd) \
  242. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  243. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  244. @CURVE25519_LIBS@ \
  245. @TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  246. src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
  247. @TOR_LDFLAGS_libevent@
  248. src_test_test_workqueue_LDADD = \
  249. $(TOR_INTERNAL_TESTING_LIBS) \
  250. $(rust_ldadd) \
  251. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  252. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  253. @CURVE25519_LIBS@ \
  254. @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  255. src_test_test_timers_CPPFLAGS = $(src_test_test_CPPFLAGS)
  256. src_test_test_timers_CFLAGS = $(src_test_test_CFLAGS)
  257. src_test_test_timers_LDADD = \
  258. src/lib/libtor-evloop-testing.a \
  259. $(TOR_CRYPTO_TESTING_LIBS) \
  260. $(TOR_UTIL_TESTING_LIBS) \
  261. $(rust_ldadd) \
  262. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  263. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  264. @CURVE25519_LIBS@ \
  265. @TOR_LZMA_LIBS@
  266. src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)
  267. noinst_HEADERS+= \
  268. src/test/fakechans.h \
  269. src/test/hs_test_helpers.h \
  270. src/test/log_test_helpers.h \
  271. src/test/rend_test_helpers.h \
  272. src/test/test.h \
  273. src/test/test_helpers.h \
  274. src/test/test_dir_common.h \
  275. src/test/test_connection.h \
  276. src/test/test_tortls.h \
  277. src/test/test_descriptors.inc \
  278. src/test/example_extrainfo.inc \
  279. src/test/failing_routerdescs.inc \
  280. src/test/ed25519_vectors.inc \
  281. src/test/test_descriptors.inc \
  282. src/test/test_hs_descriptor.inc \
  283. src/test/vote_descriptors.inc
  284. noinst_PROGRAMS+= src/test/test-ntor-cl
  285. noinst_PROGRAMS+= src/test/test-hs-ntor-cl
  286. src_test_test_ntor_cl_SOURCES = src/test/test_ntor_cl.c
  287. src_test_test_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
  288. src_test_test_ntor_cl_LDADD = \
  289. $(TOR_INTERNAL_LIBS) \
  290. $(rust_ldadd) \
  291. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
  292. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  293. @CURVE25519_LIBS@ @TOR_LZMA_LIBS@
  294. src_test_test_ntor_cl_AM_CPPFLAGS = \
  295. $(AM_CPPFLAGS)
  296. src_test_test_hs_ntor_cl_SOURCES = src/test/test_hs_ntor_cl.c
  297. src_test_test_hs_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
  298. src_test_test_hs_ntor_cl_LDADD = \
  299. $(TOR_INTERNAL_LIBS) \
  300. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
  301. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
  302. src_test_test_hs_ntor_cl_AM_CPPFLAGS = \
  303. $(AM_CPPFLAGS)
  304. if UNITTESTS_ENABLED
  305. noinst_PROGRAMS += src/test/test-bt-cl
  306. src_test_test_bt_cl_SOURCES = src/test/test_bt_cl.c
  307. src_test_test_bt_cl_LDADD = \
  308. $(TOR_UTIL_TESTING_LIBS) \
  309. $(rust_ldadd) \
  310. @TOR_LIB_MATH@ \
  311. @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@
  312. src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  313. src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
  314. endif
  315. EXTRA_DIST += \
  316. src/test/bt_test.py \
  317. src/test/ntor_ref.py \
  318. src/test/hs_ntor_ref.py \
  319. src/test/hs_build_address.py \
  320. src/test/hs_indexes.py \
  321. src/test/fuzz_static_testcases.sh \
  322. src/test/slownacl_curve25519.py \
  323. src/test/test_rebind.sh \
  324. src/test/test_rebind.py \
  325. src/test/zero_length_keys.sh \
  326. src/test/rust_supp.txt \
  327. src/test/test_keygen.sh \
  328. src/test/test_key_expiration.sh \
  329. src/test/test_zero_length_keys.sh \
  330. src/test/test_ntor.sh src/test/test_hs_ntor.sh src/test/test_bt.sh \
  331. src/test/test-network.sh \
  332. src/test/test_rust.sh \
  333. src/test/test_switch_id.sh \
  334. src/test/test_workqueue_cancel.sh \
  335. src/test/test_workqueue_efd.sh \
  336. src/test/test_workqueue_efd2.sh \
  337. src/test/test_workqueue_pipe.sh \
  338. src/test/test_workqueue_pipe2.sh \
  339. src/test/test_workqueue_socketpair.sh
  340. test-rust:
  341. $(TESTS_ENVIRONMENT) "$(abs_top_srcdir)/src/test/test_rust.sh"