From 58abf5872023aca7ee6459fa3b2e067d57923ba5 Mon Sep 17 00:00:00 2001 From: Mica White Date: Sun, 9 Mar 2025 20:49:56 -0400 Subject: Finish testing and fixing --- tests/evil_rwlock.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/evil_rwlock.rs') diff --git a/tests/evil_rwlock.rs b/tests/evil_rwlock.rs index 9eed8a8..4be86a1 100644 --- a/tests/evil_rwlock.rs +++ b/tests/evil_rwlock.rs @@ -1,3 +1,4 @@ +use std::panic::AssertUnwindSafe; use std::sync::Arc; use happylock::collection::{BoxedLockCollection, RetryingLockCollection}; @@ -63,6 +64,23 @@ fn boxed_rwlocks() { assert!(good_mutex.scoped_try_write(&mut key, |_| {}).is_ok()); assert!(evil_mutex.scoped_try_write(&mut key, |_| {}).is_err()); assert!(useless_mutex.scoped_try_write(&mut key, |_| {}).is_ok()); + + std::thread::scope(|s| { + s.spawn(|| { + let evil_mutex = AssertUnwindSafe(evil_mutex); + let r = std::panic::catch_unwind(|| { + let key = ThreadKey::get().unwrap(); + evil_mutex.write(key); + }); + + assert!(r.is_err()); + }); + + s.spawn(|| { + let key = ThreadKey::get().unwrap(); + good_mutex.write(key); + }); + }); } #[test] -- cgit v1.2.3