Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable unit tests in libstd and libextra on Windows #8819

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,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

Expand Down
7 changes: 7 additions & 0 deletions src/libstd/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/libstd/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/libstd/num/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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();
Expand Down
67 changes: 42 additions & 25 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1458,7 +1458,6 @@ pub enum MapError {
// Windows-specific errors
ErrUnsupProt,
ErrUnsupOffset,
ErrNeedRW,
ErrAlreadyExists,
ErrVirtualAlloc(uint),
ErrCreateFileMappingW(uint),
Expand All @@ -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),
Expand Down Expand Up @@ -1542,6 +1540,10 @@ impl MemoryMap {
})
}
}

pub fn granularity() -> uint {
page_size()
}
}

#[cfg(unix)]
Expand Down Expand Up @@ -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()));
Expand All @@ -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 {
Expand All @@ -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)]
Expand All @@ -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()));
}
}
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/libstd/rt/io/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ fn file_test_smoke_test_impl() {
}

#[test]
#[ignore(cfg(windows))] // FIXME #8810
fn file_test_io_smoke_test() {
file_test_smoke_test_impl();
}
Expand Down Expand Up @@ -232,6 +233,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();
}
Expand Down Expand Up @@ -264,6 +266,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();
}
Expand Down Expand Up @@ -295,6 +298,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();
}
Expand Down Expand Up @@ -334,6 +338,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();
}
5 changes: 5 additions & 0 deletions src/libstd/rt/io/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ mod test {
}

#[test]
#[ignore(cfg(windows))] // FIXME #8811
fn connect_error() {
do run_in_newsched_task {
let mut called = false;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/libstd/rt/io/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/rt/uv/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,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();
}
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/rt/uv/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn listen_ip4() {
do run_in_bare_thread() {
static MAX: int = 10;
Expand Down Expand Up @@ -674,6 +675,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn listen_ip6() {
do run_in_bare_thread() {
static MAX: int = 10;
Expand Down Expand Up @@ -750,6 +752,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn udp_recv_ip4() {
do run_in_bare_thread() {
static MAX: int = 10;
Expand Down Expand Up @@ -810,6 +813,7 @@ mod test {
}
#[test]
#[ignore(cfg(windows))] // FIXME #8815
fn udp_recv_ip6() {
do run_in_bare_thread() {
static MAX: int = 10;
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/rt/uv/uvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,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();
Expand Down Expand Up @@ -1994,6 +1995,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();
Expand Down
1 change: 1 addition & 0 deletions src/libstd/rt/uv/uvll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ fn handle_sanity_check() {
}

#[test]
#[ignore(cfg(windows))] // FIXME #8817
#[fixed_stack_segment]
#[inline(never)]
fn request_sanity_check() {
Expand Down
1 change: 1 addition & 0 deletions src/libstd/unstable/dynamic_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down