]> git.lizzy.rs Git - rust.git/commitdiff
libstd: Use iotest! for for get_host_addresses.
authorLuqman Aden <laden@csclub.uwaterloo.ca>
Wed, 22 Jan 2014 21:05:28 +0000 (16:05 -0500)
committerLuqman Aden <laden@csclub.uwaterloo.ca>
Fri, 24 Jan 2014 21:44:16 +0000 (16:44 -0500)
src/librustuv/addrinfo.rs
src/libstd/io/net/addrinfo.rs

index 2fe4819c789c7ba76ccacbe26eaa70f1a2838b13..2740671c00d60489abb90b402fce4ddafa5ea4f8 100644 (file)
@@ -183,39 +183,3 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> ~[ai::Info] {
         return addrs;
     }
 }
-
-// cannot give tcp/ip permission without help of apk
-#[cfg(test, not(target_os="android"))]
-mod test {
-    use std::io::net::ip::{SocketAddr, Ipv4Addr};
-    use super::super::local_loop;
-    use super::GetAddrInfoRequest;
-
-    #[test]
-    fn getaddrinfo_test() {
-        let loop_ = &mut local_loop().loop_;
-        match GetAddrInfoRequest::run(loop_, Some("localhost"), None, None) {
-            Ok(infos) => {
-                let mut found_local = false;
-                let local_addr = &SocketAddr {
-                    ip: Ipv4Addr(127, 0, 0, 1),
-                    port: 0
-                };
-                for addr in infos.iter() {
-                    found_local = found_local || addr.address == *local_addr;
-                }
-                assert!(found_local);
-            }
-            Err(e) => fail!("{:?}", e),
-        }
-    }
-
-    #[test]
-    fn issue_10663() {
-        let loop_ = &mut local_loop().loop_;
-        // Something should happen here, but this certainly shouldn't cause
-        // everything to die. The actual outcome we don't care too much about.
-        GetAddrInfoRequest::run(loop_, Some("irc.n0v4.com"), None,
-                                None);
-    }
-}
index fe29a112262283596d6cca7bacc69a9e15f50f57..4a8529d0a0aafec8e3d3b623d2090b001cc0fc20 100644 (file)
@@ -98,15 +98,15 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>)
     LocalIo::maybe_raise(|io| io.get_host_addresses(hostname, servname, hint))
 }
 
-#[cfg(test)]
+// Ignored on android since we cannot give tcp/ip
+// permission without help of apk
+#[cfg(test, not(target_os = "android"))]
 mod test {
     use io::net::ip::Ipv4Addr;
     use prelude::*;
     use super::*;
 
-    #[test]
-    #[ignore(cfg(target_os="android"))] // cannot give tcp/ip permission without help of apk
-    fn dns_smoke_test() {
+    iotest!(fn dns_smoke_test() {
         let ipaddrs = get_host_addresses("localhost").unwrap();
         let mut found_local = false;
         let local_addr = &Ipv4Addr(127, 0, 0, 1);
@@ -114,5 +114,11 @@ fn dns_smoke_test() {
             found_local = found_local || addr == local_addr;
         }
         assert!(found_local);
-    }
+    })
+
+    iotest!(fn issue_10663() {
+        // Something should happen here, but this certainly shouldn't cause
+        // everything to die. The actual outcome we don't care too much about.
+        get_host_addresses("example.com");
+    } #[ignore])
 }