summaryrefslogtreecommitdiff
path: root/tests/evil_rwlock.rs
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2025-03-09 20:49:56 -0400
committerMica White <botahamec@outlook.com>2025-03-09 20:49:56 -0400
commit58abf5872023aca7ee6459fa3b2e067d57923ba5 (patch)
tree196cadda0dd4386668477ef286f9c9b09480e713 /tests/evil_rwlock.rs
parent4ba03be97e6cc7e790bbc9bfc18caaa228c8a262 (diff)
Finish testing and fixing
Diffstat (limited to 'tests/evil_rwlock.rs')
-rw-r--r--tests/evil_rwlock.rs18
1 files changed, 18 insertions, 0 deletions
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]