about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-12-28 10:36:54 -0800
committerbors <bors@rust-lang.org>2013-12-28 10:36:54 -0800
commit200c52a34e7673ab4186f86394c52874c98b4ffa (patch)
tree9a083f25aa13d80ac60e04cbdd76f90fc75ff97a /src/libstd
parent1b2cebc2c1f4d6e4bad36f4fa682f3d4e70cfb70 (diff)
parent2a4f9d69afd19603ed3354fa8e64ab0e67c6a915 (diff)
downloadrust-200c52a34e7673ab4186f86394c52874c98b4ffa.tar.gz
rust-200c52a34e7673ab4186f86394c52874c98b4ffa.zip
auto merge of #11159 : alexcrichton/rust/native-io, r=pcwalton
The old `rtio-processes` run-pass test is now moved into libstd's `io::process` module, and all process and TCP tests are now run with `iotest!` (both a native and a green version are tested).

All TCP networking on windows is provided by `ws2_32` which is apparently very similar to unix networking (hurray!).


Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/net/tcp.rs108
-rw-r--r--src/libstd/io/process.rs151
-rw-r--r--src/libstd/io/test.rs12
-rw-r--r--src/libstd/libc.rs308
-rw-r--r--src/libstd/run.rs2
5 files changed, 506 insertions, 75 deletions
diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs
index e7787692dd2..52cca7f622b 100644
--- a/src/libstd/io/net/tcp.rs
+++ b/src/libstd/io/net/tcp.rs
@@ -134,13 +134,11 @@ impl Acceptor<TcpStream> for TcpAcceptor {
 #[cfg(test)]
 mod test {
     use super::*;
-    use io::net::ip::{Ipv4Addr, SocketAddr};
+    use io::net::ip::SocketAddr;
     use io::*;
-    use io::test::{next_test_ip4, next_test_ip6};
     use prelude::*;
 
-    #[test] #[ignore]
-    fn bind_error() {
+    iotest!(fn bind_error() {
         let mut called = false;
         io_error::cond.trap(|e| {
             assert!(e.kind == PermissionDenied);
@@ -151,19 +149,12 @@ mod test {
             assert!(listener.is_none());
         });
         assert!(called);
-    }
+    } #[ignore(cfg(windows))])
 
-    #[test]
-    fn connect_error() {
+    iotest!(fn connect_error() {
         let mut called = false;
         io_error::cond.trap(|e| {
-            let expected_error = if cfg!(unix) {
-                ConnectionRefused
-            } else {
-                // On Win32, opening port 1 gives WSAEADDRNOTAVAIL error.
-                OtherIoError
-            };
-            assert_eq!(e.kind, expected_error);
+            assert_eq!(e.kind, ConnectionRefused);
             called = true;
         }).inside(|| {
             let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
@@ -171,10 +162,9 @@ mod test {
             assert!(stream.is_none());
         });
         assert!(called);
-    }
+    })
 
-    #[test]
-    fn smoke_test_ip4() {
+    iotest!(fn smoke_test_ip4() {
         let addr = next_test_ip4();
         let (port, chan) = Chan::new();
 
@@ -190,10 +180,9 @@ mod test {
         let mut buf = [0];
         stream.read(buf);
         assert!(buf[0] == 99);
-    }
+    })
 
-    #[test]
-    fn smoke_test_ip6() {
+    iotest!(fn smoke_test_ip6() {
         let addr = next_test_ip6();
         let (port, chan) = Chan::new();
 
@@ -209,10 +198,9 @@ mod test {
         let mut buf = [0];
         stream.read(buf);
         assert!(buf[0] == 99);
-    }
+    })
 
-    #[test]
-    fn read_eof_ip4() {
+    iotest!(fn read_eof_ip4() {
         let addr = next_test_ip4();
         let (port, chan) = Chan::new();
 
@@ -228,10 +216,9 @@ mod test {
         let mut buf = [0];
         let nread = stream.read(buf);
         assert!(nread.is_none());
-    }
+    })
 
-    #[test]
-    fn read_eof_ip6() {
+    iotest!(fn read_eof_ip6() {
         let addr = next_test_ip6();
         let (port, chan) = Chan::new();
 
@@ -247,10 +234,9 @@ mod test {
         let mut buf = [0];
         let nread = stream.read(buf);
         assert!(nread.is_none());
-    }
+    })
 
-    #[test]
-    fn read_eof_twice_ip4() {
+    iotest!(fn read_eof_twice_ip4() {
         let addr = next_test_ip4();
         let (port, chan) = Chan::new();
 
@@ -276,10 +262,9 @@ mod test {
             let nread = stream.read(buf);
             assert!(nread.is_none());
         })
-    }
+    })
 
-    #[test]
-    fn read_eof_twice_ip6() {
+    iotest!(fn read_eof_twice_ip6() {
         let addr = next_test_ip6();
         let (port, chan) = Chan::new();
 
@@ -305,10 +290,9 @@ mod test {
             let nread = stream.read(buf);
             assert!(nread.is_none());
         })
-    }
+    })
 
-    #[test]
-    fn write_close_ip4() {
+    iotest!(fn write_close_ip4() {
         let addr = next_test_ip4();
         let (port, chan) = Chan::new();
 
@@ -337,10 +321,9 @@ mod test {
             });
             if stop { break }
         }
-    }
+    })
 
-    #[test]
-    fn write_close_ip6() {
+    iotest!(fn write_close_ip6() {
         let addr = next_test_ip6();
         let (port, chan) = Chan::new();
 
@@ -369,10 +352,9 @@ mod test {
             });
             if stop { break }
         }
-    }
+    })
 
-    #[test]
-    fn multiple_connect_serial_ip4() {
+    iotest!(fn multiple_connect_serial_ip4() {
         let addr = next_test_ip4();
         let max = 10;
         let (port, chan) = Chan::new();
@@ -392,10 +374,9 @@ mod test {
             stream.read(buf);
             assert_eq!(buf[0], 99);
         }
-    }
+    })
 
-    #[test]
-    fn multiple_connect_serial_ip6() {
+    iotest!(fn multiple_connect_serial_ip6() {
         let addr = next_test_ip6();
         let max = 10;
         let (port, chan) = Chan::new();
@@ -415,10 +396,9 @@ mod test {
             stream.read(buf);
             assert_eq!(buf[0], 99);
         }
-    }
+    })
 
-    #[test]
-    fn multiple_connect_interleaved_greedy_schedule_ip4() {
+    iotest!(fn multiple_connect_interleaved_greedy_schedule_ip4() {
         let addr = next_test_ip4();
         static MAX: int = 10;
         let (port, chan) = Chan::new();
@@ -453,10 +433,9 @@ mod test {
                 stream.write([i as u8]);
             }
         }
-    }
+    })
 
-    #[test]
-    fn multiple_connect_interleaved_greedy_schedule_ip6() {
+    iotest!(fn multiple_connect_interleaved_greedy_schedule_ip6() {
         let addr = next_test_ip6();
         static MAX: int = 10;
         let (port, chan) = Chan::<()>::new();
@@ -491,10 +470,9 @@ mod test {
                 stream.write([i as u8]);
             }
         }
-    }
+    })
 
-    #[test]
-    fn multiple_connect_interleaved_lazy_schedule_ip4() {
+    iotest!(fn multiple_connect_interleaved_lazy_schedule_ip4() {
         let addr = next_test_ip4();
         static MAX: int = 10;
         let (port, chan) = Chan::new();
@@ -529,9 +507,9 @@ mod test {
                 stream.write([99]);
             }
         }
-    }
-    #[test]
-    fn multiple_connect_interleaved_lazy_schedule_ip6() {
+    })
+
+    iotest!(fn multiple_connect_interleaved_lazy_schedule_ip6() {
         let addr = next_test_ip6();
         static MAX: int = 10;
         let (port, chan) = Chan::new();
@@ -566,10 +544,9 @@ mod test {
                 stream.write([99]);
             }
         }
-    }
+    })
 
