Touch up net tests
This commit is contained in:
@@ -373,28 +373,16 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn connect_ip4_loopback() {
|
fn connect_loopback() {
|
||||||
let addr = next_test_ip4();
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
|
|
||||||
let _t = thread::spawn(move|| {
|
let _t = thread::spawn(move|| {
|
||||||
let mut stream = t!(TcpStream::connect(&("127.0.0.1", addr.port())));
|
let host = match addr {
|
||||||
t!(stream.write(&[44]));
|
SocketAddr::V4(..) => "127.0.0.1",
|
||||||
});
|
SocketAddr::V6(..) => "::1",
|
||||||
|
};
|
||||||
let mut stream = t!(acceptor.accept()).0;
|
let mut stream = t!(TcpStream::connect(&(host, addr.port())));
|
||||||
let mut buf = [0];
|
|
||||||
t!(stream.read(&mut buf));
|
|
||||||
assert!(buf[0] == 44);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn connect_ip6_loopback() {
|
|
||||||
let addr = next_test_ip6();
|
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
|
||||||
|
|
||||||
let _t = thread::spawn(move|| {
|
|
||||||
let mut stream = t!(TcpStream::connect(&("::1", addr.port())));
|
|
||||||
t!(stream.write(&[66]));
|
t!(stream.write(&[66]));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -402,10 +390,11 @@ mod tests {
|
|||||||
let mut buf = [0];
|
let mut buf = [0];
|
||||||
t!(stream.read(&mut buf));
|
t!(stream.read(&mut buf));
|
||||||
assert!(buf[0] == 66);
|
assert!(buf[0] == 66);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke_test_ip6() {
|
fn smoke_test() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
|
|
||||||
@@ -425,7 +414,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read_eof_ip4() {
|
fn read_eof() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
|
|
||||||
@@ -470,7 +459,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiple_connect_serial_ip4() {
|
fn multiple_connect_serial() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let max = 10;
|
let max = 10;
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@@ -527,7 +516,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiple_connect_interleaved_lazy_schedule_ip4() {
|
fn multiple_connect_interleaved_lazy_schedule() {
|
||||||
const MAX: usize = 10;
|
const MAX: usize = 10;
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@@ -560,7 +549,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn socket_and_peer_name_ip4() {
|
fn socket_and_peer_name() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let listener = t!(TcpListener::bind(&addr));
|
let listener = t!(TcpListener::bind(&addr));
|
||||||
let so_name = t!(listener.local_addr());
|
let so_name = t!(listener.local_addr());
|
||||||
|
|||||||
Reference in New Issue
Block a user