auto merge of #8819 : vadimcn/rust/unit-tests, r=brson

Some of the tests are failing.  I've only managed to fix 'memory_map_file', the rest are up for grabs...

Fixes #5261.
This commit is contained in:
bors 2013-08-29 20:40:47 -07:00
commit ed422b8872
13 changed files with 86 additions and 26 deletions

View File

@ -870,7 +870,8 @@ $(foreach host,$(CFG_HOST_TRIPLES), \
$(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
$(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))
check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE)
check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE) check-stage2-std check-stage2-extra
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
define DEF_CHECK_FAST_FOR_H

View File

@ -1142,6 +1142,10 @@ mod tests {
assert_eq!(infinity.abs_sub(&1f32), infinity);
assert_eq!(0f32.abs_sub(&neg_infinity), infinity);
assert_eq!(0f32.abs_sub(&infinity), 0f32);
}
#[test] #[ignore(cfg(windows))] // FIXME #8663
fn test_abs_sub_nowin() {
assert!(NaN.abs_sub(&-1f32).is_NaN());
assert!(1f32.abs_sub(&NaN).is_NaN());
}
@ -1267,7 +1271,10 @@ mod tests {
assert_eq!(0f32.frexp(), (0f32, 0));
assert_eq!((-0f32).frexp(), (-0f32, 0));
}
#[test] #[ignore(cfg(windows))] // FIXME #8755
fn test_frexp_nowin() {
let inf: f32 = Float::infinity();
let neg_inf: f32 = Float::neg_infinity();
let nan: f32 = Float::NaN();

View File

@ -1192,6 +1192,10 @@ mod tests {
assert_eq!(infinity.abs_sub(&1f64), infinity);
assert_eq!(0f64.abs_sub(&neg_infinity), infinity);
assert_eq!(0f64.abs_sub(&infinity), 0f64);
}
#[test] #[ignore(cfg(windows))] // FIXME #8663
fn test_abs_sub_nowin() {
assert!(NaN.abs_sub(&-1f64).is_NaN());
assert!(1f64.abs_sub(&NaN).is_NaN());
}
@ -1316,7 +1320,10 @@ mod tests {
assert_eq!(0f64.frexp(), (0f64, 0));
assert_eq!((-0f64).frexp(), (-0f64, 0));
}
#[test] #[ignore(cfg(windows))] // FIXME #8755
fn test_frexp_nowin() {
let inf: f64 = Float::infinity();
let neg_inf: f64 = Float::neg_infinity();
let nan: f64 = Float::NaN();

View File

@ -1163,6 +1163,10 @@ mod tests {
assert_eq!(infinity.abs_sub(&1f), infinity);
assert_eq!(0f.abs_sub(&neg_infinity), infinity);
assert_eq!(0f.abs_sub(&infinity), 0f);
}
#[test] #[ignore(cfg(windows))] // FIXME #8663
fn test_abs_sub_nowin() {
assert!(NaN.abs_sub(&-1f).is_NaN());
assert!(1f.abs_sub(&NaN).is_NaN());
}
@ -1288,7 +1292,10 @@ mod tests {
assert_eq!(0f.frexp(), (0f, 0));
assert_eq!((-0f).frexp(), (-0f, 0));
}
#[test] #[ignore(cfg(windows))] // FIXME #8755
fn test_frexp_nowin() {
let inf: float = Float::infinity();
let neg_inf: float = Float::neg_infinity();
let nan: float = Float::NaN();

View File

@ -1418,12 +1418,12 @@ pub fn page_size() -> uint {
pub fn page_size() -> uint {
#[fixed_stack_segment]; #[inline(never)];
unsafe {
let mut info = libc::SYSTEM_INFO::new();
libc::GetSystemInfo(&mut info);
unsafe {
let mut info = libc::SYSTEM_INFO::new();
libc::GetSystemInfo(&mut info);
return info.dwPageSize as uint;
}
return info.dwPageSize as uint;
}
}
pub struct MemoryMap {
@ -1458,7 +1458,6 @@ pub enum MapError {
// Windows-specific errors
ErrUnsupProt,
ErrUnsupOffset,
ErrNeedRW,
ErrAlreadyExists,
ErrVirtualAlloc(uint),
ErrCreateFileMappingW(uint),
@ -1477,7 +1476,6 @@ impl to_str::ToStr for MapError {
ErrUnknown(code) => fmt!("Unknown error=%?", code),
ErrUnsupProt => ~"Protection mode unsupported",
ErrUnsupOffset => ~"Offset in virtual memory mode is unsupported",
ErrNeedRW => ~"File mapping should be at least readable/writable",
ErrAlreadyExists => ~"File mapping for specified file already exists",
ErrVirtualAlloc(code) => fmt!("VirtualAlloc failure=%?", code),
ErrCreateFileMappingW(code) => fmt!("CreateFileMappingW failure=%?", code),
@ -1542,6 +1540,10 @@ impl MemoryMap {
})
}
}
pub fn granularity() -> uint {
page_size()
}
}
#[cfg(unix)]
@ -1617,21 +1619,21 @@ impl MemoryMap {
})
}
} else {
let dwDesiredAccess = match (readable, writable) {
(true, true) => libc::FILE_MAP_ALL_ACCESS,
(true, false) => libc::FILE_MAP_READ,
(false, true) => libc::FILE_MAP_WRITE,
_ => {
return Err(ErrNeedRW);
}
let dwDesiredAccess = match (executable, readable, writable) {
(false, true, false) => libc::FILE_MAP_READ,
(false, true, true) => libc::FILE_MAP_WRITE,
(true, true, false) => libc::FILE_MAP_READ | libc::FILE_MAP_EXECUTE,
(true, true, true) => libc::FILE_MAP_WRITE | libc::FILE_MAP_EXECUTE,
_ => return Err(ErrUnsupProt) // Actually, because of the check above,
// we should never get here.
};
unsafe {
let hFile = libc::get_osfhandle(fd) as HANDLE;
let mapping = libc::CreateFileMappingW(hFile,
ptr::mut_null(),
flProtect,
(len >> 32) as DWORD,
(len & 0xffff_ffff) as DWORD,
0,
0,
ptr::null());
if mapping == ptr::mut_null() {
return Err(ErrCreateFileMappingW(errno()));
@ -1641,7 +1643,7 @@ impl MemoryMap {
}
let r = libc::MapViewOfFile(mapping,
dwDesiredAccess,
(offset >> 32) as DWORD,
((len as u64) >> 32) as DWORD,
(offset & 0xffff_ffff) as DWORD,
0);
match r as uint {
@ -1655,6 +1657,19 @@ impl MemoryMap {
}
}
}
/// Granularity of MapAddr() and MapOffset() parameter values.
/// This may be greater than the value returned by page_size().
pub fn granularity() -> uint {
#[fixed_stack_segment]; #[inline(never)];
unsafe {
let mut info = libc::SYSTEM_INFO::new();
libc::GetSystemInfo(&mut info);
return info.dwAllocationGranularity as uint;
}
}
}
#[cfg(windows)]
@ -1663,20 +1678,22 @@ impl Drop for MemoryMap {
#[fixed_stack_segment]; #[inline(never)];
use libc::types::os::arch::extra::{LPCVOID, HANDLE};
use libc::consts::os::extra::FALSE;
unsafe {
match self.kind {
MapVirtual => match libc::VirtualFree(self.data as *mut c_void,
self.len,
libc::MEM_RELEASE) {
0 => error!(fmt!("VirtualFree failed: %?", errno())),
_ => ()
MapVirtual => {
if libc::VirtualFree(self.data as *mut c_void,
self.len,
libc::MEM_RELEASE) == FALSE {
error!(fmt!("VirtualFree failed: %?", errno()));
}
},
MapFile(mapping) => {
if libc::UnmapViewOfFile(self.data as LPCVOID) != 0 {
if libc::UnmapViewOfFile(self.data as LPCVOID) == FALSE {
error!(fmt!("UnmapViewOfFile failed: %?", errno()));
}
if libc::CloseHandle(mapping as HANDLE) != 0 {
if libc::CloseHandle(mapping as HANDLE) == FALSE {
error!(fmt!("CloseHandle failed: %?", errno()));
}
}
@ -2108,7 +2125,7 @@ mod tests {
}
let path = tmpdir().push("mmap_file.tmp");
let size = page_size() * 2;
let size = MemoryMap::granularity() * 2;
remove_file(&path);
let fd = unsafe {

View File

@ -168,6 +168,7 @@ fn file_test_smoke_test_impl() {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8810
fn file_test_io_smoke_test() {
file_test_smoke_test_impl();
}
@ -235,6 +236,7 @@ fn file_test_io_non_positional_read_impl() {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8810
fn file_test_io_non_positional_read() {
file_test_io_non_positional_read_impl();
}
@ -267,6 +269,7 @@ fn file_test_io_seeking_impl() {
}
}
#[test]
#[ignore(cfg(windows))] // FIXME #8810
fn file_test_io_seek_and_tell_smoke_test() {
file_test_io_seeking_impl();
}
@ -298,6 +301,7 @@ fn file_test_io_seek_and_write_impl() {
}
}
#[test]
#[ignore(cfg(windows))] // FIXME #8810
fn file_test_io_seek_and_write() {
file_test_io_seek_and_write_impl();
}
@ -337,6 +341,7 @@ fn file_test_io_seek_shakedown_impl() {
}
}
#[test]
#[ignore(cfg(windows))] // FIXME #8810
fn file_test_io_seek_shakedown() {
file_test_io_seek_shakedown_impl();
}

View File

@ -162,6 +162,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8811
fn connect_error() {
do run_in_newsched_task {
let mut called = false;
@ -258,6 +259,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8811
fn read_eof_twice_ip4() {
do run_in_newsched_task {
let addr = next_test_ip4();
@ -280,6 +282,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8811
fn read_eof_twice_ip6() {
do run_in_newsched_task {
let addr = next_test_ip6();
@ -302,6 +305,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8811
fn write_close_ip4() {
do run_in_newsched_task {
let addr = next_test_ip4();
@ -331,6 +335,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8811
fn write_close_ip6() {
do run_in_newsched_task {
let addr = next_test_ip6();

View File

@ -33,6 +33,7 @@ mod test {
use super::PathLike;
#[test]
#[ignore(cfg(windows))] // FIXME #8812
fn path_like_smoke_test() {
let expected = "/home";
let path = Path(expected);

View File

@ -408,11 +408,13 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8814
fn file_test_full_simple() {
file_test_full_simple_impl();
}
#[test]
#[ignore(cfg(windows))] // FIXME #8814
fn file_test_full_simple_sync() {
file_test_full_simple_impl_sync();
}

View File

@ -601,6 +601,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn listen_ip4() {
do run_in_bare_thread() {
static MAX: int = 10;
@ -675,6 +676,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn listen_ip6() {
do run_in_bare_thread() {
static MAX: int = 10;
@ -751,6 +753,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn udp_recv_ip4() {
do run_in_bare_thread() {
static MAX: int = 10;
@ -811,6 +814,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn udp_recv_ip6() {
do run_in_bare_thread() {
static MAX: int = 10;

View File

@ -1666,6 +1666,7 @@ fn test_read_read_read() {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8816
fn test_udp_twice() {
do run_in_newsched_task {
let server_addr = next_test_ip4();
@ -1800,6 +1801,7 @@ fn file_test_uvio_full_simple_impl() {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8816
fn file_test_uvio_full_simple() {
do run_in_newsched_task {
file_test_uvio_full_simple_impl();

View File

@ -227,6 +227,7 @@ fn handle_sanity_check() {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8817
#[fixed_stack_segment]
#[inline(never)]
fn request_sanity_check() {

View File

@ -90,6 +90,7 @@ mod test {
use libc;
#[test]
#[ignore(cfg(windows))] // FIXME #8818
fn test_loading_cosine() {
// The math library does not need to be loaded since it is already
// statically linked in