mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
auto merge of #5388 : Ms2ger/servo/net-tests, r=jdm
This commit is contained in:
commit
ac786e2967
2 changed files with 5 additions and 10 deletions
|
@ -8,6 +8,7 @@
|
||||||
#![feature(core)]
|
#![feature(core)]
|
||||||
#![feature(int_uint)]
|
#![feature(int_uint)]
|
||||||
#![feature(io)]
|
#![feature(io)]
|
||||||
|
#![cfg_attr(test, feature(net))]
|
||||||
#![feature(path)]
|
#![feature(path)]
|
||||||
#![feature(path_ext)]
|
#![feature(path_ext)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
|
|
|
@ -31,11 +31,6 @@ use std::io::{BufReader, Read};
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::thunk::Invoke;
|
use std::thunk::Invoke;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
use std::old_io::{Listener, Acceptor, TimedOut};
|
|
||||||
#[cfg(test)]
|
|
||||||
use std::old_io::net::tcp::TcpListener;
|
|
||||||
|
|
||||||
static mut HOST_TABLE: Option<*mut HashMap<String, String>> = None;
|
static mut HOST_TABLE: Option<*mut HashMap<String, String>> = None;
|
||||||
|
|
||||||
pub fn global_init() {
|
pub fn global_init() {
|
||||||
|
@ -533,6 +528,8 @@ fn test_parse_hostsfile_with_end_of_line_whitespace()
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_replace_hosts() {
|
fn test_replace_hosts() {
|
||||||
|
use std::net::TcpListener;
|
||||||
|
|
||||||
let mut host_table_box = box HashMap::new();
|
let mut host_table_box = box HashMap::new();
|
||||||
host_table_box.insert("foo.bar.com".to_owned(), "127.0.0.1".to_owned());
|
host_table_box.insert("foo.bar.com".to_owned(), "127.0.0.1".to_owned());
|
||||||
host_table_box.insert("servo.test.server".to_owned(), "127.0.0.2".to_owned());
|
host_table_box.insert("servo.test.server".to_owned(), "127.0.0.2".to_owned());
|
||||||
|
@ -543,8 +540,7 @@ fn test_replace_hosts() {
|
||||||
|
|
||||||
//Start the TCP server
|
//Start the TCP server
|
||||||
let mut listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
let mut listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let port = listener.socket_name().unwrap().port;
|
let port = listener.socket_addr().unwrap().port();
|
||||||
let mut acceptor = listener.listen().unwrap();
|
|
||||||
|
|
||||||
//Start the resource task and make a request to our TCP server
|
//Start the resource task and make a request to our TCP server
|
||||||
let resource_task = new_resource_task(None);
|
let resource_task = new_resource_task(None);
|
||||||
|
@ -552,12 +548,10 @@ fn test_replace_hosts() {
|
||||||
let url = Url::parse(&format!("http://foo.bar.com:{}", port)).unwrap();
|
let url = Url::parse(&format!("http://foo.bar.com:{}", port)).unwrap();
|
||||||
resource_task.send(ControlMsg::Load(replace_hosts(LoadData::new(url, start_chan), host_table)));
|
resource_task.send(ControlMsg::Load(replace_hosts(LoadData::new(url, start_chan), host_table)));
|
||||||
|
|
||||||
match acceptor.accept() {
|
match listener.accept() {
|
||||||
Ok(..) => assert!(true, "received request"),
|
Ok(..) => assert!(true, "received request"),
|
||||||
Err(ref e) if e.kind == TimedOut => { assert!(false, "timed out!"); },
|
|
||||||
Err(_) => assert!(false, "error")
|
Err(_) => assert!(false, "error")
|
||||||
}
|
}
|
||||||
|
|
||||||
resource_task.send(ControlMsg::Exit);
|
resource_task.send(ControlMsg::Exit);
|
||||||
drop(acceptor);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue