Skip to content

Commit

Permalink
test: Add a test that repros servo/servo#13480
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Nov 10, 2017
1 parent b3dd16a commit c758d28
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,53 @@ fn cross_process_embedded_senders() {
assert_eq!(received_person, person);
}

#[cfg(not(any(feature = "force-inprocess", target_os = "windows", target_os = "android", target_os = "ios")))]
#[test]
fn stress_in_process() {
enum Message {
CloneApi(IpcSender<i32>),
}

impl Serialize for Message {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer {
match *self {
Message::CloneApi(ref s) => s.serialize(serializer),
}
}
}

impl<'de> Deserialize<'de> for Message {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de> {
Deserialize::deserialize(deserializer).map(Message::CloneApi)
}
}


let (api, rx) = ipc::channel::<Message>().unwrap();

{
::std::mem::forget(api.clone());
}

thread::spawn(move || {
loop {
match rx.recv().unwrap() {
Message::CloneApi(sender) => {
sender.send(0).unwrap();
}
}
}
});

for _ in 0..100000 {
let (one_shot_tx, one_shot_rx) = ipc::channel().unwrap();
api.send(Message::CloneApi(one_shot_tx)).unwrap();
let received = one_shot_rx.recv().unwrap();
assert_eq!(received, 0);
}
}


#[test]
fn router_simple() {
let person = ("Patrick Walton".to_owned(), 29);
Expand Down

0 comments on commit c758d28

Please sign in to comment.