aboutsummaryrefslogtreecommitdiff
path: root/src/rust/crypto
diff options
context:
space:
mode:
authorIsis Lovecruft <isis@torproject.org>2018-06-18 18:57:38 +0000
committerIsis Lovecruft <isis@torproject.org>2018-06-18 18:57:38 +0000
commit508332feaf99ada12037c3a7fa77eab8516bb69e (patch)
treeb4ce84ed9d4324920b59441b2243d244902c9ee9 /src/rust/crypto
parentbcc1368c77d6ed8ac7f8bd81acdec7bb2da9f925 (diff)
downloadtor-508332feaf99ada12037c3a7fa77eab8516bb69e.tar.gz
tor-508332feaf99ada12037c3a7fa77eab8516bb69e.zip
rust: Add "test-c-from-rust" feature-gate.
Due to linker issues (#25386) when testing Rust code which calls C, all tests which touch FFI code should now be feature-gated behind the "test-c-from-rust" flag. To run this test code, cargo must be called with `cargo test --features="test-c-from-rust"`. * FIXES #26398: https://bugs.torproject.org/26398
Diffstat (limited to 'src/rust/crypto')
-rw-r--r--src/rust/crypto/Cargo.toml4
-rw-r--r--src/rust/crypto/digests/sha2.rs6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/rust/crypto/Cargo.toml b/src/rust/crypto/Cargo.toml
index c0c5e7bf93..c31c8e185a 100644
--- a/src/rust/crypto/Cargo.toml
+++ b/src/rust/crypto/Cargo.toml
@@ -26,4 +26,8 @@ rand_core = { version = "=0.2.0-pre.0", default-features = false }
[features]
testing = ["tor_log/testing"]
+# If this feature is enabled, test code which calls Tor C code from Rust will
+# execute with `cargo test`. Due to numerous linker issues (#25386), this is
+# currently disabled by default.
+test-c-from-rust = []
diff --git a/src/rust/crypto/digests/sha2.rs b/src/rust/crypto/digests/sha2.rs
index 1cbb6c581e..bb610ed9e2 100644
--- a/src/rust/crypto/digests/sha2.rs
+++ b/src/rust/crypto/digests/sha2.rs
@@ -165,15 +165,19 @@ impl FixedOutput for Sha512 {
#[cfg(test)]
mod test {
+ #[cfg(feature = "test-c-from-rust")]
use digest::Digest;
+ #[cfg(feature = "test-c-from-rust")]
use super::*;
+ #[cfg(feature = "test-c-from-rust")]
#[test]
fn sha256_default() {
let _: Sha256 = Sha256::default();
}
+ #[cfg(feature = "test-c-from-rust")]
#[test]
fn sha256_digest() {
let mut h: Sha256 = Sha256::new();
@@ -190,11 +194,13 @@ mod test {
assert_eq!(&result[..], &b"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"[..]);
}
+ #[cfg(feature = "test-c-from-rust")]
#[test]
fn sha512_default() {
let _: Sha512 = Sha512::default();
}
+ #[cfg(feature = "test-c-from-rust")]
#[test]
fn sha512_digest() {
let mut h: Sha512 = Sha512::new();