Auto merge of #4403 - ebfull:rust-tests, r=str4d

Additional librustzcash integration

This adds librustzcash tests to the full test suite, and brings in the release profile configurations that are currently present in the librustzcash workspace on the other repository. It's very important that we build librustzcash with panic=abort because otherwise the unwinding panics across FFI boundaries could cause undefined behavior.
This commit is contained in:
Homu 2020-03-17 07:50:48 +00:00
commit a125f3f5f8
3 changed files with 26 additions and 2 deletions

View File

@ -31,3 +31,8 @@ rand_core = "0.5.1"
zcash_history = "0.2"
zcash_primitives = "0.2"
zcash_proofs = "0.2"
[profile.release]
lto = true
panic = 'abort'
codegen-units = 1

View File

@ -93,7 +93,7 @@ def ensure_no_dot_so_in_depends():
# Not Linux, try MacOS
arch_dirs = glob(os.path.join(depends_dir, 'x86_64-apple-darwin*'))
if arch_dirs:
# Just try the first one; there will only be on in CI
# Just try the first one; there will only be one in CI
arch_dir = arch_dirs[0]
exit_code = 0
@ -126,6 +126,23 @@ def util_test():
env={'PYTHONPATH': repofile('src/test'), 'srcdir': repofile('src')}
) == 0
def rust_test():
target_dir = os.path.join(REPOROOT, 'target', 'x86_64-unknown-linux-gnu')
if not os.path.isdir(target_dir):
target_dir = os.path.join(REPOROOT, 'target', 'x86_64-apple-darwin')
if os.path.isdir(target_dir):
# cargo build --tests will produce a binary named something
# like rustzcash-b38184f84aaf9146 (see also https://github.com/rust-lang/cargo/issues/1924)
# so let's find it and run it.
test_files = glob(os.path.join(target_dir, 'release', 'rustzcash*'))
for candidate in test_files:
if candidate[-2::] != ".d":
# Only one test target to run
return subprocess.call([candidate]) == 0
# Didn't manage to run anything
return False
#
# Tests
@ -133,6 +150,7 @@ def util_test():
STAGES = [
'check-depends',
'rust-test',
'btest',
'gtest',
'sec-hard',
@ -145,6 +163,7 @@ STAGES = [
STAGE_COMMANDS = {
'check-depends': ['qa/zcash/test-depends-sources-mirror.py'],
'rust-test': rust_test,
'btest': [repofile('src/test/test_bitcoin'), '-p'],
'gtest': [repofile('src/zcash-gtest')],
'sec-hard': check_security_hardening,

View File

@ -79,7 +79,7 @@ $(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.offline
endif
cargo-build: $(CARGO_CONFIGURED)
$(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) --manifest-path $(top_srcdir)/Cargo.toml
$(RUST_ENV_VARS) $(CARGO) build --lib --tests $(RUST_BUILD_OPTS) --manifest-path $(top_srcdir)/Cargo.toml
if TARGET_WINDOWS
LIBRUSTZCASH_WIN=$(top_builddir)/target/$(RUST_TARGET)/release/rustzcash.lib