diff options
| author | Joakim Hulthe <joakim@hulthe.net> | 2025-05-08 10:20:16 +0200 |
|---|---|---|
| committer | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-05-14 18:00:28 +0200 |
| commit | 6dd81d057b397f1b784041663d5f900a1fae38b1 (patch) | |
| tree | c54d95ce409a06f084bf608bce150eda9c3ef3e8 /talpid-core/src | |
| parent | 5cda2363fb38cead126bf0625f5243307167dd6d (diff) | |
| download | mullvadvpn-6dd81d057b397f1b784041663d5f900a1fae38b1.tar.xz mullvadvpn-6dd81d057b397f1b784041663d5f900a1fae38b1.zip | |
Make local resolver tests run sequentially
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/resolver.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/talpid-core/src/resolver.rs b/talpid-core/src/resolver.rs index 15b018c3df..225acf3011 100644 --- a/talpid-core/src/resolver.rs +++ b/talpid-core/src/resolver.rs @@ -621,7 +621,11 @@ mod test { config::{NameServerConfigGroup, ResolverConfig, ResolverOpts}, TokioAsyncResolver, }; - use std::{mem, net::UdpSocket, thread, time::Duration}; + use std::{mem, net::UdpSocket, sync::Mutex, thread, time::Duration}; + + /// Can't have multiple local resolvers running at the same time, as they will try to bind to + /// the same address and port. The tests below use this lock to run sequentially. + static LOCK: Mutex<()> = Mutex::new(()); async fn start_resolver() -> ResolverHandle { super::start_resolver().await.unwrap() @@ -638,7 +642,9 @@ mod test { #[test] fn test_successful_lookup() { + let _mutex = LOCK.lock().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap(); + let handle = rt.block_on(start_resolver()); let test_resolver = get_test_resolver(handle.listening_addr()); @@ -653,6 +659,7 @@ mod test { #[test] fn test_failed_lookup() { + let _mutex = LOCK.lock().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap(); let handle = rt.block_on(start_resolver()); @@ -672,6 +679,7 @@ mod test { #[test] fn test_shutdown() { + let _mutex = LOCK.lock().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap(); let handle = rt.block_on(start_resolver()); |
