diff --git a/Cargo.lock b/Cargo.lock index 0ccece6f4efb194e4070b741bdd19c04d670a59c..a18f5f9a0f82ac3e63fe726b1020b4264bd1b25c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,6 +1239,7 @@ dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/lib/modules/ws2p/ws2p/Cargo.toml b/lib/modules/ws2p/ws2p/Cargo.toml index f692491c543222d2a0380ca28d0a12771c4b867a..b7084cd7186e229c6bfd1cabe0d73adf97749515 100644 --- a/lib/modules/ws2p/ws2p/Cargo.toml +++ b/lib/modules/ws2p/ws2p/Cargo.toml @@ -35,6 +35,7 @@ ws = { version = "0.9.*", features = ["permessage-deflate"] } [dev-dependencies] durs-common-tests-tools = { path = "../../../tests-tools/common-tests-tools" } +once_cell = "1.3.1" [features] ssl = ["ws/ssl"] diff --git a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs index 576912cdbc2b1eabd5af38718984c5ce875fadd7..417cc0d4f8182e51583d20ebf92e567b8626b7e9 100644 --- a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs +++ b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs @@ -27,13 +27,18 @@ use durs_ws2p_protocol::connection_state::WS2PConnectionState; use durs_ws2p_protocol::controller::{WS2PControllerEvent, WebsocketActionOrder}; use durs_ws2p_protocol::orchestrator::OrchestratorMsg; use durs_ws2p_protocol::MySelfWs2pNode; +use once_cell::sync::Lazy; use std::sync::mpsc; +use std::sync::Mutex; use std::thread; use std::time::Duration; static PORT: &'static u16 = &10899; static TIMEOUT_IN_MS: &'static u64 = &30_000; +// Empty mutex used to ensure that only one test runs at a time +static MUTEX: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(())); + pub fn currency() -> CurrencyName { CurrencyName(String::from("g1")) } @@ -75,6 +80,7 @@ fn client_node() -> MySelfWs2pNode { #[cfg(unix)] fn test_connection_negociation_denial() { durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]); + let _lock = MUTEX.lock().expect("MUTEX poisoned"); // ===== initialization ===== // client and server are initialized and launched in separate threads @@ -152,6 +158,7 @@ fn test_connection_negociation_denial() { #[cfg(unix)] fn test_connection_negociation_success() { durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]); + let _lock = MUTEX.lock().expect("MUTEX poisoned"); // ===== initialization ===== // client and server are initialized and launched in separate threads