-    #[cfg(test)]
-    fn socket_name(addr: SocketAddr) {
+    pub fn socket_name(addr: SocketAddr) {
         let mut listener = TcpListener::bind(addr).unwrap();
 
         // Make sure socket_name gives
@@ -579,8 +556,7 @@ mod test {
         assert_eq!(addr, so_name.unwrap());
     }
 
-    #[cfg(test)]
-    fn peer_name(addr: SocketAddr) {
+    pub fn peer_name(addr: SocketAddr) {
         let (port, chan) = Chan::new();
 
         do spawn {
@@ -603,16 +579,14 @@ mod test {
         assert_eq!(addr, peer_name.unwrap());
     }
 
-    #[test]
-    fn socket_and_peer_name_ip4() {
+    iotest!(fn socket_and_peer_name_ip4() {
         peer_name(next_test_ip4());
         socket_name(next_test_ip4());
-    }
+    })
 
-    #[test]
-    fn socket_and_peer_name_ip6() {
+    iotest!(fn socket_and_peer_name_ip6() {
         // XXX: peer name is not consistent
         //peer_name(next_test_ip6());
         socket_name(next_test_ip6());
-    }
+    })
 }
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index bbb2a7ef398..a8b7e8e00ea 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -169,5 +169,152 @@ impl Drop for Process {
     }
 }
 
-// Tests for this module can be found in the rtio-processes run-pass test, along
-// with the justification for why it's not located here.
+#[cfg(test)]
+mod tests {
+    use io::process::{ProcessConfig, Process};
+    use prelude::*;
+    use str;
+
+    // FIXME(#10380)
+    #[cfg(unix, not(target_os="android"))]
+    iotest!(fn smoke() {
+        let io = ~[];
+        let args = ProcessConfig {
+            program: "/bin/sh",
+            args: [~"-c", ~"true"],
+            env: None,
+            cwd: None,
+            io: io,
+        };
+        let p = Process::new(args);
+        assert!(p.is_some());
+        let mut p = p.unwrap();
+        assert!(p.wait().success());
+    })
+
+    // FIXME(#10380)
+    #[cfg(unix, not(target_os="android"))]
+    iotest!(fn smoke_failure() {
+        let io = ~[];
+        let args = ProcessConfig {
+            program: "if-this-is-a-binary-then-the-world-has-ended",
+            args: [],
+            env: None,
+            cwd: None,
+            io: io,
+        };
+        match io::result(|| Process::new(args)) {
+            Ok(..) => fail!(),
+            Err(..) => {}
+        }
+    })
+
+    // FIXME(#10380)
+    #[cfg(unix, not(target_os="android"))]
+    iotest!(fn exit_reported_right() {
+        let io = ~[];
+        let args = ProcessConfig {
+            program: "/bin/sh",
+            args: [~"-c", ~"exit 1"],
+            env: None,
+            cwd: None,
+            io: io,
+        };
+        let p = Process::new(args);
+        assert!(p.is_some());
+        let mut p = p.unwrap();
+        assert!(p.wait().matches_exit_status(1));
+    })
+
+    #[cfg(unix, not(target_os="android"))]
+    iotest!(fn signal_reported_right() {
+        let io = ~[];
+        let args = ProcessConfig {
+            program: "/bin/sh",
+            args: [~"-c", ~"kill -1 $$"],
+            env: None,
+            cwd: None,
+            io: io,
+        };
+        let p = Process::new(args);
+        assert!(p.is_some());
+        let mut p = p.unwrap();
+        match p.wait() {
+            process::ExitSignal(1) => {},
+            result => fail!("not terminated by signal 1 (instead, {})", result),
+        }
+    })
+
+    pub fn read_all(input: &mut Reader) -> ~str {
+        let mut ret = ~"";
+        let mut buf = [0, ..1024];
+        loop {
+            match input.read(buf) {
+                None => { break }
+                Some(n) => { ret.push_str(str::from_utf8(buf.slice_to(n))); }
+            }
+        }
+        return ret;
+    }
+
+    pub fn run_output(args: ProcessConfig) -> ~str {
+        let p = Process::new(args);
+        assert!(p.is_some());
+        let mut p = p.unwrap();
+        assert!(p.io[0].is_none());
+        assert!(p.io[1].is_some());
+        let ret = read_all(p.io[1].get_mut_ref() as &mut Reader);
+        assert!(p.wait().success());
+        return ret;
+    }
+
+    // FIXME(#10380)
+    #[cfg(unix, not(target_os="android"))]
+    iotest!(fn stdout_works() {
+        let io = ~[Ignored, CreatePipe(false, true)];
+        let args = ProcessConfig {
+            program: "/bin/sh",
+            args: [~"-c", ~"echo foobar"],
+            env: None,
+            cwd: None,
+            io: io,
+        };
+        assert_eq!(run_output(args), ~"foobar\n");
+    })
+
+    // FIXME(#10380)
+    #[cfg(unix, not(target_os="android"))]
+    iotest!(fn set_cwd_works() {
+        let io = ~[Ignored, CreatePipe(false, true)];
+        let cwd = Some("/");
+        let args = ProcessConfig {
+            program: "/bin/sh",
+            args: [~"-c", ~"pwd"],
+            env: None,
+            cwd: cwd,
+            io: io,
+        };
+        assert_eq!(run_output(args), ~"/\n");
+    })
+
+    // FIXME(#10380)
+    #[cfg(unix, not(target_os="android"))]
+    iotest!(fn stdin_works() {
+        let io = ~[CreatePipe(true, false),
+                   CreatePipe(false, true)];
+        let args = ProcessConfig {
+            program: "/bin/sh",
+            args: [~"-c", ~"read line; echo $line"],
+            env: None,
+            cwd: None,
+            io: io,
+        };
+        let mut p = Process::new(args).expect("didn't create a proces?!");
+        p.io[0].get_mut_ref().write("foobar".as_bytes());
+        p.io[0] = None; // close stdin;
+        let out = read_all(p.io[1].get_mut_ref() as &mut Reader);
+        assert!(p.wait().success());
+        assert_eq!(out, ~"foobar\n");
+    })
+
+}
diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs
index 4be11227965..92b2cfa8be2 100644
--- a/src/libstd/io/test.rs
+++ b/src/libstd/io/test.rs
@@ -18,7 +18,7 @@ use std::io::net::ip::*;
 use sync::atomics::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
 
 macro_rules! iotest (
-    { fn $name:ident() $b:block } => (
+    { fn $name:ident() $b:block $($a:attr)* } => (
         mod $name {
             #[allow(unused_imports)];
 
@@ -28,18 +28,20 @@ macro_rules! iotest (
             use prelude::*;
             use io::*;
             use io::fs::*;
+            use io::test::*;
             use io::net::tcp::*;
             use io::net::ip::*;
             use io::net::udp::*;
             #[cfg(unix)]
             use io::net::unix::*;
+            use io::process::*;
             use str;
             use util;
 
             fn f() $b
 
-            #[test] fn green() { f() }
-            #[test] fn native() {
+            $($a)* #[test] fn green() { f() }
+            $($a)* #[test] fn native() {
                 use native;
                 let (p, c) = Chan::new();
                 do native::task::spawn { c.send(f()) }
@@ -90,9 +92,9 @@ fn base_port() -> u16 {
 
     let bases = [
         ("32-opt", base + range * 1),
-        ("32-noopt", base + range * 2),
+        ("32-nopt", base + range * 2),
         ("64-opt", base + range * 3),
-        ("64-noopt", base + range * 4),
+        ("64-nopt", base + range * 4),
         ("64-opt-vg", base + range * 5),
         ("all-opt", base + range * 6),
         ("snap3", base + range * 7),
diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs
index 556009c2838..2696e27c373 100644
--- a/src/libstd/libc.rs
+++ b/src/libstd/libc.rs
@@ -76,6 +76,7 @@ pub use libc::types::common::posix01::*;
 pub use libc::types::common::posix08::*;
 pub use libc::types::common::bsd44::*;
 pub use libc::types::os::common::posix01::*;
+pub use libc::types::os::common::bsd44::*;
 pub use libc::types::os::arch::c95::*;
 pub use libc::types::os::arch::c99::*;
 pub use libc::types::os::arch::posix88::*;
@@ -111,6 +112,7 @@ pub use libc::funcs::posix01::glob::*;
 pub use libc::funcs::posix01::mman::*;
 pub use libc::funcs::posix08::unistd::*;
 
+pub use libc::funcs::bsd43::*;
 pub use libc::funcs::bsd44::*;
 pub use libc::funcs::extra::*;
 
@@ -240,6 +242,40 @@ pub mod types {
                     __unused5: *c_void,
                 }
             }
+            pub mod bsd44 {
+                pub type socklen_t = u32;
+                pub type sa_family_t = u16;
+                pub type in_port_t = u16;
+                pub type in_addr_t = u32;
+                pub struct sockaddr {
+                    sa_family: sa_family_t,
+                    sa_data: [u8, ..14],
+                }
+                pub struct sockaddr_storage {
+                    ss_family: sa_family_t,
+                    __ss_align: i64,
+                    __ss_pad2: [u8, ..112],
+                }
+                pub struct sockaddr_in {
+                    sin_family: sa_family_t,
+                    sin_port: in_port_t,
+                    sin_addr: in_addr,
+                    sin_zero: [u8, ..8],
+                }
+                pub struct in_addr {
+                    s_addr: in_addr_t,
+                }
+                pub struct sockaddr_in6 {
+                    sin6_family: sa_family_t,
+                    sin6_port: in_port_t,
+                    sin6_flowinfo: u32,
+                    sin6_addr: in6_addr,
+                    sin6_scope_id: u32,
+                }
+                pub struct in6_addr {
+                    s6_addr: [u16, ..8]
+                }
+            }
         }
 
         #[cfg(target_arch = "x86")]
@@ -538,6 +574,45 @@ pub mod types {
                     __unused8: *c_void,
                 }
             }
+            pub mod bsd44 {
+                pub type socklen_t = u32;
+                pub type sa_family_t = u8;
+                pub type in_port_t = u16;
+                pub type in_addr_t = u32;
+                pub struct sockaddr {
+                    sa_len: u8,
+                    sa_family: sa_family_t,
+                    sa_data: [u8, ..14],
+                }
+                pub struct sockaddr_storage {
+                    ss_len: u8,
+                    ss_family: sa_family_t,
+                    __ss_pad1: [u8, ..6],
+                    __ss_align: i64,
+                    __ss_pad2: [u8, ..112],
+                }
+                pub struct sockaddr_in {
+                    sin_len: u8,
+                    sin_family: sa_family_t,
+                    sin_port: in_port_t,
+                    sin_addr: in_addr,
+                    sin_zero: [u8, ..8],
+                }
+                pub struct in_addr {
+                    s_addr: in_addr_t,
+                }
+                pub struct sockaddr_in6 {
+                    sin6_len: u8,
+                    sin6_family: sa_family_t,
+                    sin6_port: in_port_t,
+                    sin6_flowinfo: u32,
+                    sin6_addr: in6_addr,
+                    sin6_scope_id: u32,
+                }
+                pub struct in6_addr {
+                    s6_addr: [u16, ..8]
+                }
+            }
         }
 
         #[cfg(target_arch = "x86_64")]
@@ -661,6 +736,44 @@ pub mod types {
                     modtime: time64_t,
                 }
             }
+
+            pub mod bsd44 {
+                use libc::types::os::arch::c95::{c_int, c_uint};
+
+                pub type SOCKET = c_uint;
+                pub type socklen_t = c_int;
+                pub type sa_family_t = u16;
+                pub type in_port_t = u16;
+                pub type in_addr_t = u32;
+                pub struct sockaddr {
+                    sa_family: sa_family_t,
+                    sa_data: [u8, ..14],
+                }
+                pub struct sockaddr_storage {
+                    ss_family: sa_family_t,
+                    __ss_align: i64,
+                    __ss_pad2: [u8, ..112],
+                }
+                pub struct sockaddr_in {
+                    sin_family: sa_family_t,
+                    sin_port: in_port_t,
+                    sin_addr: in_addr,
+                    sin_zero: [u8, ..8],
+                }
+                pub struct in_addr {
+                    s_addr: in_addr_t,
+                }
+                pub struct sockaddr_in6 {
+                    sin6_family: sa_family_t,
+                    sin6_port: in_port_t,
+                    sin6_flowinfo: u32,
+                    sin6_addr: in6_addr,
+                    sin6_scope_id: u32,
+                }
+                pub struct in6_addr {
+                    s6_addr: [u16, ..8]
+                }
+            }
         }
 
         pub mod arch {
@@ -900,6 +1013,48 @@ pub mod types {
                     __unused8: *c_void,
                 }
             }
+
+            pub mod bsd44 {
+                use libc::types::os::arch::c95::c_int;
+
+                pub type socklen_t = c_int;
+                pub type sa_family_t = u8;
+                pub type in_port_t = u16;
+                pub type in_addr_t = u32;
+                pub struct sockaddr {
+                    sa_len: u8,
+                    sa_family: sa_family_t,
+                    sa_data: [u8, ..14],
+                }
+                pub struct sockaddr_storage {
+                    ss_len: u8,
+                    ss_family: sa_family_t,
+                    __ss_pad1: [u8, ..6],
+                    __ss_align: i64,
+                    __ss_pad2: [u8, ..112],
+                }
+                pub struct sockaddr_in {
+                    sin_len: u8,
+                    sin_family: sa_family_t,
+                    sin_port: in_port_t,
+                    sin_addr: in_addr,
+                    sin_zero: [u8, ..8],
+                }
+                pub struct in_addr {
+                    s_addr: in_addr_t,
+                }
+                pub struct sockaddr_in6 {
+                    sin6_len: u8,
+                    sin6_family: sa_family_t,
+                    sin6_port: in_port_t,
+                    sin6_flowinfo: u32,
+                    sin6_addr: in6_addr,
+                    sin6_scope_id: u32,
+                }
+                pub struct in6_addr {
+                    s6_addr: [u16, ..8]
+                }
+            }
         }
 
         #[cfg(target_arch = "x86")]
@@ -1109,6 +1264,59 @@ pub mod consts {
             pub static FILENAME_MAX : c_uint = 260_u32;
             pub static L_tmpnam : c_uint = 16_u32;
             pub static TMP_MAX : c_uint = 32767_u32;
+
+            pub static WSAEINTR: c_int = 10004;
+            pub static WSAEBADF: c_int = 10009;
+            pub static WSAEACCES: c_int = 10013;
+            pub static WSAEFAULT: c_int = 10014;
+            pub static WSAEINVAL: c_int = 10022;
+            pub static WSAEMFILE: c_int = 10024;
+            pub static WSAEWOULDBLOCK: c_int = 10035;
+            pub static WSAEINPROGRESS: c_int = 10036;
+            pub static WSAEALREADY: c_int = 10037;
+            pub static WSAENOTSOCK: c_int = 10038;
+            pub static WSAEDESTADDRREQ: c_int = 10039;
+            pub static WSAEMSGSIZE: c_int = 10040;
+            pub static WSAEPROTOTYPE: c_int = 10041;
+            pub static WSAENOPROTOOPT: c_int = 10042;
+            pub static WSAEPROTONOSUPPORT: c_int = 10043;
+            pub static WSAESOCKTNOSUPPORT: c_int = 10044;
+            pub static WSAEOPNOTSUPP: c_int = 10045;
+            pub static WSAEPFNOSUPPORT: c_int = 10046;
+            pub static WSAEAFNOSUPPORT: c_int = 10047;
+            pub static WSAEADDRINUSE: c_int = 10048;
+            pub static WSAEADDRNOTAVAIL: c_int = 10049;
+            pub static WSAENETDOWN: c_int = 10050;
+            pub static WSAENETUNREACH: c_int = 10051;
+            pub static WSAENETRESET: c_int = 10052;
+            pub static WSAECONNABORTED: c_int = 10053;
+            pub static WSAECONNRESET: c_int = 10054;
+            pub static WSAENOBUFS: c_int = 10055;
+            pub static WSAEISCONN: c_int = 10056;
+            pub static WSAENOTCONN: c_int = 10057;
+            pub static WSAESHUTDOWN: c_int = 10058;
+            pub static WSAETOOMANYREFS: c_int = 10059;
+            pub static WSAETIMEDOUT: c_int = 10060;
+            pub static WSAECONNREFUSED: c_int = 10061;
+            pub static WSAELOOP: c_int = 10062;
+            pub static WSAENAMETOOLONG: c_int = 10063;
+            pub static WSAEHOSTDOWN: c_int = 10064;
+            pub static WSAEHOSTUNREACH: c_int = 10065;
+            pub static WSAENOTEMPTY: c_int = 10066;
+            pub static WSAEPROCLIM: c_int = 10067;
+            pub static WSAEUSERS: c_int = 10068;
+            pub static WSAEDQUOT: c_int = 10069;
+            pub static WSAESTALE: c_int = 10070;
+            pub static WSAEREMOTE: c_int = 10071;
+            pub static WSASYSNOTREADY: c_int = 10091;
+            pub static WSAVERNOTSUPPORTED: c_int = 10092;
+            pub static WSANOTINITIALISED: c_int = 10093;
+            pub static WSAEDISCON: c_int = 10101;
+            pub static WSAENOMORE: c_int = 10102;
+            pub static WSAECANCELLED: c_int = 10103;
+            pub static WSAEINVALIDPROCTABLE: c_int = 10104;
+            pub static WSAEINVALIDPROVIDER: c_int = 10105;
+            pub static WSAEPROVIDERFAILEDINIT: c_int = 10106;
         }
         pub mod c99 {
         }
@@ -1149,6 +1357,17 @@ pub mod consts {
         pub mod posix08 {
         }
         pub mod bsd44 {
+            use libc::types::os::arch::c95::c_int;
+
+            pub static AF_INET: c_int = 2;
+            pub static AF_INET6: c_int = 23;
+            pub static SOCK_STREAM: c_int = 1;
+            pub static SOCK_DGRAM: c_int = 2;
+            pub static IPPROTO_TCP: c_int = 6;
+
+            pub static TCP_NODELAY: c_int = 0x0001;
+            pub static SOL_SOCKET: c_int = 0xffff;
+            pub static SO_KEEPALIVE: c_int = 8;
         }
         pub mod extra {
             use libc::types::os::arch::c95::c_int;
@@ -1845,6 +2064,16 @@ pub mod consts {
             pub static MADV_MERGEABLE : c_int = 12;
             pub static MADV_UNMERGEABLE : c_int = 13;
             pub static MADV_HWPOISON : c_int = 100;
+
+            pub static AF_INET: c_int = 2;
+            pub static AF_INET6: c_int = 10;
+            pub static SOCK_STREAM: c_int = 1;
+            pub static SOCK_DGRAM: c_int = 2;
+            pub static IPPROTO_TCP: c_int = 6;
+
+            pub static TCP_NODELAY: c_int = 1;
+            pub static SOL_SOCKET: c_int = 1;
+            pub static SO_KEEPALIVE: c_int = 9;
         }
         #[cfg(target_arch = "x86")]
         #[cfg(target_arch = "x86_64")]
@@ -2262,6 +2491,17 @@ pub mod consts {
             pub static MINCORE_REFERENCED_OTHER : c_int = 0x8;
             pub static MINCORE_MODIFIED_OTHER : c_int = 0x10;
             pub static MINCORE_SUPER : c_int = 0x20;
+
+            pub static AF_INET: c_int = 2;
+            pub static AF_INET6: c_int = 28;
+            pub static SOCK_STREAM: c_int = 1;
+            pub static SOCK_DGRAM: c_int = 2;
+            pub static IPPROTO_TCP: c_int = 6;
+
+            pub static TCP_NODELAY: c_int = 1;
+            pub static TCP_KEEPIDLE: c_int = 256;
+            pub static SOL_SOCKET: c_int = 0xffff;
+            pub static SO_KEEPALIVE: c_int = 0x0008;
         }
         pub mod extra {
             use libc::types::os::arch::c95::c_int;
@@ -2616,6 +2856,17 @@ pub mod consts {
             pub static MINCORE_MODIFIED : c_int = 0x4;
             pub static MINCORE_REFERENCED_OTHER : c_int = 0x8;
             pub static MINCORE_MODIFIED_OTHER : c_int = 0x10;
+
+            pub static AF_INET: c_int = 2;
+            pub static AF_INET6: c_int = 30;
+            pub static SOCK_STREAM: c_int = 1;
+            pub static SOCK_DGRAM: c_int = 2;
+            pub static IPPROTO_TCP: c_int = 6;
+
+            pub static TCP_NODELAY: c_int = 0x01;
+            pub static TCP_KEEPALIVE: c_int = 0x10;
+            pub static SOL_SOCKET: c_int = 0xffff;
+            pub static SO_KEEPALIVE: c_int = 0x0008;
         }
         pub mod extra {
             use libc::types::os::arch::c95::c_int;
@@ -3296,6 +3547,63 @@ pub mod funcs {
         }
     }
 
+    #[cfg(not(windows))]
+    pub mod bsd43 {
+        use libc::types::common::c95::{c_void};
+        use libc::types::os::common::bsd44::{socklen_t, sockaddr};
+        use libc::types::os::arch::c95::{c_int, size_t};
+        use libc::types::os::arch::posix88::ssize_t;
+
+        extern "system" {
+            pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
+            pub fn connect(socket: c_int, address: *sockaddr,
+                           len: socklen_t) -> c_int;
+            pub fn bind(socket: c_int, address: *sockaddr,
+                        address_len: socklen_t) -> c_int;
+            pub fn listen(socket: c_int, backlog: c_int) -> c_int;
+            pub fn accept(socket: c_int, address: *mut sockaddr,
+                          address_len: *mut socklen_t) -> c_int;
+            pub fn getpeername(socket: c_int, address: *mut sockaddr,
+                               address_len: *mut socklen_t) -> c_int;
+            pub fn getsockname(socket: c_int, address: *mut sockaddr,
+                               address_len: *mut socklen_t) -> c_int;
+            pub fn setsockopt(socket: c_int, level: c_int, name: c_int,
+                              value: *c_void, option_len: socklen_t) -> c_int;
+            pub fn recv(socket: c_int, buf: *mut c_void, len: size_t,
+                        flags: c_int) -> ssize_t;
+            pub fn send(socket: c_int, buf: *mut c_void, len: size_t,
+                        flags: c_int) -> ssize_t;
+        }
+    }
+
+    #[cfg(windows)]
+    pub mod bsd43 {
+        use libc::types::common::c95::{c_void};
+        use libc::types::os::common::bsd44::{socklen_t, sockaddr, SOCKET};
+        use libc::types::os::arch::c95::c_int;
+
+        extern "system" {
+            pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET;
+            pub fn connect(socket: SOCKET, address: *sockaddr,
+                           len: socklen_t) -> c_int;
+            pub fn bind(socket: SOCKET, address: *sockaddr,
+                        address_len: socklen_t) -> c_int;
+            pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
+            pub fn accept(socket: SOCKET, address: *mut sockaddr,
+                          address_len: *mut socklen_t) -> SOCKET;
+            pub fn getpeername(socket: SOCKET, address: *mut sockaddr,
+                               address_len: *mut socklen_t) -> c_int;
+            pub fn getsockname(socket: SOCKET, address: *mut sockaddr,
+                               address_len: *mut socklen_t) -> c_int;
+            pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int,
+                              value: *c_void, option_len: socklen_t) -> c_int;
+            pub fn closesocket(socket: SOCKET) -> c_int;
+            pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
+                        flags: c_int) -> c_int;
+            pub fn send(socket: SOCKET, buf: *mut c_void, len: c_int,
+                        flags: c_int) -> c_int;
+        }
+    }
 
     #[cfg(target_os = "macos")]
     #[cfg(target_os = "freebsd")]
diff --git a/src/libstd/run.rs b/src/libstd/run.rs
index 69704c855ee..33be746e604 100644
--- a/src/libstd/run.rs
+++ b/src/libstd/run.rs
@@ -339,7 +339,7 @@ mod tests {
     use task::spawn;
     use unstable::running_on_valgrind;
     use io::pipe::PipeStream;
-    use io::{Writer, Reader, io_error, FileNotFound, OtherIoError};
+    use io::{Writer, Reader, io_error, FileNotFound};
 
     #[test]
     #[cfg(not(target_os="android"))] // FIXME(#10380)