Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for two Miri issues with unit tests #252

Merged
merged 3 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
- wasm32-unknown-unknown
- x86_64-fortanix-unknown-sgx
#- x86_64-unknown-redox
- x86_64-unknown-cloudabi
#- x86_64-linux-android
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions src/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ mod tests {
while !c.notify_one() {
// Wait for the thread to get into wait()
MutexGuard::bump(&mut g);
// Yield, so the other thread gets a chance to do something.
// (At least Miri needs this, because it doesn't preempt threads.)
thread::yield_now();
}
// The thread should have been requeued to the mutex, which we wake up now.
drop(g);
Expand Down
11 changes: 8 additions & 3 deletions src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ mod tests {
fn test_rwlock_recursive() {
let arc = Arc::new(RwLock::new(1));
let arc2 = arc.clone();
let _lock1 = arc.read();
thread::spawn(move || {
let lock1 = arc.read();
let t = thread::spawn(move || {
let _lock = arc2.write();
});

Expand All @@ -554,7 +554,12 @@ mod tests {
}

// A normal read would block here since there is a pending writer
let _lock2 = arc.read_recursive();
let lock2 = arc.read_recursive();

// Unblock the thread and join it.
drop(lock1);
drop(lock2);
t.join().unwrap();
}

#[test]
Expand Down