Skip to content

Instantly share code, notes, and snippets.

@haxpor
Last active May 1, 2022
Embed
What would you like to do?
attempt to bypass poisoned mutex (not work yet)
macro_rules! serial_test {
(fn $name: ident() $body: block) => {
#[test]
fn $name() {
let guard = LOCK.try_lock();
if let Ok(mutex) = guard {
$body
}
else {
let err = guard.unwrap_err();
if let std::sync::TryLockError::Poisoned(p) = err {
let _guard = p.get_ref(); // not hit this at all
$body
}
else {
panic!("Error cannot acquire lock"); // always hit this
}
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment