diff options
author | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 09:41:24 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 09:41:24 -0800 |
commit | c32a5d1f19fe8652c01017f33ac8b0f20fec7c1d (patch) | |
tree | 909a6df94744a264ed8be858f2e9bd179d5ef6f9 /tests | |
parent | f41fd3efc0512c9e33e606afd14439c36bd6df60 (diff) | |
download | ssh2-rs-c32a5d1f19fe8652c01017f33ac8b0f20fec7c1d.zip |
Update to rust master
Diffstat (limited to 'tests')
-rw-r--r-- | tests/channel.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tests/channel.rs b/tests/channel.rs index c41cb70..420c5bd 100644 --- a/tests/channel.rs +++ b/tests/channel.rs @@ -1,4 +1,5 @@ use std::io::{TcpListener, Listener, Acceptor, TcpStream}; +use std::thread::Thread; #[test] fn smoke() { @@ -66,14 +67,12 @@ fn direct() { let mut l = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = l.socket_name().unwrap(); let mut a = l.listen().unwrap(); - let (tx, rx) = channel(); - spawn(move|| { + let t = Thread::spawn(move|| { let mut s = a.accept().unwrap(); let b = &mut [0, 0, 0]; s.read(b).unwrap(); assert_eq!(b.as_slice(), [1, 2, 3].as_slice()); s.write(&[4, 5, 6]).unwrap(); - tx.send(()); }); let (_tcp, sess) = ::authed_session(); let mut channel = sess.channel_direct_tcpip("127.0.0.1", @@ -82,7 +81,7 @@ fn direct() { let r = &mut [0, 0, 0]; channel.read(r).unwrap(); assert_eq!(r.as_slice(), [4, 5, 6].as_slice()); - rx.recv(); + t.join().ok().unwrap(); } #[test] @@ -90,14 +89,12 @@ fn forward() { let (_tcp, sess) = ::authed_session(); let (mut listen, port) = sess.channel_forward_listen(39249, None, None) .unwrap(); - let (tx, rx) = channel(); - spawn(move|| { + let t = Thread::spawn(move|| { let mut s = TcpStream::connect(("127.0.0.1", port)).unwrap(); let b = &mut [0, 0, 0]; s.read(b).unwrap(); assert_eq!(b.as_slice(), [1, 2, 3].as_slice()); s.write(&[4, 5, 6]).unwrap(); - tx.send(()); }); let mut channel = listen.accept().unwrap(); @@ -105,5 +102,5 @@ fn forward() { let r = &mut [0, 0, 0]; channel.read(r).unwrap(); assert_eq!(r.as_slice(), [4, 5, 6].as_slice()); - rx.recv(); + t.join().ok().unwrap(); } |