diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-16 14:34:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-16 14:34:31 -0400 |
commit | a8ac21fbb5f22b68ffa019b575085c142293bc40 (patch) | |
tree | e32e8574612eba971173c5513bd57eae9162bce3 /src/rust/protover | |
parent | 078debb0ded16e7f8d79d5aa6f4184ae5ad44ff9 (diff) | |
download | tor-a8ac21fbb5f22b68ffa019b575085c142293bc40.tar.gz tor-a8ac21fbb5f22b68ffa019b575085c142293bc40.zip |
Don't try to link C from rust doctests for nss detection
This is really annoying, since we can't use cfg(test) for doctests.
Diffstat (limited to 'src/rust/protover')
-rw-r--r-- | src/rust/protover/Cargo.toml | 6 | ||||
-rw-r--r-- | src/rust/protover/protover.rs | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/rust/protover/Cargo.toml b/src/rust/protover/Cargo.toml index a8480e142a..2f7783e76c 100644 --- a/src/rust/protover/Cargo.toml +++ b/src/rust/protover/Cargo.toml @@ -4,6 +4,11 @@ version = "0.0.1" name = "protover" [features] +# We have to define a feature here because doctests don't get cfg(test), +# and we need to disable some C dependencies when running the doctests +# because of the various linker issues. See +# https://github.com/rust-lang/rust/issues/45599 +test_linking_hack = [] [dependencies] libc = "=0.2.39" @@ -27,4 +32,3 @@ path = "../tor_log" name = "protover" path = "lib.rs" crate_type = ["rlib", "staticlib"] - diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs index 7b3f808cb2..8417d85959 100644 --- a/src/rust/protover/protover.rs +++ b/src/rust/protover/protover.rs @@ -10,7 +10,6 @@ use std::str::FromStr; use std::string::String; use external::c_tor_version_as_new_as; -use external::c_tor_is_using_nss; use errors::ProtoverError; use protoset::ProtoSet; @@ -125,6 +124,17 @@ impl From<Protocol> for UnknownProtocol { } } +#[cfg(feature="test_linking_hack")] +fn have_linkauth_v1() -> bool { + true +} + +#[cfg(not(feature="test_linking_hack"))] +fn have_linkauth_v1() -> bool { + use external::c_tor_is_using_nss; + ! c_tor_is_using_nss() +} + /// Get a CStr representation of current supported protocols, for /// passing to C, or for converting to a `&str` for Rust. /// @@ -142,7 +152,7 @@ impl From<Protocol> for UnknownProtocol { /// // C_RUST_COUPLED: protover.c `protover_get_supported_protocols` pub(crate) fn get_supported_protocols_cstr() -> &'static CStr { - if c_tor_is_using_nss() { + if ! have_linkauth_v1() { cstr!("Cons=1-2 \ Desc=1-2 \ DirCache=1-2 \ |