Skip to content

Commit a04cc4d

Browse files
committed
libstd: Use iotest! for for get_host_addresses.
1 parent 5aa31c4 commit a04cc4d

File tree

2 files changed

+11
-41
lines changed

2 files changed

+11
-41
lines changed

src/librustuv/addrinfo.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -183,39 +183,3 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> ~[ai::Info] {
183183
return addrs;
184184
}
185185
}
186-
187-
// cannot give tcp/ip permission without help of apk
188-
#[cfg(test, not(target_os="android"))]
189-
mod test {
190-
use std::io::net::ip::{SocketAddr, Ipv4Addr};
191-
use super::super::local_loop;
192-
use super::GetAddrInfoRequest;
193-
194-
#[test]
195-
fn getaddrinfo_test() {
196-
let loop_ = &mut local_loop().loop_;
197-
match GetAddrInfoRequest::run(loop_, Some("localhost"), None, None) {
198-
Ok(infos) => {
199-
let mut found_local = false;
200-
let local_addr = &SocketAddr {
201-
ip: Ipv4Addr(127, 0, 0, 1),
202-
port: 0
203-
};
204-
for addr in infos.iter() {
205-
found_local = found_local || addr.address == *local_addr;
206-
}
207-
assert!(found_local);
208-
}
209-
Err(e) => fail!("{:?}", e),
210-
}
211-
}
212-
213-
#[test]
214-
fn issue_10663() {
215-
let loop_ = &mut local_loop().loop_;
216-
// Something should happen here, but this certainly shouldn't cause
217-
// everything to die. The actual outcome we don't care too much about.
218-
GetAddrInfoRequest::run(loop_, Some("irc.n0v4.com"), None,
219-
None);
220-
}
221-
}

src/libstd/io/net/addrinfo.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,27 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>)
9898
LocalIo::maybe_raise(|io| io.get_host_addresses(hostname, servname, hint))
9999
}
100100

101-
#[cfg(test)]
101+
// Ignored on android since we cannot give tcp/ip
102+
// permission without help of apk
103+
#[cfg(test, not(target_os = "android"))]
102104
mod test {
103105
use io::net::ip::Ipv4Addr;
104106
use prelude::*;
105107
use super::*;
106108

107-
#[test]
108-
#[ignore(cfg(target_os="android"))] // cannot give tcp/ip permission without help of apk
109-
fn dns_smoke_test() {
109+
iotest!(fn dns_smoke_test() {
110110
let ipaddrs = get_host_addresses("localhost").unwrap();
111111
let mut found_local = false;
112112
let local_addr = &Ipv4Addr(127, 0, 0, 1);
113113
for addr in ipaddrs.iter() {
114114
found_local = found_local || addr == local_addr;
115115
}
116116
assert!(found_local);
117-
}
117+
})
118+
119+
iotest!(fn issue_10663() {
120+
// Something should happen here, but this certainly shouldn't cause
121+
// everything to die. The actual outcome we don't care too much about.
122+
get_host_addresses("example.com");
123+
} #[ignore])
118124
}

0 commit comments

Comments
 (0)