From 7767f8e9e0ddcf8e707409444fbd10e4ca56d092 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Sat, 14 Mar 2020 10:58:09 -0600 Subject: [PATCH 1/4] Add librustzcash tests to the full test suite. --- qa/zcash/full_test_suite.py | 21 +++++++++++++++++++++ src/Makefile.am | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/qa/zcash/full_test_suite.py b/qa/zcash/full_test_suite.py index 1e80ee210..8293a6b21 100755 --- a/qa/zcash/full_test_suite.py +++ b/qa/zcash/full_test_suite.py @@ -126,13 +126,33 @@ 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): + arch_dirs = glob(os.path.join(REPOROOT, 'target', 'x86_64-apple-darwin*')) + if arch_dirs: + # Just try the first one; there will only be on in CI + target_dir = arch_dirs[0] + 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 # STAGES = [ 'check-depends', + 'rust-test', 'btest', 'gtest', 'sec-hard', @@ -145,6 +165,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, diff --git a/src/Makefile.am b/src/Makefile.am index f26805378..a512029f9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 From bd84d4fdb8e3d6ddc7b67fd20fcb973a039c7b98 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Sat, 14 Mar 2020 10:58:31 -0600 Subject: [PATCH 2/4] Add release profile optimizations and turn off panic unwinding in librustzcash. --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index f860d8339..663af314f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 From 531c7c2881e39135bdbbef1dacfdeb349683e6c7 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Sat, 14 Mar 2020 11:04:39 -0600 Subject: [PATCH 3/4] Minor typo fixes. --- qa/zcash/full_test_suite.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qa/zcash/full_test_suite.py b/qa/zcash/full_test_suite.py index 8293a6b21..847fa9908 100755 --- a/qa/zcash/full_test_suite.py +++ b/qa/zcash/full_test_suite.py @@ -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 @@ -131,7 +131,7 @@ def rust_test(): if not os.path.isdir(target_dir): arch_dirs = glob(os.path.join(REPOROOT, 'target', '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 target_dir = arch_dirs[0] if os.path.isdir(target_dir): @@ -146,6 +146,7 @@ def rust_test(): # Didn't manage to run anything return False + # # Tests # From 81a633c9c37a237609f008c7834a78157db60e93 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Sat, 14 Mar 2020 11:05:56 -0600 Subject: [PATCH 4/4] Simplification for MacOS in rust-test. --- qa/zcash/full_test_suite.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/qa/zcash/full_test_suite.py b/qa/zcash/full_test_suite.py index 847fa9908..879688207 100755 --- a/qa/zcash/full_test_suite.py +++ b/qa/zcash/full_test_suite.py @@ -129,10 +129,7 @@ def util_test(): def rust_test(): target_dir = os.path.join(REPOROOT, 'target', 'x86_64-unknown-linux-gnu') if not os.path.isdir(target_dir): - arch_dirs = glob(os.path.join(REPOROOT, 'target', 'x86_64-apple-darwin*')) - if arch_dirs: - # Just try the first one; there will only be one in CI - target_dir = arch_dirs[0] + 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