From c2d3ed8c81e264dce586d6cdc914de1b1cc55628 Mon Sep 17 00:00:00 2001 From: fufesou Date: Tue, 8 Sep 2026 14:01:46 +0800 Subject: [PATCH] Remove tests that are not very useful. Signed-off-by: fufesou --- src/host/wasapi/stream.rs | 4 -- src/host/wasapi/stream_priority_tests.rs | 60 ------------------------ 2 files changed, 64 deletions(-) delete mode 100644 src/host/wasapi/stream_priority_tests.rs diff --git a/src/host/wasapi/stream.rs b/src/host/wasapi/stream.rs index 3541912..935bab6 100644 --- a/src/host/wasapi/stream.rs +++ b/src/host/wasapi/stream.rs @@ -334,10 +334,6 @@ fn boost_current_thread_priority() -> Result<(), StreamError> { .map_err(|err| super::windows_err_to_cpal_err_message(err, "SetThreadPriority failed: ")) } -#[cfg(test)] -#[path = "stream_priority_tests.rs"] -mod priority_tests; - enum ControlFlow { Break, Continue, diff --git a/src/host/wasapi/stream_priority_tests.rs b/src/host/wasapi/stream_priority_tests.rs deleted file mode 100644 index 8e0deee..0000000 --- a/src/host/wasapi/stream_priority_tests.rs +++ /dev/null @@ -1,60 +0,0 @@ -use super::boost_current_thread_priority; -use windows::Win32::System::Threading; - -const THREAD_PRIORITY_ERROR_RETURN: i32 = i32::MAX; - -#[test] -fn boost_changes_the_calling_thread_priority() { - assert_boost_from(Threading::THREAD_PRIORITY_NORMAL); -} - -#[test] -fn boost_works_from_below_normal_priority() { - assert_boost_from(Threading::THREAD_PRIORITY_BELOW_NORMAL); -} - -#[test] -fn boost_works_from_above_normal_priority() { - assert_boost_from(Threading::THREAD_PRIORITY_ABOVE_NORMAL); -} - -#[test] -fn boost_preserves_time_critical_priority() { - assert_boost_from(Threading::THREAD_PRIORITY_TIME_CRITICAL); -} - -fn assert_boost_from(initial: Threading::THREAD_PRIORITY) { - let parent = unsafe { Threading::GetCurrentThread() }; - let parent_priority = unsafe { Threading::GetThreadPriority(parent) }; - assert_ne!(parent_priority, THREAD_PRIORITY_ERROR_RETURN); - std::thread::spawn(move || unsafe { - let thread = Threading::GetCurrentThread(); - let original = Threading::GetThreadPriority(thread); - assert_ne!(original, THREAD_PRIORITY_ERROR_RETURN); - Threading::SetThreadPriority(thread, initial) - .expect("could not establish initial priority"); - - let result = boost_current_thread_priority(); - let observed = Threading::GetThreadPriority(thread); - let repeated = boost_current_thread_priority(); - let observed_again = Threading::GetThreadPriority(thread); - let restored = Threading::SetThreadPriority(thread, Threading::THREAD_PRIORITY(original)); - - restored.expect("could not restore the original priority"); - result.expect("priority boost failed"); - repeated.expect("repeated priority boost failed"); - assert_eq!( - observed, - Threading::THREAD_PRIORITY_TIME_CRITICAL.0, - "the production priority helper did not boost its calling thread" - ); - assert_eq!(observed_again, observed); - assert_eq!(Threading::GetThreadPriority(thread), original); - }) - .join() - .expect("priority regression thread failed"); - assert_eq!( - unsafe { Threading::GetThreadPriority(parent) }, - parent_priority - ); -}