Skip to content

Commit

Permalink
Added unit test for select::remove / select::next() race
Browse files Browse the repository at this point in the history
  • Loading branch information
csherratt committed Nov 10, 2015
1 parent deb21cf commit 5ba0f15
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,25 @@ fn select_already_pulsed() {
assert_eq!(id0, p.id());
let p = select.next();
assert!(p.is_none());
}
}

#[test]
fn select_remove() {
let (p0, t0) = Signal::new();
let (p1, t1) = Signal::new();

let mut select = Select::new();
let id0 = select.add(p0);
let id1 = select.add(p1);

thread::spawn(move || {
// This should only matter if the bug still exists
// this thread will otherwise unblock the select
thread::sleep_ms(100);
t1.pulse();
});

t0.pulse();
select.remove(id0).unwrap();
assert_eq!(id1, select.next().unwrap().id());
}

0 comments on commit 5ba0f15

Please sign in to comment.