]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
rust: Add "test-c-from-rust" feature-gate.
authorIsis Lovecruft <isis@torproject.org>
Mon, 18 Jun 2018 18:57:38 +0000 (18:57 +0000)
committerIsis Lovecruft <isis@torproject.org>
Mon, 18 Jun 2018 18:57:38 +0000 (18:57 +0000)
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

src/rust/Cargo.toml
src/rust/crypto/Cargo.toml
src/rust/crypto/digests/sha2.rs

index c3e44d2a7950d1a2d3c6beb3d0cddce02b24d251..4bbadbe5352b84d46e63d515e3285b88223e95f6 100644 (file)
@@ -14,3 +14,12 @@ members = [
 debug = true
 panic = "abort"
 
+[features]
+default = []
+# 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.  Crates listed here are those which, in their
+# unittests, doctests, and/or integration tests, call C code.
+test-c-from-rust = [
+    "crypto/test-c-from-rust",
+]
index c0c5e7bf93c57b7b54c06dfa86ff0b315d0b70d6..c31c8e185a713cf8fc84fa2c2595f1a259d349c2 100644 (file)
@@ -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 = []
 
index 1cbb6c581e6efdcff923f95e199a72791735ff6f..bb610ed9e219fc4e627b78202b9f9410e26f9c21 100644 (file)
@@ -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();