@@ -26,6 +26,7 @@ fn get_and_set_priority_with_normal_policies(
2626 }
2727}
2828
29+ // In macOS it is allowed to specify number as a SCHED_OTHER policy priority.
2930#[ cfg( any(
3031 target_os = "macos" ,
3132 target_os = "openbsd" ,
@@ -39,8 +40,7 @@ fn get_and_set_priority_with_normal_policies(
3940 #[ values( ThreadPriority :: Min , ThreadPriority :: Max , ThreadPriority :: Crossplatform ( 23u8 . try_into( ) . unwrap( ) ) ) ]
4041 priority : ThreadPriority ,
4142) {
42- // In macOS it is allowed to specify number as a SCHED_OTHER policy priority.
43- assert ! ( set_thread_priority_and_policy( thread_native_id( ) , priority, policy, ) . is_ok( ) ) ;
43+ assert ! ( set_thread_priority_and_policy( thread_native_id( ) , priority, policy) . is_ok( ) ) ;
4444}
4545
4646#[ rstest]
@@ -69,6 +69,7 @@ fn check_min_and_max_priority_values(
6969#[ case( ThreadSchedulePolicy :: Normal ( NormalThreadSchedulePolicy :: Other ) ) ]
7070fn set_priority_with_normal_policy_but_with_invalid_value ( #[ case] policy : ThreadSchedulePolicy ) {
7171 let thread_id = thread_native_id ( ) ;
72+ #[ cfg( target_os = "linux" ) ]
7273 let expected = if policy == ThreadSchedulePolicy :: Normal ( NormalThreadSchedulePolicy :: Idle ) {
7374 // In Linux we should get an error whenever a non-zero value is passed as priority and a normal
7475 // scheduling policy is used.
@@ -94,7 +95,8 @@ fn set_priority_with_normal_policy_but_with_invalid_value(#[case] policy: Thread
9495 target_os = "netbsd"
9596) ) ]
9697#[ test]
97- // In macOS the SCHED_OTHER policy allows having a non-zero priority value.
98+ // In macOS the SCHED_OTHER policy allows having a non-zero priority value,
99+ // but the crate doesn't use this opportunity for normal threads and uses niceness instead.
98100fn get_and_set_priority_with_normal_policy ( ) {
99101 let thread_id = thread_native_id ( ) ;
100102 let normal_policy = ThreadSchedulePolicy :: Normal ( NormalThreadSchedulePolicy :: Other ) ;
@@ -108,17 +110,6 @@ fn get_and_set_priority_with_normal_policy() {
108110 Ok ( ( ) )
109111 ) ;
110112 assert_eq ! ( thread_schedule_policy( ) , Ok ( normal_policy) ) ;
111- assert_eq ! (
112- thread_schedule_policy_param( thread_native_id( ) ) ,
113- Ok ( ( normal_policy, ScheduleParams { sched_priority: 23 } ) )
114- ) ;
115- assert_eq ! (
116- Thread :: current( ) ,
117- Ok ( Thread {
118- priority: ThreadPriority :: Crossplatform ( 23u8 . try_into( ) . unwrap( ) ) ,
119- id: thread_native_id( )
120- } )
121- ) ;
122113}
123114
124115#[ rstest]
0 commit comments