Skip to content

Commit

Permalink
test: only test immediate park policy
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromfedricci committed Nov 7, 2024
1 parent 215871d commit 333f505
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 109 deletions.
27 changes: 5 additions & 22 deletions src/parking/barging/lock_api/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,42 +74,25 @@ impl<T: ?Sized, Ps: Park, Pq: Park> LockData for Mutex<T, Ps, Pq> {

#[cfg(test)]
mod test {
use crate::parking::barging::lock_api::{immediate, yields};
use crate::parking::barging::lock_api::immediate;
use crate::test::tests;

type Mutex<T> = immediate::Mutex<T>;

type ImmediateMutex<T> = immediate::Mutex<T>;
type YieldThenParkMutex<T> = yields::Mutex<T>;
type ImmediateParkMutex<T> = immediate::Mutex<T>;

#[test]
fn lots_and_lots_lock_immediate_park() {
tests::lots_and_lots_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_lock_yield_then_park() {
tests::lots_and_lots_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_lock::<ImmediateParkMutex<_>>();
}

#[test]
fn lots_and_lots_try_lock_immediate_park() {
tests::lots_and_lots_try_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_try_lock_yield_then_park() {
tests::lots_and_lots_try_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_try_lock::<ImmediateParkMutex<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_immediate_park() {
tests::lots_and_lots_mixed_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_yield_then_park() {
tests::lots_and_lots_mixed_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_mixed_lock::<ImmediateParkMutex<_>>();
}

#[test]
Expand Down
27 changes: 5 additions & 22 deletions src/parking/barging/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,11 @@ impl<T: ?Sized, Ps, Pq> AsDerefMut for MutexGuard<'_, T, Ps, Pq> {

#[cfg(all(not(loom), test))]
mod test {
use crate::parking::barging::{immediate, yields};
use crate::parking::barging::immediate;
use crate::test::tests;

type Mutex<T> = immediate::Mutex<T>;

type ImmediateMutex<T> = immediate::Mutex<T>;
type YieldThenParkMutex<T> = yields::Mutex<T>;
type ImmediateParkMutex<T> = immediate::Mutex<T>;

#[test]
fn node_waiter_drop_does_not_matter() {
Expand All @@ -582,32 +580,17 @@ mod test {

#[test]
fn lots_and_lots_lock_immediate_park() {
tests::lots_and_lots_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_lock_yield_then_park() {
tests::lots_and_lots_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_lock::<ImmediateParkMutex<_>>();
}

#[test]
fn lots_and_lots_try_lock_immediate_park() {
tests::lots_and_lots_try_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_try_lock_yield_then_park() {
tests::lots_and_lots_try_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_try_lock::<ImmediateParkMutex<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_immediate_park() {
tests::lots_and_lots_mixed_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_yield_then_park() {
tests::lots_and_lots_mixed_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_mixed_lock::<ImmediateParkMutex<_>>();
}

#[test]
Expand Down
27 changes: 5 additions & 22 deletions src/parking/raw/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,11 @@ impl<T: ?Sized, P> crate::test::LockData for Mutex<T, P> {

#[cfg(all(not(loom), test))]
mod test {
use crate::parking::raw::{immediate, yields};
use crate::parking::raw::immediate;
use crate::test::tests;

type Mutex<T> = immediate::Mutex<T>;

type ImmediateMutex<T> = immediate::Mutex<T>;
type YieldThenParkMutex<T> = yields::Mutex<T>;
type ImmediateParkMutex<T> = immediate::Mutex<T>;

#[test]
fn node_waiter_drop_does_not_matter() {
Expand All @@ -557,32 +555,17 @@ mod test {

#[test]
fn lots_and_lots_lock_immediate_park() {
tests::lots_and_lots_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_lock_yield_then_park() {
tests::lots_and_lots_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_lock::<ImmediateParkMutex<_>>();
}

#[test]
fn lots_and_lots_try_lock_immediate_park() {
tests::lots_and_lots_try_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_try_lock_yield_then_park() {
tests::lots_and_lots_try_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_try_lock::<ImmediateParkMutex<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_immediate_park() {
tests::lots_and_lots_mixed_lock::<ImmediateMutex<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_yield_then_park() {
tests::lots_and_lots_mixed_lock::<YieldThenParkMutex<_>>();
tests::lots_and_lots_mixed_lock::<ImmediateParkMutex<_>>();
}

#[test]
Expand Down
53 changes: 10 additions & 43 deletions src/parking/raw/thread_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,18 +605,15 @@ impl<T: ?Sized, P: Park> TryLockThen for MutexUnchecked<T, P> {

#[cfg(all(not(loom), test))]
mod test {
use crate::parking::park::{ImmediatePark, YieldThenPark};
use crate::parking::park::ImmediatePark;
use crate::parking::raw::MutexNode;
use crate::test::tests;

type MutexPanic<T> = super::MutexPanic<T, ImmediatePark>;
type MutexUnchecked<T> = super::MutexUnchecked<T, ImmediatePark>;

type ImmediateMutexPanic<T> = super::MutexPanic<T, ImmediatePark>;
type YieldThenParkMutexPanic<T> = super::MutexPanic<T, YieldThenPark>;
type ImmediateParkMutexPanic<T> = super::MutexPanic<T, ImmediatePark>;

type ImmediateMutexUnchecked<T> = super::MutexUnchecked<T, ImmediatePark>;
type YieldThenParkMutexUnchecked<T> = super::MutexUnchecked<T, YieldThenPark>;
type MutexUnchecked<T> = super::MutexUnchecked<T, ImmediatePark>;
type ImmediateParkMutexUnchecked<T> = super::MutexUnchecked<T, ImmediatePark>;

#[test]
fn ref_cell_node_drop_does_not_matter() {
Expand All @@ -626,62 +623,32 @@ mod test {

#[test]
fn lots_and_lots_lock_immediate_park() {
tests::lots_and_lots_lock::<ImmediateMutexPanic<_>>();
}

#[test]
fn lots_and_lots_lock_yield_then_park() {
tests::lots_and_lots_lock::<YieldThenParkMutexPanic<_>>();
tests::lots_and_lots_lock::<ImmediateParkMutexPanic<_>>();
}

#[test]
fn lots_and_lots_lock_immediate_park_unchecked() {
tests::lots_and_lots_lock::<ImmediateMutexUnchecked<_>>();
}

#[test]
fn lots_and_lots_lock_yield_then_park_unchecked() {
tests::lots_and_lots_lock::<YieldThenParkMutexUnchecked<_>>();
tests::lots_and_lots_lock::<ImmediateParkMutexUnchecked<_>>();
}

#[test]
fn lots_and_lots_try_lock_immediate_park() {
tests::lots_and_lots_try_lock::<ImmediateMutexPanic<_>>();
tests::lots_and_lots_try_lock::<ImmediateParkMutexPanic<_>>();
}

#[test]
fn lots_and_lots_try_lock_immediate_park_unchecked() {
tests::lots_and_lots_try_lock::<ImmediateMutexUnchecked<_>>();
}

#[test]
fn lots_and_lots_try_lock_yield_then_park() {
tests::lots_and_lots_try_lock::<YieldThenParkMutexPanic<_>>();
}

#[test]
fn lots_and_lots_try_lock_yield_then_park_unchecked() {
tests::lots_and_lots_try_lock::<YieldThenParkMutexUnchecked<_>>();
tests::lots_and_lots_try_lock::<ImmediateParkMutexUnchecked<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_immediate_park() {
tests::lots_and_lots_mixed_lock::<ImmediateMutexPanic<_>>();
tests::lots_and_lots_mixed_lock::<ImmediateParkMutexPanic<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_immediate_park_unchecked() {
tests::lots_and_lots_mixed_lock::<ImmediateMutexUnchecked<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_yield_then_park() {
tests::lots_and_lots_mixed_lock::<YieldThenParkMutexPanic<_>>();
}

#[test]
fn lots_and_lots_mixed_lock_yield_then_park_unchecked() {
tests::lots_and_lots_mixed_lock::<YieldThenParkMutexUnchecked<_>>();
tests::lots_and_lots_mixed_lock::<ImmediateParkMutexUnchecked<_>>();
}

#[test]
Expand Down

0 comments on commit 333f505

Please sign in to comment.