include.am 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. if COVERAGE_ENABLED
  33. # ...
  34. else
  35. # Only do this when coverage is not on, since it invokes lots of code
  36. # in a kind of unpredictable way.
  37. TESTSCRIPTS += src/test/test_rebind.sh
  38. endif
  39. endif
  40. TESTS += src/test/test src/test/test-slow src/test/test-memwipe \
  41. src/test/test_workqueue \
  42. src/test/test_keygen.sh \
  43. src/test/test_key_expiration.sh \
  44. src/test/test-timers \
  45. $(TESTSCRIPTS)
  46. # These flavors are run using automake's test-driver and test-network.sh
  47. TEST_CHUTNEY_FLAVORS = basic-min bridges-min hs-v2-min hs-v3-min \
  48. single-onion-v23
  49. # only run if we can ping6 ::1 (localhost)
  50. TEST_CHUTNEY_FLAVORS_IPV6 = bridges+ipv6-min ipv6-exit-min hs-v23-ipv6-md \
  51. single-onion-v23-ipv6-md
  52. # only run if we can find a stable (or simply another) version of tor
  53. TEST_CHUTNEY_FLAVORS_MIXED = mixed+hs-v2
  54. ### This is a lovely feature, but it requires automake >= 1.12, and Tor
  55. ### doesn't require that yet.
  56. ###
  57. # TEST_EXTENSIONS = .sh
  58. # SH_LOG_COMPILER = $(SHELL)
  59. noinst_PROGRAMS+= src/test/bench
  60. if UNITTESTS_ENABLED
  61. noinst_PROGRAMS+= \
  62. src/test/test \
  63. src/test/test-slow \
  64. src/test/test-memwipe \
  65. src/test/test-process \
  66. src/test/test_workqueue \
  67. src/test/test-switch-id \
  68. src/test/test-timers \
  69. src/test/test-rng
  70. endif
  71. src_test_AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \
  72. -DLOCALSTATEDIR="\"$(localstatedir)\"" \
  73. -DBINDIR="\"$(bindir)\"" \
  74. -DTOR_UNIT_TESTS \
  75. $(AM_CPPFLAGS)
  76. # -L flags need to go in LDFLAGS. -l flags need to go in LDADD.
  77. # This seems to matter nowhere but on Windows, but I assure you that it
  78. # matters a lot there, and is quite hard to debug if you forget to do it.
  79. src_test_test_SOURCES =
  80. if UNITTESTS_ENABLED
  81. # ADD_C_FILE: INSERT SOURCES HERE.
  82. src_test_test_SOURCES += \
  83. src/test/log_test_helpers.c \
  84. src/test/hs_test_helpers.c \
  85. src/test/rend_test_helpers.c \
  86. src/test/rng_test_helpers.c \
  87. src/test/test.c \
  88. src/test/test_accounting.c \
  89. src/test/test_addr.c \
  90. src/test/test_address.c \
  91. src/test/test_address_set.c \
  92. src/test/test_bridges.c \
  93. src/test/test_btrack.c \
  94. src/test/test_buffers.c \
  95. src/test/test_bwmgt.c \
  96. src/test/test_cell_formats.c \
  97. src/test/test_cell_queue.c \
  98. src/test/test_channel.c \
  99. src/test/test_channelpadding.c \
  100. src/test/test_circuitpadding.c \
  101. src/test/test_channeltls.c \
  102. src/test/test_checkdir.c \
  103. src/test/test_circuitlist.c \
  104. src/test/test_circuitmux.c \
  105. src/test/test_circuitbuild.c \
  106. src/test/test_circuituse.c \
  107. src/test/test_circuitstats.c \
  108. src/test/test_compat_libevent.c \
  109. src/test/test_config.c \
  110. src/test/test_connection.c \
  111. src/test/test_conscache.c \
  112. src/test/test_consdiff.c \
  113. src/test/test_consdiffmgr.c \
  114. src/test/test_containers.c \
  115. src/test/test_controller.c \
  116. src/test/test_controller_events.c \
  117. src/test/test_crypto.c \
  118. src/test/test_crypto_ope.c \
  119. src/test/test_crypto_rng.c \
  120. src/test/test_data.c \
  121. src/test/test_dir.c \
  122. src/test/test_dir_common.c \
  123. src/test/test_dir_handle_get.c \
  124. src/test/test_dispatch.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 \
  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 \
  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 \
  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 \
  148. src/test/test_microdesc.c \
  149. src/test/test_namemap.c \
  150. src/test/test_netinfo.c \
  151. src/test/test_nodelist.c \
  152. src/test/test_oom.c \
  153. src/test/test_oos.c \
  154. src/test/test_options.c \
  155. src/test/test_pem.c \
  156. src/test/test_periodic_event.c \
  157. src/test/test_policy.c \
  158. src/test/test_process.c \
  159. src/test/test_prob_distr.c \
  160. src/test/test_procmon.c \
  161. src/test/test_proto_http.c \
  162. src/test/test_proto_misc.c \
  163. src/test/test_protover.c \
  164. src/test/test_pt.c \
  165. src/test/test_pubsub_build.c \
  166. src/test/test_pubsub_msg.c \
  167. src/test/test_relay.c \
  168. src/test/test_relaycell.c \
  169. src/test/test_relaycrypt.c \
  170. src/test/test_rendcache.c \
  171. src/test/test_replay.c \
  172. src/test/test_router.c \
  173. src/test/test_routerkeys.c \
  174. src/test/test_routerlist.c \
  175. src/test/test_routerset.c \
  176. src/test/test_scheduler.c \
  177. src/test/test_sendme.c \
  178. src/test/test_shared_random.c \
  179. src/test/test_socks.c \
  180. src/test/test_status.c \
  181. src/test/test_storagedir.c \
  182. src/test/test_threads.c \
  183. src/test/test_tortls.c \
  184. src/test/test_util.c \
  185. src/test/test_util_format.c \
  186. src/test/test_util_process.c \
  187. src/test/test_voting_flags.c \
  188. src/test/test_voting_schedule.c \
  189. src/test/test_x509.c \
  190. src/test/test_helpers.c \
  191. src/test/test_dns.c \
  192. src/test/test_parsecommon.c \
  193. src/test/testing_common.c \
  194. src/test/testing_rsakeys.c \
  195. src/ext/tinytest.c
  196. if USE_NSS
  197. # ...
  198. else
  199. src_test_test_SOURCES += \
  200. src/test/test_crypto_openssl.c \
  201. src/test/test_tortls_openssl.c
  202. endif
  203. endif
  204. src_test_test_slow_SOURCES =
  205. if UNITTESTS_ENABLED
  206. src_test_test_slow_SOURCES += \
  207. src/test/rng_test_helpers.c \
  208. src/test/test_slow.c \
  209. src/test/test_crypto_slow.c \
  210. src/test/test_process_slow.c \
  211. src/test/test_prob_distr.c \
  212. src/test/ptr_helpers.c \
  213. src/test/test_ptr_slow.c \
  214. src/test/testing_common.c \
  215. src/test/testing_rsakeys.c \
  216. src/ext/tinytest.c
  217. endif
  218. src_test_test_memwipe_SOURCES = \
  219. src/test/test-memwipe.c
  220. src_test_test_timers_SOURCES = \
  221. src/test/test-timers.c
  222. src_test_test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  223. src_test_test_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
  224. src_test_bench_SOURCES = \
  225. src/test/bench.c
  226. src_test_test_workqueue_SOURCES = \
  227. src/test/test_workqueue.c
  228. src_test_test_workqueue_CPPFLAGS= $(src_test_AM_CPPFLAGS)
  229. src_test_test_workqueue_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  230. src_test_test_switch_id_SOURCES = \
  231. src/test/test_switch_id.c
  232. src_test_test_switch_id_CPPFLAGS= $(src_test_AM_CPPFLAGS)
  233. src_test_test_switch_id_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  234. src_test_test_switch_id_LDFLAGS = @TOR_LDFLAGS_zlib@
  235. src_test_test_switch_id_LDADD = \
  236. $(TOR_UTIL_TESTING_LIBS) \
  237. $(rust_ldadd) \
  238. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
  239. @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_USERENV@ \
  240. @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  241. src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
  242. @TOR_LDFLAGS_libevent@
  243. src_test_test_LDADD = \
  244. $(TOR_INTERNAL_TESTING_LIBS) \
  245. $(rust_ldadd) \
  246. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  247. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  248. @CURVE25519_LIBS@ \
  249. @TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  250. src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
  251. src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
  252. src_test_test_slow_LDADD = $(src_test_test_LDADD)
  253. src_test_test_slow_LDFLAGS = $(src_test_test_LDFLAGS)
  254. src_test_test_rng_CPPFLAGS = $(src_test_test_CPPFLAGS)
  255. src_test_test_rng_CFLAGS = $(src_test_test_CFLAGS)
  256. src_test_test_rng_SOURCES = src/test/test_rng.c
  257. src_test_test_rng_LDFLAGS = $(src_test_test_LDFLAGS)
  258. src_test_test_rng_LDADD = $(src_test_test_LDADD)
  259. src_test_test_memwipe_CPPFLAGS = $(src_test_test_CPPFLAGS)
  260. # Don't use bugtrap cflags here: memwipe tests require memory violations.
  261. src_test_test_memwipe_CFLAGS = $(TEST_CFLAGS)
  262. src_test_test_memwipe_LDADD = $(src_test_test_LDADD)
  263. # The LDFLAGS need to include the bugtrap cflags, or else we won't link
  264. # successfully with the libraries built with them.
  265. src_test_test_memwipe_LDFLAGS = $(src_test_test_LDFLAGS) @CFLAGS_BUGTRAP@
  266. src_test_bench_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
  267. @TOR_LDFLAGS_libevent@
  268. src_test_bench_LDADD = \
  269. $(TOR_INTERNAL_LIBS) \
  270. $(rust_ldadd) \
  271. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  272. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  273. @CURVE25519_LIBS@ \
  274. @TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  275. src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
  276. @TOR_LDFLAGS_libevent@
  277. src_test_test_workqueue_LDADD = \
  278. $(TOR_INTERNAL_TESTING_LIBS) \
  279. $(rust_ldadd) \
  280. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  281. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  282. @CURVE25519_LIBS@ \
  283. @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
  284. src_test_test_timers_CPPFLAGS = $(src_test_test_CPPFLAGS)
  285. src_test_test_timers_CFLAGS = $(src_test_test_CFLAGS)
  286. src_test_test_timers_LDADD = \
  287. src/lib/libtor-evloop-testing.a \
  288. $(TOR_CRYPTO_TESTING_LIBS) \
  289. $(TOR_UTIL_TESTING_LIBS) \
  290. $(rust_ldadd) \
  291. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
  292. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  293. @CURVE25519_LIBS@ \
  294. @TOR_LZMA_LIBS@
  295. src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)
  296. # ADD_C_FILE: INSERT HEADERS HERE.
  297. noinst_HEADERS+= \
  298. src/test/fakechans.h \
  299. src/test/hs_test_helpers.h \
  300. src/test/log_test_helpers.h \
  301. src/test/rend_test_helpers.h \
  302. src/test/rng_test_helpers.h \
  303. src/test/test.h \
  304. src/test/ptr_helpers.h \
  305. src/test/test_helpers.h \
  306. src/test/test_dir_common.h \
  307. src/test/test_connection.h \
  308. src/test/test_tortls.h \
  309. src/test/test_descriptors.inc \
  310. src/test/example_extrainfo.inc \
  311. src/test/failing_routerdescs.inc \
  312. src/test/ed25519_vectors.inc \
  313. src/test/test_descriptors.inc \
  314. src/test/test_hs_descriptor.inc \
  315. src/test/vote_descriptors.inc
  316. noinst_PROGRAMS+= src/test/test-ntor-cl
  317. noinst_PROGRAMS+= src/test/test-hs-ntor-cl
  318. src_test_test_ntor_cl_SOURCES = src/test/test_ntor_cl.c
  319. src_test_test_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
  320. src_test_test_ntor_cl_LDADD = \
  321. $(TOR_INTERNAL_LIBS) \
  322. $(rust_ldadd) \
  323. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
  324. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
  325. @CURVE25519_LIBS@ @TOR_LZMA_LIBS@
  326. src_test_test_ntor_cl_AM_CPPFLAGS = \
  327. $(AM_CPPFLAGS)
  328. src_test_test_hs_ntor_cl_SOURCES = src/test/test_hs_ntor_cl.c
  329. src_test_test_hs_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
  330. src_test_test_hs_ntor_cl_LDADD = \
  331. $(TOR_INTERNAL_LIBS) \
  332. @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
  333. $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
  334. src_test_test_hs_ntor_cl_AM_CPPFLAGS = \
  335. $(AM_CPPFLAGS)
  336. if UNITTESTS_ENABLED
  337. noinst_PROGRAMS += src/test/test-bt-cl
  338. src_test_test_bt_cl_SOURCES = src/test/test_bt_cl.c
  339. src_test_test_bt_cl_LDADD = \
  340. $(TOR_UTIL_TESTING_LIBS) \
  341. $(rust_ldadd) \
  342. @TOR_LIB_MATH@ \
  343. @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@
  344. src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
  345. src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
  346. endif
  347. EXTRA_DIST += \
  348. src/test/bt_test.py \
  349. src/test/ntor_ref.py \
  350. src/test/hs_ntor_ref.py \
  351. src/test/hs_build_address.py \
  352. src/test/hs_indexes.py \
  353. src/test/fuzz_static_testcases.sh \
  354. src/test/slownacl_curve25519.py \
  355. src/test/test_rebind.sh \
  356. src/test/test_rebind.py \
  357. src/test/zero_length_keys.sh \
  358. src/test/rust_supp.txt \
  359. src/test/test_keygen.sh \
  360. src/test/test_key_expiration.sh \
  361. src/test/test_zero_length_keys.sh \
  362. src/test/test_ntor.sh src/test/test_hs_ntor.sh src/test/test_bt.sh \
  363. src/test/test-network.sh \
  364. src/test/test_rust.sh \
  365. src/test/test_switch_id.sh \
  366. src/test/test_workqueue_cancel.sh \
  367. src/test/test_workqueue_efd.sh \
  368. src/test/test_workqueue_efd2.sh \
  369. src/test/test_workqueue_pipe.sh \
  370. src/test/test_workqueue_pipe2.sh \
  371. src/test/test_workqueue_socketpair.sh
  372. test-rust:
  373. $(TESTS_ENVIRONMENT) "$(abs_top_srcdir)/src/test/test_rust.sh"