Skip to content

Commit ed422b8

Browse files
committed
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.
2 parents 7c6c751 + 6538258 commit ed422b8

File tree

13 files changed

+86
-26
lines changed

13 files changed

+86
-26
lines changed

mk/tests.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ $(foreach host,$(CFG_HOST_TRIPLES), \
870870
$(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
871871
$(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))
872872

873-
check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE)
873+
check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE) check-stage2-std check-stage2-extra
874+
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
874875

875876
define DEF_CHECK_FAST_FOR_H
876877

src/libstd/num/f32.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,10 @@ mod tests {
11421142
assert_eq!(infinity.abs_sub(&1f32), infinity);
11431143
assert_eq!(0f32.abs_sub(&neg_infinity), infinity);
11441144
assert_eq!(0f32.abs_sub(&infinity), 0f32);
1145+
}
1146+
1147+
#[test] #[ignore(cfg(windows))] // FIXME #8663
1148+
fn test_abs_sub_nowin() {
11451149
assert!(NaN.abs_sub(&-1f32).is_NaN());
11461150
assert!(1f32.abs_sub(&NaN).is_NaN());
11471151
}
@@ -1267,7 +1271,10 @@ mod tests {
12671271

12681272
assert_eq!(0f32.frexp(), (0f32, 0));
12691273
assert_eq!((-0f32).frexp(), (-0f32, 0));
1274+
}
12701275

