summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-02-28 10:28:49 -0500
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-04-29 11:33:26 -0400
commit0902ab4b4b7a343c6a352170e998bf6c0d55ba0c (patch)
tree410b7b052b0e47fc91673d7f68147647835dac31
parent1799d3935af2bee74dd1ebc5cb8bd0b5aaa2ec7f (diff)
downloadtor-0902ab4b4b7a343c6a352170e998bf6c0d55ba0c.tar.xz
tor-0902ab4b4b7a343c6a352170e998bf6c0d55ba0c.zip
Fix Rust -> C FFI tests.
Also add a useless protover test to test tests.
-rw-r--r--.gitignore1
-rw-r--r--changes/bug253862
-rw-r--r--configure.ac16
-rw-r--r--meson.build54
-rw-r--r--meson_options.txt13
-rw-r--r--src/common/meson.build2
-rw-r--r--src/common/torint.h4
-rw-r--r--src/meson.build2
-rw-r--r--src/or/meson.build4
-rw-r--r--src/rust/.cargo/config.in15
-rw-r--r--src/rust/.cargo/meson.build32
-rw-r--r--src/rust/Cargo.lock1
-rw-r--r--src/rust/Cargo.toml2
-rw-r--r--src/rust/asan.c5
-rw-r--r--src/rust/external/Cargo.toml1
-rw-r--r--src/rust/external/build.rs10
-rw-r--r--src/rust/meson.build30
-rw-r--r--src/rust/protover/build.rs10
-rw-r--r--src/rust/protover/protover.rs5
-rw-r--r--src/rust/tor_rust/Cargo.toml3
-rwxr-xr-xsrc/rust/tor_rust/build.sh39
-rw-r--r--src/rust/tor_rust/include.am2
-rw-r--r--src/rust/tor_rust/meson.build22
-rw-r--r--src/test/meson.build175
24 files changed, 399 insertions, 51 deletions
diff --git a/.gitignore b/.gitignore
index 1dc5aff2c..7195c9297 100644
--- a/.gitignore
+++ b/.gitignore
@@ -122,6 +122,7 @@ uptime-*.json
# /scripts
/scripts/maint/checkOptionDocs.pl
/scripts/maint/updateVersions.pl
+/scripts/cargo_test
# /src/
/src/Makefile
diff --git a/changes/bug25386 b/changes/bug25386
new file mode 100644
index 000000000..4202cb7a6
--- /dev/null
+++ b/changes/bug25386
@@ -0,0 +1,2 @@
+ o Minor features (testing):
+ - Fix calling C code from Rust tests. Closes ticket 25386.
diff --git a/configure.ac b/configure.ac
index 878f5a88b..d8a88763e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2220,6 +2220,16 @@ fi
CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
+# for Rust
+AC_SUBST(CHOST)
+
+case "$host_os" in
+darwin*)
+ LD_LIBRARY_PATH_VAR=DYLD_LIBRARY_PATH
+*)
+ LD_LIBRARY_PATH_VAR=LD_LIBRARY_PATH
+esac
+
AC_CONFIG_FILES([
Doxyfile
Makefile
@@ -2235,6 +2245,12 @@ AC_CONFIG_FILES([
scripts/maint/updateVersions.pl
])
+AC_CONFIG_FILES([
+ scripts/cargo_test
+], [
+ chmod +x scripts/cargo_test
+])
+
if test "x$asciidoc" = "xtrue" && test "$ASCIIDOC" = "none"; then
regular_mans="doc/tor doc/tor-gencert doc/tor-resolve doc/torify"
for file in $regular_mans ; do
diff --git a/meson.build b/meson.build
index 4adab0994..d6b17dd94 100644
--- a/meson.build
+++ b/meson.build
@@ -2,13 +2,35 @@ project('tor', 'c')
add_project_arguments('-D_GNU_SOURCE', language: 'c')
add_project_arguments('-D_REENTRANT', language: 'c')
+# fix it with LTO
+add_project_arguments('-DTOR_UNIT_TESTS', language: 'c')
cc = meson.get_compiler('c')
+if get_option('fragile_hardening')
+ add_project_arguments('-fsanitize=address', language: 'c')
+ add_project_link_arguments('-fsanitize=address', language: 'c')
+endif
+
orconf = configuration_data()
+if get_option('use_rust')
+ cargo = find_program(get_option('cargo'))
+ cargo_run = run_command(cargo, '--version')
+ if cargo_run.returncode() == 0
+ orconf.set('HAVE_RUST', true)
+ use_rust = true
+ else
+ error('Rust requested but cargo doesn\'t work.')
+ endif
+else
+ use_rust = false
+endif
+
orconf.set('USE_CURVE25519_DONNA', true)
orconf.set('LOGFACILITY', 'LOG_DAEMON')
+orconf.set_quoted('SRCDIR', meson.source_root())
+orconf.set_quoted('BUILDDIR', meson.build_root())
orconf.set_quoted('LOCALSTATEDIR', get_option('localstatedir'))
orconf.set_quoted('CONFDIR', get_option('sysconfdir') + '/tor')
orconf.set_quoted('VERSION', '0.3.3.0-alpha-dev')
@@ -59,7 +81,6 @@ check_headers = [
'sys/file.h',
'sys/ioctl.h',
'sys/limits.h',
- 'sys/mman.h',
'sys/param.h',
'sys/prctl.h',
'sys/random.h',
@@ -87,7 +108,7 @@ foreach h : check_headers
endforeach
foreach t : ['struct in6_addr', 'struct sockaddr_in6', 'sa_family_t']
- orconf.set('HAVE_' + t.to_upper().underscorify(), cc.has_type(t, prefix: '
+ orconf.set('HAVE_' + t.to_upper().underscorify(), cc.has_type(t, prefix: '''
#include <netinet/in.h>
#ifdef _WIN32
#define _WIN32_WINNT 0x0501
@@ -95,7 +116,7 @@ foreach t : ['struct in6_addr', 'struct sockaddr_in6', 'sa_family_t']
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
-'))
+'''))
endforeach
check_funcs = [
@@ -128,6 +149,7 @@ check_funcs = [
'lround',
'memmem',
'memset_s',
+ 'mmap',
'pipe',
'pipe2',
'prctl',
@@ -178,24 +200,24 @@ orconf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix: '#include <time.h>'))
orconf.set('HAVE_STRUCT_TIMEVAL_TV_SEC', cc.has_member('struct timeval', 'tv_sec', prefix: '#include <sys/time.h>'))
-if get_option('use_rust')
- cargo = get_option('cargo')
- cargo_run = run_command(cargo)
- if cargo_run.returncode() == 0
- orconf.set('HAVE_RUST', true)
- use_rust = true
- else
- error('Rust requested but cargo doesn\'t work.')
- endif
-else
- use_rust = false
-endif
-
if cc.has_member('struct tcp_info', 'tcpi_unacked', prefix: '#include <netinet/tcp.h>') and cc.has_member('struct tcp_info', 'tcpi_snd_mss', prefix: '#include <netinet/tcp.h>') and cc.has_header_symbol('linux/sockios.h', 'SIOCOUTQNSD')
orconf.set('HAVE_KIST_SUPPORT', true)
endif
+if cc.has_member('SSL', 'state', prefix: '#include <openssl/ssl.h>')
+ orconf.set('HAVE_SSL_STATE', true)
+endif
+
+check_cc_arguments = [
+ '-Wall',
+ '-Wextra',
+ '-fno-strict-aliasing',
+]
+
+add_project_arguments(cc.get_supported_arguments(check_cc_arguments), language: 'c')
+
configure_file(output: 'orconfig.h', configuration: orconf)
+
add_project_arguments('-I.', language: 'c')
foreach d : ['ext/trunnel', 'trunnel', 'ext', 'common', 'or']
add_project_arguments('-I' + meson.source_root() + '/src/' + d, language: 'c')
diff --git a/meson_options.txt b/meson_options.txt
index 8956ee595..f5558de36 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,2 +1,11 @@
-option('use_rust', type: 'boolean', value: false, description: 'Use rust')
-option('cargo', type: 'string', value: 'cargo', description: 'Path to cargo executable')
+option('chost', type: 'string', value: '', description: 'host triple, auto-detect if empty')
+
+option('manpages', type: 'boolean', value: false, description: 'make manpages')
+
+option('use_rust', type: 'boolean', value: false, description: 'enable rust')
+option('cargo', type: 'string', value: 'cargo', description: 'path to cargo')
+option('rustc', type: 'string', value: 'rustc', description: 'path to rustc')
+option('cargo_online', type: 'boolean', value: false, description: 'allow cargo to download')
+option('tor_rust_dependencies', type: 'string', value: 'src/ext/rust/crates', description: 'path to tor rust dependencies')
+
+option('fragile_hardening', type: 'boolean', value: false, description: 'enable fragile hardening')
diff --git a/src/common/meson.build b/src/common/meson.build
index 7a32020ac..490cdce8b 100644
--- a/src/common/meson.build
+++ b/src/common/meson.build
@@ -27,6 +27,7 @@ libor_src = [
'util_process.c',
'sandbox.c',
'storagedir.c',
+ 'token_bucket.c',
'workqueue.c',
'../ext/readpassphrase.c',
micro_revision,
@@ -51,6 +52,7 @@ libor_crypto_src = [
'compress_zlib.c',
'compress_zstd.c',
'crypto.c',
+ 'crypto_digest.c',
'crypto_format.c',
'crypto_openssl_mgt.c',
'crypto_pwbox.c',
diff --git a/src/common/torint.h b/src/common/torint.h
index fa16929ba..6614fefb7 100644
--- a/src/common/torint.h
+++ b/src/common/torint.h
@@ -13,7 +13,7 @@
#include "orconfig.h"
-#include <stdint.h>
+#include <inttypes.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -43,7 +43,7 @@
# define TOR_PRIuSZ "zu"
#endif
-#define TIME_MAX ((1 << (sizeof(time_t) - 1)) - 1)
+#define TIME_MAX ((((time_t)1 << (CHAR_BIT * sizeof(time_t) - 2)) - 1) * 2 + 1)
#define TIME_MIN (-TIME_MAX - 1)
/** Any ssize_t larger than this amount is likely to be an underflow. */
diff --git a/src/meson.build b/src/meson.build
index 9a9730351..97ac641af 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -7,7 +7,7 @@ if use_rust
subdir('rust')
endif
subdir('or')
-#subdir('test')
+subdir('test')
#subdir('tools')
#subdir('win32')
#subdir('config')
diff --git a/src/or/meson.build b/src/or/meson.build
index 2f4f4bee2..e79903db4 100644
--- a/src/or/meson.build
+++ b/src/or/meson.build
@@ -72,6 +72,7 @@ libtor_sources = [
'policies.c',
'reasons.c',
'relay.c',
+ 'relay_crypto.c',
'rendcache.c',
'rendclient.c',
'rendcommon.c',
@@ -103,4 +104,5 @@ if use_rust
endif
tor_ldadd = [libtor, libor, libor_ctime, libor_crypto, libkeccak_tiny, libdonna, libor_event, libor_trunnel]
-executable('tor', 'tor_main.c', dependencies: tor_deps, link_with: tor_ldadd)
+executable('tor', 'tor_main.c', link_with: tor_ldadd, dependencies: tor_deps)
+shared_module('tor', build_by_default: true, link_whole: tor_ldadd, dependencies: tor_deps)
diff --git a/src/rust/.cargo/config.in b/src/rust/.cargo/config.in
index 301e7fdbe..b4145d805 100644
--- a/src/rust/.cargo/config.in
+++ b/src/rust/.cargo/config.in
@@ -1,8 +1,11 @@
-[source]
+@RUST_DL@[source.crates-io]
+@RUST_DL@replace-with = 'vendored-sources'
-@RUST_DL@ [source.crates-io]
-@RUST_DL@ registry = 'https://github.com/rust-lang/crates.io-index'
-@RUST_DL@ replace-with = 'vendored-sources'
+@RUST_DL@[source.vendored-sources]
+@RUST_DL@directory = '@TOR_RUST_DEPENDENCIES@'
-@RUST_DL@ [source.vendored-sources]
-@RUST_DL@ directory = '@TOR_RUST_DEPENDENCIES@'
+[build]
+@target@
+# not a no-op, fixes out-of-source builds
+target-dir = "./target"
+rustflags = [@rustflags@]
diff --git a/src/rust/.cargo/meson.build b/src/rust/.cargo/meson.build
new file mode 100644
index 000000000..378aac4dc
--- /dev/null
+++ b/src/rust/.cargo/meson.build
@@ -0,0 +1,32 @@
+cargo_config_conf = configuration_data()
+cargo_args = []
+
+chost = get_option('chost')
+if chost == ''
+ if meson.is_cross_build()
+ error('must specify chost for rust cross-compiling')
+ endif
+ cargo_config_conf.set('target', '')
+else
+ cargo_config_conf.set('target', 'target = "' + chost + '"')
+endif
+
+if get_option('cargo_online')
+ cargo_config_conf.set('TOR_RUST_DEPENDENCIES', '')
+ cargo_config_conf.set('RUST_DL', '#')
+else
+ tor_rust_dependencies = join_paths(meson.source_root(), get_option('tor_rust_dependencies'))
+ cargo_config_conf.set('TOR_RUST_DEPENDENCIES', tor_rust_dependencies)
+ cargo_config_conf.set('RUST_DL', '')
+ cargo_args += ['--frozen']
+endif
+
+rustflags = ['-L', '../../or']
+
+if get_option('fragile_hardening')
+ rustflags += ['-Z', 'sanitizer=address']
+endif
+
+cargo_config_conf.set('rustflags', '"' + '", "'.join(rustflags) + '"')
+
+configure_file(input: 'config.in', output: 'config', configuration: cargo_config_conf)
diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock
index 91c0502c6..7032a0ece 100644
--- a/src/rust/Cargo.lock
+++ b/src/rust/Cargo.lock
@@ -48,6 +48,7 @@ dependencies = [
name = "tor_rust"
version = "0.1.0"
dependencies = [
+ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"protover 0.0.1",
"tor_util 0.0.1",
]
diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index 4ae8033eb..bc4d5ef93 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -6,3 +6,5 @@ members = ["tor_util", "protover", "smartlist", "external", "tor_allocate",
debug = true
panic = "abort"
+[profile.test]
+rpath = true
diff --git a/src/rust/asan.c b/src/rust/asan.c
new file mode 100644
index 000000000..018930903
--- /dev/null
+++ b/src/rust/asan.c
@@ -0,0 +1,5 @@
+static const char *asan_default_options = "detect_odr_violation=1";
+
+const char *__asan_default_options() {
+ return asan_default_options;
+}
diff --git a/src/rust/external/Cargo.toml b/src/rust/external/Cargo.toml
index b5957b107..41678e1ec 100644
--- a/src/rust/external/Cargo.toml
+++ b/src/rust/external/Cargo.toml
@@ -10,4 +10,3 @@ libc = "=0.2.39"
name = "external"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]
-
diff --git a/src/rust/external/build.rs b/src/rust/external/build.rs
new file mode 100644
index 000000000..270bb3746
--- /dev/null
+++ b/src/rust/external/build.rs
@@ -0,0 +1,10 @@
+#[no_mangle]
+pub extern "C" fn __asan_default_options() -> *const u8 {
+ b"detect_odr_violation=1\0" as *const [u8] as *const u8
+}
+
+fn main() {
+ println!("cargo:rustc-link-search=native={}/src/or",
+ std::env::var("abs_top_builddir").unwrap());
+ println!("cargo:rustc-link-lib=dylib=tor");
+}
diff --git a/src/rust/meson.build b/src/rust/meson.build
index 123d799c8..75cfdad99 100644
--- a/src/rust/meson.build
+++ b/src/rust/meson.build
@@ -1 +1,31 @@
+subdir('.cargo')
subdir('tor_rust')
+
+tor_rust = declare_dependency(sources: [libtor_rust, 'asan.c'])
+
+cargo_test_args = ['test', '--all', '--all-features',
+ '--manifest-path', meson.source_root() + '/src/rust/Cargo.toml']
+
+if get_option('buildtype') == 'release'
+ cargo_test_args += '--release'
+endif
+
+if get_option('fragile_hardening')
+ warning('skipping doctests because rustdoc is not compatible with ASAN (https://github.com/rust-lang/rust/issues/43031)')
+ cargo_test_args += '--lib'
+endif
+
+cargo_test_env = environment()
+cargo_test_env.set('abs_top_builddir', meson.build_root())
+# https://github.com/rust-lang/rust/issues/43031
+if host_machine.system() != 'windows' and host_machine.system() != 'cygwin'
+ ld_library_path_var = 'LD_LIBRARY_PATH'
+ if host_machine.system() == 'darwin'
+ ld_library_path_var = 'DYLD_LIBRARY_PATH'
+ endif
+ cargo_test_env.prepend(ld_library_path_var, meson.build_root() + '/src/or')
+endif
+
+test('test_rust', cargo, args: cargo_test_args, env: cargo_test_env,
+ workdir: meson.build_root() + '/src/rust',
+ timeout: 300)
diff --git a/src/rust/protover/build.rs b/src/rust/protover/build.rs
new file mode 100644
index 000000000..270bb3746
--- /dev/null
+++ b/src/rust/protover/build.rs
@@ -0,0 +1,10 @@
+#[no_mangle]
+pub extern "C" fn __asan_default_options() -> *const u8 {
+ b"detect_odr_violation=1\0" as *const [u8] as *const u8
+}
+
+fn main() {
+ println!("cargo:rustc-link-search=native={}/src/or",
+ std::env::var("abs_top_builddir").unwrap());
+ println!("cargo:rustc-link-lib=dylib=tor");
+}
diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs
index 514aeffc5..28b0ac5a4 100644
--- a/src/rust/protover/protover.rs
+++ b/src/rust/protover/protover.rs
@@ -812,4 +812,9 @@ mod test {
versions = "1-3,500";
assert_eq!(String::from(versions), ProtoSet::from_str(&versions).unwrap().to_string());
}
+
+ #[test]
+ fn test_compute_for_old_tor() {
+ compute_for_old_tor("9999.9999.9999.9999");
+ }
}
diff --git a/src/rust/tor_rust/Cargo.toml b/src/rust/tor_rust/Cargo.toml
index 86fad3ee7..508cfcf8a 100644
--- a/src/rust/tor_rust/Cargo.toml
+++ b/src/rust/tor_rust/Cargo.toml
@@ -8,6 +8,9 @@ name = "tor_rust"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]
+[dependencies]
+libc = "=0.2.39"
+
[dependencies.tor_util]
path = "../tor_util"
diff --git a/src/rust/tor_rust/build.sh b/src/rust/tor_rust/build.sh
index c013153d0..eba496286 100755
--- a/src/rust/tor_rust/build.sh
+++ b/src/rust/tor_rust/build.sh
@@ -1,22 +1,37 @@
#!/bin/sh
-if [ "$1" = "release" ]; then
+cargo_args=
+
+chost="$1"
+build_type="$2"
+cargo="$3"
+manifest="$(realpath "$4")"
+export abs_top_builddir="$(realpath "$5")"
+output_lib="$6"
+
+shift 6
+
+if [ "$build_type" = "release" ]; then
cargo_build_type=release
- cargo_args=--release
+ cargo_args="$cargo_args --release"
else
cargo_build_type=debug
- cargo_args=
fi
-source_dir="$2"
-output_dir="$(realpath -s "$3")"
-output_lib="$(realpath -s "$4")"
-shift 4
-cd "$source_dir"
+CARGO_OUTPUT_DIR="$abs_top_builddir/src/rust/target"
+
+if [ -n "$chost" ]; then
+ cargo_args="$cargo_args --target $chost"
+ cargo_output_dir="$CARGO_OUTPUT_DIR/$chost/$cargo_build_type"
+else
+ cargo_output_dir="$CARGO_OUTPUT_DIR/$cargo_build_type"
+fi
-set -x
+set -e -x
-CARGO_TARGET_DIR="$output_dir/target.dir" \
- cargo build $cargo_args "$@"
+(
+cd "$abs_top_builddir/src/rust/tor_rust"
+"$cargo" build --manifest-path "$manifest" $cargo_args "$@"
+)
-cp -p "$output_dir/target.dir/$cargo_build_type/libtor_rust.a" "$output_lib"
+cp -p "$cargo_output_dir/libtor_rust.a" "$output_lib"
diff --git a/src/rust/tor_rust/include.am b/src/rust/tor_rust/include.am
index c02324cb7..0299c1c9e 100644
--- a/src/rust/tor_rust/include.am
+++ b/src/rust/tor_rust/include.am
@@ -2,7 +2,7 @@ EXTRA_DIST +=\
src/rust/tor_rust/Cargo.toml \
src/rust/tor_rust/lib.rs
-EXTRA_CARGO_OPTIONS=
+EXTRA_CARGO_OPTIONS = --target @CHOST@
src/rust/target/release/@TOR_RUST_STATIC_NAME@: FORCE
( cd "$(abs_top_builddir)/src/rust" ; \
diff --git a/src/rust/tor_rust/meson.build b/src/rust/tor_rust/meson.build
index 094af9ffa..b0e1a4971 100644
--- a/src/rust/tor_rust/meson.build
+++ b/src/rust/tor_rust/meson.build
@@ -1,9 +1,13 @@
-build_cmd = [files('build.sh'), get_option('buildtype'), '@INPUT@', '@OUTDIR@', '@OUTPUT@']
-
-# input and output are relative to source dir and output dir
-libtor_rust = custom_target('libtor_rust',
- build_always: true,
- command: build_cmd,
- input: '.',
- output: 'libtor_rust.a')
-tor_rust = declare_dependency(sources: libtor_rust)
+libtor_rust = custom_target(
+ 'libtor_rust',
+ build_always: true,
+ command: [
+ files('build.sh'),
+ get_option('chost'),
+ get_option('buildtype'),
+ cargo.path(),
+ '@INPUT@',
+ meson.build_root(),
+ '@OUTPUT@'],
+ input: 'Cargo.toml',
+ output: 'libtor_rust.a')
diff --git a/src/test/meson.build b/src/test/meson.build
new file mode 100644
index 000000000..0bc1f361e
--- /dev/null
+++ b/src/test/meson.build
@@ -0,0 +1,175 @@
+test_src = [
+ 'log_test_helpers.c',
+ 'hs_test_helpers.c',
+ 'rend_test_helpers.c',
+ 'test.c',
+ 'test_accounting.c',
+ 'test_addr.c',
+ 'test_address.c',
+ 'test_address_set.c',
+ 'test_buffers.c',
+ 'test_bridges.c',
+ 'test_bwmgt.c',
+ 'test_cell_formats.c',
+ 'test_cell_queue.c',
+ 'test_channel.c',
+ 'test_channelpadding.c',
+ 'test_channeltls.c',
+ 'test_checkdir.c',
+ 'test_circuitlist.c',
+ 'test_circuitmux.c',
+ 'test_circuitbuild.c',
+ 'test_circuituse.c',
+ 'test_circuitstats.c',
+ 'test_compat_libevent.c',
+ 'test_config.c',
+ 'test_connection.c',
+ 'test_conscache.c',
+ 'test_consdiff.c',
+ 'test_consdiffmgr.c',
+ 'test_containers.c',
+ 'test_controller.c',
+ 'test_controller_events.c',
+ 'test_crypto.c',
+ 'test_crypto_openssl.c',
+ 'test_data.c',
+ 'test_dir.c',
+ 'test_dir_common.c',
+ 'test_dir_handle_get.c',
+ 'test_dos.c',
+ 'test_entryconn.c',
+ 'test_entrynodes.c',
+ 'test_geoip.c',
+ 'test_guardfraction.c',
+ 'test_extorport.c',
+ 'test_hs.c',
+ 'test_hs_common.c',
+ 'test_hs_config.c',
+ 'test_hs_cell.c',
+ 'test_hs_ntor.c',
+ 'test_hs_service.c',
+ 'test_hs_client.c',
+ 'test_hs_intropoint.c',
+ 'test_hs_control.c',
+ 'test_handles.c',
+ 'test_hs_cache.c',
+ 'test_hs_descriptor.c',
+ 'test_introduce.c',
+ 'test_keypin.c',
+ 'test_link_handshake.c',
+ 'test_logging.c',
+ 'test_microdesc.c',
+ 'test_nodelist.c',
+ 'test_oom.c',
+ 'test_oos.c',
+ 'test_options.c',
+ 'test_policy.c',
+ 'test_procmon.c',
+ 'test_proto_http.c',
+ 'test_proto_misc.c',
+ 'test_protover.c',
+ 'test_pt.c',
+ 'test_pubsub.c',
+ 'test_relay.c',
+ 'test_relaycell.c',
+ 'test_rendcache.c',
+ 'test_relaycrypt.c',
+ 'test_replay.c',
+ 'test_router.c',
+ 'test_routerkeys.c',
+ 'test_routerlist.c',
+ 'test_routerset.c',
+ 'test_scheduler.c',
+ 'test_shared_random.c',
+ 'test_socks.c',
+ 'test_status.c',
+ 'test_storagedir.c',
+ 'test_threads.c',
+ 'test_tortls.c',
+ 'test_util.c',
+ 'test_util_format.c',
+ 'test_util_process.c',
+ 'test_helpers.c',
+ 'test_dns.c',
+ 'testing_common.c',
+ 'testing_rsakeys.c',
+ '../ext/tinytest.c',
+]
+
+test_slow_src = [
+ 'test_slow.c',
+ 'test_crypto_slow.c',
+ 'test_util_slow.c',
+ 'testing_common.c',
+ 'testing_rsakeys.c',
+ '../ext/tinytest.c',
+]
+
+test_memwipe_src = [
+ 'test-memwipe.c',
+]
+
+test_timers_src = [
+ 'test-timers.c',
+]
+
+test_workqueue_src = [
+ 'test_workqueue.c',
+]
+
+test_ntor_cl_src = [
+ 'test_ntor_cl.c',
+]
+
+test_hs_ntor_cl_src = [
+ 'test_hs_ntor_cl.c',
+]
+
+test_bt_cl_src = [
+ 'test_bt_cl.c',
+]
+
+if get_option('fragile_hardening')
+ no_san = ['-fno-sanitize=address']
+else
+ no_san = []
+endif
+
+test_exe = executable('tests', test_src, dependencies: tor_deps, link_with: tor_ldadd)
+test_slow_exe = executable('test_slow', test_slow_src, dependencies: tor_deps, link_with: tor_ldadd)
+test_memwipe_exe = executable('test_memwipe', test_memwipe_src, c_args: no_san, dependencies: tor_deps, link_with: tor_ldadd)
+test_timers_exe = executable('test_timers', test_timers_src, dependencies: tor_deps, link_with: tor_ldadd)
+test_workqueue_exe = executable('test_workqueue', test_workqueue_src, dependencies: tor_deps, link_with: tor_ldadd)
+test_ntor_cl_exe = executable('test-ntor-cl', test_ntor_cl_src, dependencies: tor_deps, link_with: tor_ldadd)
+test_hs_ntor_cl_exe = executable('test-hs-ntor-cl', test_hs_ntor_cl_src, dependencies: tor_deps, link_with: tor_ldadd)
+test_bt_cl_exe = executable('test-bt-cl', test_bt_cl_src, dependencies: tor_deps, link_with: tor_ldadd)
+test_child_exe = executable('test-child', 'test-child.c')
+
+test('tests', test_exe, timeout: 300)
+test('slow', test_slow_exe, timeout: 300)
+test('memwipe', test_memwipe_exe)
+test('timers', test_timers_exe, timeout: 300)
+test('workqueue', test_workqueue_exe)
+
+# put test scripts at the end since they run faster than src/test/tests
+
+test_env = environment()
+
+test_env.set('abs_top_srcdir', meson.source_root())
+test_env.set('abs_top_builddir', meson.build_root())
+
+test_scripts = [
+ 'fuzz_static_testcases',
+ 'test_zero_length_keys',
+ 'test_workqueue_cancel',
+ 'test_workqueue_efd',
+ 'test_workqueue_efd2',
+ 'test_workqueue_pipe',
+ 'test_workqueue_pipe2',
+ 'test_workqueue_socketpair',
+ 'test_switch_id',
+]
+
+foreach s : test_scripts
+ test(s, files(s + '.sh'), env: test_env)
+endforeach