1276+
#[test] #[ignore(cfg(windows))] // FIXME #8755
1277+
fn test_frexp_nowin() {
12711278
let inf: f32 = Float::infinity();
12721279
let neg_inf: f32 = Float::neg_infinity();
12731280
let nan: f32 = Float::NaN();

src/libstd/num/f64.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,10 @@ mod tests {
11921192
assert_eq!(infinity.abs_sub(&1f64), infinity);
11931193
assert_eq!(0f64.abs_sub(&neg_infinity), infinity);
11941194
assert_eq!(0f64.abs_sub(&infinity), 0f64);
1195+
}
1196+
1197+
#[test] #[ignore(cfg(windows))] // FIXME #8663
1198+
fn test_abs_sub_nowin() {
11951199
assert!(NaN.abs_sub(&-1f64).is_NaN());
11961200
assert!(1f64.abs_sub(&NaN).is_NaN());
11971201
}
@@ -1316,7 +1320,10 @@ mod tests {
13161320

13171321
assert_eq!(0f64.frexp(), (0f64, 0));
13181322
assert_eq!((-0f64).frexp(), (-0f64, 0));
1323+
}
13191324

1325+
#[test] #[ignore(cfg(windows))] // FIXME #8755
1326+
fn test_frexp_nowin() {
13201327
let inf: f64 = Float::infinity();
13211328
let neg_inf: f64 = Float::neg_infinity();
13221329
let nan: f64 = Float::NaN();

src/libstd/num/float.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,10 @@ mod tests {
11631163
assert_eq!(infinity.abs_sub(&1f), infinity);
11641164
assert_eq!(0f.abs_sub(&neg_infinity), infinity);
11651165
assert_eq!(0f.abs_sub(&infinity), 0f);
1166+
}
1167+
1168+
#[test] #[ignore(cfg(windows))] // FIXME #8663
1169+
fn test_abs_sub_nowin() {
11661170
assert!(NaN.abs_sub(&-1f).is_NaN());
11671171
assert!(1f.abs_sub(&NaN).is_NaN());
11681172
}
@@ -1288,7 +1292,10 @@ mod tests {
12881292

12891293
assert_eq!(0f.frexp(), (0f, 0));
12901294
assert_eq!((-0f).frexp(), (-0f, 0));
1295+
}
12911296

1297+
#[test] #[ignore(cfg(windows))] // FIXME #8755
1298+
fn test_frexp_nowin() {
12921299
let inf: float = Float::infinity();
12931300
let neg_inf: float = Float::neg_infinity();
12941301
let nan: float = Float::NaN();

src/libstd/os.rs

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,12 +1418,12 @@ pub fn page_size() -> uint {
14181418
pub fn page_size() -> uint {
14191419
#[fixed_stack_segment]; #[inline(never)];
14201420

1421-
unsafe {
1422-
let mut info = libc::SYSTEM_INFO::new();
1423-
libc::GetSystemInfo(&mut info);
1421+
unsafe {
1422+
let mut info = libc::SYSTEM_INFO::new();
1423+
libc::GetSystemInfo(&mut info);
14241424

1425-
return info.dwPageSize as uint;
1426-
}
1425+
return info.dwPageSize as uint;
1426+
}
14271427
}
14281428

14291429
pub struct MemoryMap {
@@ -1458,7 +1458,6 @@ pub enum MapError {
14581458
// Windows-specific errors
14591459
ErrUnsupProt,
14601460
ErrUnsupOffset,
1461-
ErrNeedRW,
14621461
ErrAlreadyExists,
14631462
ErrVirtualAlloc(uint),
14641463
ErrCreateFileMappingW(uint),
@@ -1477,7 +1476,6 @@ impl to_str::ToStr for MapError {
14771476
ErrUnknown(code) => fmt!("Unknown error=%?", code),
14781477
ErrUnsupProt => ~"Protection mode unsupported",
14791478
ErrUnsupOffset => ~"Offset in virtual memory mode is unsupported",
1480-
ErrNeedRW => ~"File mapping should be at least readable/writable",
14811479
ErrAlreadyExists => ~"File mapping for specified file already exists",
14821480
ErrVirtualAlloc(code) => fmt!("VirtualAlloc failure=%?", code),
14831481
ErrCreateFileMappingW(code) => fmt!("CreateFileMappingW failure=%?", code),
@@ -1542,6 +1540,10 @@ impl MemoryMap {
15421540
})
15431541
}
15441542
}
1543+
1544+
pub fn granularity() -> uint {
1545+
page_size()
1546+
}
15451547
}
15461548

15471549
#[cfg(unix)]
@@ -1617,21 +1619,21 @@ impl MemoryMap {
16171619
})
16181620
}
16191621
} else {
1620-
let dwDesiredAccess = match (readable, writable) {
1621-
(true, true) => libc::FILE_MAP_ALL_ACCESS,
1622-
(true, false) => libc::FILE_MAP_READ,
1623-
(false, true) => libc::FILE_MAP_WRITE,
1624-
_ => {
1625-
return Err(ErrNeedRW);
1626-
}
1622+
let dwDesiredAccess = match (executable, readable, writable) {
1623+
(false, true, false) => libc::FILE_MAP_READ,
1624+
(false, true, true) => libc::FILE_MAP_WRITE,
1625+
(true, true, false) => libc::FILE_MAP_READ | libc::FILE_MAP_EXECUTE,
1626+
(true, true, true) => libc::FILE_MAP_WRITE | libc::FILE_MAP_EXECUTE,
1627+
_ => return Err(ErrUnsupProt) // Actually, because of the check above,
1628+
// we should never get here.
16271629
};
16281630
unsafe {
16291631
let hFile = libc::get_osfhandle(fd) as HANDLE;
16301632
let mapping = libc::CreateFileMappingW(hFile,
16311633
ptr::mut_null(),
16321634
flProtect,
1633-
(len >> 32) as DWORD,
1634-
(len & 0xffff_ffff) as DWORD,
1635+
0,
1636+
0,
16351637
ptr::null());
16361638
if mapping == ptr::mut_null() {
16371639
return Err(ErrCreateFileMappingW(errno()));
@@ -1641,7 +1643,7 @@ impl MemoryMap {
16411643
}
16421644
let r = libc::MapViewOfFile(mapping,
16431645
dwDesiredAccess,
1644-
(offset >> 32) as DWORD,
1646+
((len as u64) >> 32) as DWORD,
16451647
(offset & 0xffff_ffff) as DWORD,
16461648
0);
16471649
match r as uint {
@@ -1655,6 +1657,19 @@ impl MemoryMap {
16551657
}
16561658
}
16571659
}
1660+
1661+
/// Granularity of MapAddr() and MapOffset() parameter values.
1662+
/// This may be greater than the value returned by page_size().
1663+
pub fn granularity() -> uint {
1664+
#[fixed_stack_segment]; #[inline(never)];
1665+
1666+
unsafe {
1667+
let mut info = libc::SYSTEM_INFO::new();
1668+
libc::GetSystemInfo(&mut info);
1669+
1670+
return info.dwAllocationGranularity as uint;
1671+
}
1672+
}
16581673
}
16591674
16601675
#[cfg(windows)]
@@ -1663,20 +1678,22 @@ impl Drop for MemoryMap {
16631678
#[fixed_stack_segment]; #[inline(never)];
16641679
16651680
use libc::types::os::arch::extra::{LPCVOID, HANDLE};
1681+
use libc::consts::os::extra::FALSE;
16661682
16671683
unsafe {
16681684
match self.kind {
1669-
MapVirtual => match libc::VirtualFree(self.data as *mut c_void,
1670-
self.len,
1671-
libc::MEM_RELEASE) {
1672-
0 => error!(fmt!("VirtualFree failed: %?", errno())),
1673-
_ => ()
1685+
MapVirtual => {
1686+
if libc::VirtualFree(self.data as *mut c_void,
1687+
self.len,
1688+
libc::MEM_RELEASE) == FALSE {
1689+
error!(fmt!("VirtualFree failed: %?", errno()));
1690+
}
16741691
},
16751692
MapFile(mapping) => {
1676-
if libc::UnmapViewOfFile(self.data as LPCVOID) != 0 {
1693+
if libc::UnmapViewOfFile(self.data as LPCVOID) == FALSE {
16771694
error!(fmt!("UnmapViewOfFile failed: %?", errno()));
16781695
}
1679-
if libc::CloseHandle(mapping as HANDLE) != 0 {
1696+
if libc::CloseHandle(mapping as HANDLE) == FALSE {
16801697
error!(fmt!("CloseHandle failed: %?", errno()));
16811698
}
16821699
}
@@ -2108,7 +2125,7 @@ mod tests {
21082125
}
21092126
21102127
let path = tmpdir().push("mmap_file.tmp");
2111-
let size = page_size() * 2;
2128+
let size = MemoryMap::granularity() * 2;
21122129
remove_file(&path);
21132130
21142131
let fd = unsafe {

src/libstd/rt/io/file.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ fn file_test_smoke_test_impl() {
168168
}
169169

170170
#[test]
171+
#[ignore(cfg(windows))] // FIXME #8810
171172
fn file_test_io_smoke_test() {
172173
file_test_smoke_test_impl();
173174
}
@@ -235,6 +236,7 @@ fn file_test_io_non_positional_read_impl() {
235236
}
236237

237238
#[test]
239+
#[ignore(cfg(windows))] // FIXME #8810
238240
fn file_test_io_non_positional_read() {
239241
file_test_io_non_positional_read_impl();
240242
}
@@ -267,6 +269,7 @@ fn file_test_io_seeking_impl() {
267269
}
268270
}
269271
#[test]
272+
#[ignore(cfg(windows))] // FIXME #8810
270273
fn file_test_io_seek_and_tell_smoke_test() {
271274
file_test_io_seeking_impl();
272275
}
@@ -298,6 +301,7 @@ fn file_test_io_seek_and_write_impl() {
298301
}
299302
}
300303
#[test]
304+
#[ignore(cfg(windows))] // FIXME #8810
301305
fn file_test_io_seek_and_write() {
302306
file_test_io_seek_and_write_impl();
303307
}
@@ -337,6 +341,7 @@ fn file_test_io_seek_shakedown_impl() {
337341
}
338342
}
339343
#[test]
344+
#[ignore(cfg(windows))] // FIXME #8810
340345
fn file_test_io_seek_shakedown() {
341346
file_test_io_seek_shakedown_impl();
342347
}

src/libstd/rt/io/net/tcp.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ mod test {
162162
}
163163

164164
#[test]
165+
#[ignore(cfg(windows))] // FIXME #8811
165166
fn connect_error() {
166167
do run_in_newsched_task {
167168
let mut called = false;
@@ -258,6 +259,7 @@ mod test {
258259
}
259260

260261
#[test]
262+
#[ignore(cfg(windows))] // FIXME #8811
261263
fn read_eof_twice_ip4() {
262264
do run_in_newsched_task {
263265
let addr = next_test_ip4();
@@ -280,6 +282,7 @@ mod test {
280282
}
281283

282284
#[test]
285+
#[ignore(cfg(windows))] // FIXME #8811
283286
fn read_eof_twice_ip6() {
284287
do run_in_newsched_task {
285288
let addr = next_test_ip6();
@@ -302,6 +305,7 @@ mod test {
302305
}
303306

304307
#[test]
308+
#[ignore(cfg(windows))] // FIXME #8811
305309
fn write_close_ip4() {
306310
do run_in_newsched_task {
307311
let addr = next_test_ip4();
@@ -331,6 +335,7 @@ mod test {
331335
}
332336

333337
#[test]
338+
#[ignore(cfg(windows))] // FIXME #8811
334339
fn write_close_ip6() {
335340
do run_in_newsched_task {
336341
let addr = next_test_ip6();

src/libstd/rt/io/support.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ mod test {
3333
use super::PathLike;
3434

3535
#[test]
36+
#[ignore(cfg(windows))] // FIXME #8812
3637
fn path_like_smoke_test() {
3738
let expected = "/home";
3839
let path = Path(expected);

src/libstd/rt/uv/file.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,13 @@ mod test {
408408
}
409409
410410
#[test]
411+
#[ignore(cfg(windows))] // FIXME #8814
411412
fn file_test_full_simple() {
412413
file_test_full_simple_impl();
413414
}
414415
415416
#[test]
417+
#[ignore(cfg(windows))] // FIXME #8814
416418
fn file_test_full_simple_sync() {
417419
file_test_full_simple_impl_sync();
418420
}

src/libstd/rt/uv/net.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ mod test {
601601
}
602602
603603
#[test]
604+
#[ignore(cfg(windows))] // FIXME #8815
604605
fn listen_ip4() {
605606
do run_in_bare_thread() {
606607
static MAX: int = 10;
@@ -675,6 +676,7 @@ mod test {
675676
}
676677
677678
#[test]
679+
#[ignore(cfg(windows))] // FIXME #8815
678680
fn listen_ip6() {
679681
do run_in_bare_thread() {
680682
static MAX: int = 10;
@@ -751,6 +753,7 @@ mod test {
751753
}
752754
753755
#[test]
756+
#[ignore(cfg(windows))] // FIXME #8815
754757
fn udp_recv_ip4() {
755758
do run_in_bare_thread() {
756759
static MAX: int = 10;
@@ -811,6 +814,7 @@ mod test {
811814
}
812815
813816
#[test]
817+
#[ignore(cfg(windows))] // FIXME #8815
814818
fn udp_recv_ip6() {
815819
do run_in_bare_thread() {
816820
static MAX: int = 10;

src/libstd/rt/uv/uvio.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,7 @@ fn test_read_read_read() {
16661666
}
16671667

16681668
#[test]
1669+
#[ignore(cfg(windows))] // FIXME #8816
16691670
fn test_udp_twice() {
16701671
do run_in_newsched_task {
16711672
let server_addr = next_test_ip4();
@@ -1800,6 +1801,7 @@ fn file_test_uvio_full_simple_impl() {
18001801
}
18011802

18021803
#[test]
1804+
#[ignore(cfg(windows))] // FIXME #8816
18031805
fn file_test_uvio_full_simple() {
18041806
do run_in_newsched_task {
18051807
file_test_uvio_full_simple_impl();

src/libstd/rt/uv/uvll.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ fn handle_sanity_check() {
227227
}
228228

229229
#[test]
230+
#[ignore(cfg(windows))] // FIXME #8817
230231
#[fixed_stack_segment]
231232
#[inline(never)]
232233
fn request_sanity_check() {

src/libstd/unstable/dynamic_lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ mod test {
9090
use libc;
9191

9292
#[test]
93+
#[ignore(cfg(windows))] // FIXME #8818
9394
fn test_loading_cosine() {
9495
// The math library does not need to be loaded since it is already
9596
// statically linked in

0 commit comments

Comments
 (0)