Fix warnings when compiling stdlib with --test
This commit is contained in:
parent
27a1834ce5
commit
e27cbeff37
26 changed files with 81 additions and 75 deletions
|
@ -132,6 +132,7 @@ mod tests {
|
||||||
#[cfg_attr(any(windows,
|
#[cfg_attr(any(windows,
|
||||||
target_os = "android", // FIXME #10379
|
target_os = "android", // FIXME #10379
|
||||||
target_env = "musl"), ignore)]
|
target_env = "musl"), ignore)]
|
||||||
|
#[allow(deprecated)]
|
||||||
fn test_loading_cosine() {
|
fn test_loading_cosine() {
|
||||||
// The math library does not need to be loaded since it is already
|
// The math library does not need to be loaded since it is already
|
||||||
// statically linked in
|
// statically linked in
|
||||||
|
@ -164,6 +165,7 @@ mod tests {
|
||||||
target_os = "bitrig",
|
target_os = "bitrig",
|
||||||
target_os = "netbsd",
|
target_os = "netbsd",
|
||||||
target_os = "openbsd"))]
|
target_os = "openbsd"))]
|
||||||
|
#[allow(deprecated)]
|
||||||
fn test_errors_do_not_crash() {
|
fn test_errors_do_not_crash() {
|
||||||
// Open /dev/null as a library to get an error, and make sure
|
// Open /dev/null as a library to get an error, and make sure
|
||||||
// that only causes an error, and not a crash.
|
// that only causes an error, and not a crash.
|
||||||
|
|
|
@ -1281,7 +1281,6 @@ mod tests {
|
||||||
use io::{ErrorKind, SeekFrom};
|
use io::{ErrorKind, SeekFrom};
|
||||||
use path::PathBuf;
|
use path::PathBuf;
|
||||||
use path::Path as Path2;
|
use path::Path as Path2;
|
||||||
use os;
|
|
||||||
use rand::{self, StdRng, Rng};
|
use rand::{self, StdRng, Rng};
|
||||||
use str;
|
use str;
|
||||||
|
|
||||||
|
@ -1410,8 +1409,8 @@ mod tests {
|
||||||
let message = "ten-four";
|
let message = "ten-four";
|
||||||
let mut read_mem = [0; 4];
|
let mut read_mem = [0; 4];
|
||||||
let set_cursor = 4 as u64;
|
let set_cursor = 4 as u64;
|
||||||
let mut tell_pos_pre_read;
|
let tell_pos_pre_read;
|
||||||
let mut tell_pos_post_read;
|
let tell_pos_post_read;
|
||||||
let tmpdir = tmpdir();
|
let tmpdir = tmpdir();
|
||||||
let filename = &tmpdir.join("file_rt_io_file_test_seeking.txt");
|
let filename = &tmpdir.join("file_rt_io_file_test_seeking.txt");
|
||||||
{
|
{
|
||||||
|
|
|
@ -791,7 +791,7 @@ impl<W: Read + Write> Read for InternalBufWriter<W> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use prelude::v1::*;
|
use prelude::v1::*;
|
||||||
use io::prelude::*;
|
use io::prelude::*;
|
||||||
use io::{self, BufReader, BufWriter, Cursor, LineWriter, SeekFrom};
|
use io::{self, BufReader, BufWriter, LineWriter, SeekFrom};
|
||||||
use test;
|
use test;
|
||||||
|
|
||||||
/// A dummy reader intended at testing short-reads propagation.
|
/// A dummy reader intended at testing short-reads propagation.
|
||||||
|
|
|
@ -377,7 +377,7 @@ mod test {
|
||||||
struct TestError;
|
struct TestError;
|
||||||
|
|
||||||
impl fmt::Display for TestError {
|
impl fmt::Display for TestError {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1983,7 +1983,7 @@ mod tests {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut lr = repeat(1).take(10000000);
|
let mut lr = repeat(1).take(10000000);
|
||||||
let mut vec = Vec::with_capacity(1024);
|
let mut vec = Vec::with_capacity(1024);
|
||||||
super::read_to_end(&mut lr, &mut vec);
|
super::read_to_end(&mut lr, &mut vec)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(deprecated)]
|
||||||
fn tee() {
|
fn tee() {
|
||||||
let mut buf = [0; 10];
|
let mut buf = [0; 10];
|
||||||
{
|
{
|
||||||
|
@ -209,6 +210,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(deprecated)]
|
||||||
fn broadcast() {
|
fn broadcast() {
|
||||||
let mut buf1 = [0; 10];
|
let mut buf1 = [0; 10];
|
||||||
let mut buf2 = [0; 10];
|
let mut buf2 = [0; 10];
|
||||||
|
|
|
@ -468,9 +468,7 @@ impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use prelude::v1::*;
|
use prelude::v1::*;
|
||||||
use io;
|
|
||||||
use net::*;
|
use net::*;
|
||||||
use net::Ipv6MulticastScope::*;
|
|
||||||
use net::test::{tsa, sa6, sa4};
|
use net::test::{tsa, sa6, sa4};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -527,7 +527,6 @@ impl FromInner<c::in6_addr> for Ipv6Addr {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use prelude::v1::*;
|
use prelude::v1::*;
|
||||||
use io;
|
|
||||||
use net::*;
|
use net::*;
|
||||||
use net::Ipv6MulticastScope::*;
|
use net::Ipv6MulticastScope::*;
|
||||||
use net::test::{tsa, sa6, sa4};
|
use net::test::{tsa, sa6, sa4};
|
||||||
|
|
|
@ -319,7 +319,7 @@ mod tests {
|
||||||
use net::test::{next_test_ip4, next_test_ip6};
|
use net::test::{next_test_ip4, next_test_ip6};
|
||||||
use sync::mpsc::channel;
|
use sync::mpsc::channel;
|
||||||
use sys_common::AsInner;
|
use sys_common::AsInner;
|
||||||
use time::Duration;
|
use time::{Instant, Duration};
|
||||||
use thread;
|
use thread;
|
||||||
|
|
||||||
fn each_ip(f: &mut FnMut(SocketAddr)) {
|
fn each_ip(f: &mut FnMut(SocketAddr)) {
|
||||||
|
@ -929,6 +929,7 @@ mod tests {
|
||||||
|
|
||||||
t!(stream.set_write_timeout(None));
|
t!(stream.set_write_timeout(None));
|
||||||
assert_eq!(None, t!(stream.write_timeout()));
|
assert_eq!(None, t!(stream.write_timeout()));
|
||||||
|
drop(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -940,11 +941,11 @@ mod tests {
|
||||||
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
|
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
|
||||||
|
|
||||||
let mut buf = [0; 10];
|
let mut buf = [0; 10];
|
||||||
let wait = Duration::span(|| {
|
let start = Instant::now();
|
||||||
let kind = stream.read(&mut buf).err().expect("expected error").kind();
|
let kind = stream.read(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
assert!(start.elapsed() > Duration::from_millis(400));
|
||||||
assert!(wait > Duration::from_millis(400));
|
drop(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -962,10 +963,10 @@ mod tests {
|
||||||
t!(stream.read(&mut buf));
|
t!(stream.read(&mut buf));
|
||||||
assert_eq!(b"hello world", &buf[..]);
|
assert_eq!(b"hello world", &buf[..]);
|
||||||
|
|
||||||
let wait = Duration::span(|| {
|
let start = Instant::now();
|
||||||
let kind = stream.read(&mut buf).err().expect("expected error").kind();
|
let kind = stream.read(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
assert!(start.elapsed() > Duration::from_millis(400));
|
||||||
assert!(wait > Duration::from_millis(400));
|
drop(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ mod tests {
|
||||||
use net::test::{next_test_ip4, next_test_ip6};
|
use net::test::{next_test_ip4, next_test_ip6};
|
||||||
use sync::mpsc::channel;
|
use sync::mpsc::channel;
|
||||||
use sys_common::AsInner;
|
use sys_common::AsInner;
|
||||||
use time::Duration;
|
use time::{Instant, Duration};
|
||||||
use thread;
|
use thread;
|
||||||
|
|
||||||
fn each_ip(f: &mut FnMut(SocketAddr, SocketAddr)) {
|
fn each_ip(f: &mut FnMut(SocketAddr, SocketAddr)) {
|
||||||
|
@ -370,22 +370,22 @@ mod tests {
|
||||||
fn test_read_timeout() {
|
fn test_read_timeout() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
|
|
||||||
let mut stream = t!(UdpSocket::bind(&addr));
|
let stream = t!(UdpSocket::bind(&addr));
|
||||||
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
|
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
|
||||||
|
|
||||||
let mut buf = [0; 10];
|
let mut buf = [0; 10];
|
||||||
let wait = Duration::span(|| {
|
|
||||||
|
let start = Instant::now();
|
||||||
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
|
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
assert!(start.elapsed() > Duration::from_millis(400));
|
||||||
assert!(wait > Duration::from_millis(400));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_read_with_timeout() {
|
fn test_read_with_timeout() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
|
|
||||||
let mut stream = t!(UdpSocket::bind(&addr));
|
let stream = t!(UdpSocket::bind(&addr));
|
||||||
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
|
t!(stream.set_read_timeout(Some(Duration::from_millis(1000))));
|
||||||
|
|
||||||
t!(stream.send_to(b"hello world", &addr));
|
t!(stream.send_to(b"hello world", &addr));
|
||||||
|
@ -394,10 +394,9 @@ mod tests {
|
||||||
t!(stream.recv_from(&mut buf));
|
t!(stream.recv_from(&mut buf));
|
||||||
assert_eq!(b"hello world", &buf[..]);
|
assert_eq!(b"hello world", &buf[..]);
|
||||||
|
|
||||||
let wait = Duration::span(|| {
|
let start = Instant::now();
|
||||||
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
|
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
assert!(start.elapsed() > Duration::from_millis(400));
|
||||||
assert!(wait > Duration::from_millis(400));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,16 @@
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
use core::num;
|
use core::num;
|
||||||
|
#[cfg(not(test))]
|
||||||
use intrinsics;
|
use intrinsics;
|
||||||
|
#[cfg(not(test))]
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
|
#[cfg(not(test))]
|
||||||
use num::FpCategory;
|
use num::FpCategory;
|
||||||
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
|
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
|
@ -15,9 +15,13 @@
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
|
#[cfg(not(test))]
|
||||||
use core::num;
|
use core::num;
|
||||||
|
#[cfg(not(test))]
|
||||||
use intrinsics;
|
use intrinsics;
|
||||||
|
#[cfg(not(test))]
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
|
#[cfg(not(test))]
|
||||||
use num::FpCategory;
|
use num::FpCategory;
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
|
@ -47,11 +47,6 @@ pub fn test_num<T>(ten: T, two: T) where
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use i8;
|
|
||||||
use i16;
|
|
||||||
use i32;
|
|
||||||
use i64;
|
|
||||||
use isize;
|
|
||||||
use u8;
|
use u8;
|
||||||
use u16;
|
use u16;
|
||||||
use u32;
|
use u32;
|
||||||
|
|
|
@ -88,7 +88,8 @@ mod tests {
|
||||||
c_longlong c_ulonglong c_float c_double);
|
c_longlong c_ulonglong c_float c_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(all(unix, not(target_os = "android")))]
|
||||||
|
#[test]
|
||||||
fn unix() {
|
fn unix() {
|
||||||
{
|
{
|
||||||
use os::unix::raw;
|
use os::unix::raw;
|
||||||
|
@ -101,6 +102,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
#[test]
|
||||||
fn windows() {
|
fn windows() {
|
||||||
use os::windows::raw;
|
use os::windows::raw;
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,8 +381,6 @@ mod imp {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use prelude::v1::*;
|
|
||||||
|
|
||||||
use sync::mpsc::channel;
|
use sync::mpsc::channel;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use super::OsRng;
|
use super::OsRng;
|
||||||
|
|
|
@ -63,8 +63,6 @@ impl<R: Read> Rng for ReaderRng<R> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use prelude::v1::*;
|
|
||||||
|
|
||||||
use super::ReaderRng;
|
use super::ReaderRng;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,7 @@
|
||||||
issue = "0")]
|
issue = "0")]
|
||||||
#![doc(hidden)]
|
#![doc(hidden)]
|
||||||
|
|
||||||
use borrow::ToOwned;
|
|
||||||
use mem;
|
|
||||||
use panic;
|
|
||||||
use sys;
|
|
||||||
use sys_common::thread_info::{self, NewThread};
|
|
||||||
use sys_common;
|
|
||||||
use thread::Thread;
|
|
||||||
|
|
||||||
// Reexport some of our utilities which are expected by other crates.
|
// Reexport some of our utilities which are expected by other crates.
|
||||||
pub use sys_common::unwind::{begin_unwind, begin_unwind_fmt};
|
pub use sys_common::unwind::{begin_unwind, begin_unwind_fmt};
|
||||||
|
@ -41,6 +35,14 @@ pub use sys_common::unwind::imp::eh_frame_registry::*;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
#[lang = "start"]
|
#[lang = "start"]
|
||||||
fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
|
fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
|
||||||
|
use borrow::ToOwned;
|
||||||
|
use mem;
|
||||||
|
use panic;
|
||||||
|
use sys;
|
||||||
|
use sys_common;
|
||||||
|
use sys_common::thread_info::{self, NewThread};
|
||||||
|
use thread::Thread;
|
||||||
|
|
||||||
sys::init();
|
sys::init();
|
||||||
|
|
||||||
let failed = unsafe {
|
let failed = unsafe {
|
||||||
|
|
|
@ -510,15 +510,15 @@ mod tests {
|
||||||
static M: StaticMutex = StaticMutex::new();
|
static M: StaticMutex = StaticMutex::new();
|
||||||
|
|
||||||
let g = M.lock().unwrap();
|
let g = M.lock().unwrap();
|
||||||
let (g, _no_timeout) = C.wait_timeout_ms(g, 1).unwrap();
|
let (g, _no_timeout) = C.wait_timeout(g, Duration::from_millis(1)).unwrap();
|
||||||
// spurious wakeups mean this isn't necessarily true
|
// spurious wakeups mean this isn't necessarily true
|
||||||
// assert!(!no_timeout);
|
// assert!(!no_timeout);
|
||||||
let _t = thread::spawn(move || {
|
let _t = thread::spawn(move || {
|
||||||
let _g = M.lock().unwrap();
|
let _g = M.lock().unwrap();
|
||||||
C.notify_one();
|
C.notify_one();
|
||||||
});
|
});
|
||||||
let (g, no_timeout) = C.wait_timeout_ms(g, u32::MAX).unwrap();
|
let (g, timeout_res) = C.wait_timeout(g, Duration::from_millis(u32::MAX as u64)).unwrap();
|
||||||
assert!(no_timeout);
|
assert!(!timeout_res.timed_out());
|
||||||
drop(g);
|
drop(g);
|
||||||
unsafe { C.destroy(); M.destroy(); }
|
unsafe { C.destroy(); M.destroy(); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ mod tests {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut lr = repeat(1).take(10000000);
|
let mut lr = repeat(1).take(10000000);
|
||||||
let mut vec = Vec::with_capacity(1024);
|
let mut vec = Vec::with_capacity(1024);
|
||||||
unsafe { read_to_end_uninitialized(&mut lr, &mut vec) };
|
unsafe { read_to_end_uninitialized(&mut lr, &mut vec) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,6 @@ mod tests {
|
||||||
use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
|
use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
|
||||||
use cell::RefCell;
|
use cell::RefCell;
|
||||||
use sync::Arc;
|
use sync::Arc;
|
||||||
use boxed;
|
|
||||||
use thread;
|
use thread;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -208,13 +207,13 @@ mod tests {
|
||||||
fn trylock_works() {
|
fn trylock_works() {
|
||||||
let m = Arc::new(ReentrantMutex::new(()));
|
let m = Arc::new(ReentrantMutex::new(()));
|
||||||
let m2 = m.clone();
|
let m2 = m.clone();
|
||||||
let lock = m.try_lock().unwrap();
|
let _lock = m.try_lock().unwrap();
|
||||||
let lock2 = m.try_lock().unwrap();
|
let _lock2 = m.try_lock().unwrap();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let lock = m2.try_lock();
|
let lock = m2.try_lock();
|
||||||
assert!(lock.is_err());
|
assert!(lock.is_err());
|
||||||
}).join().unwrap();
|
}).join().unwrap();
|
||||||
let lock3 = m.try_lock().unwrap();
|
let _lock3 = m.try_lock().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell<u32>>);
|
pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell<u32>>);
|
||||||
|
@ -233,9 +232,8 @@ mod tests {
|
||||||
*lock.borrow_mut() = 1;
|
*lock.borrow_mut() = 1;
|
||||||
let lock2 = mc.lock().unwrap();
|
let lock2 = mc.lock().unwrap();
|
||||||
*lock.borrow_mut() = 2;
|
*lock.borrow_mut() = 2;
|
||||||
let answer = Answer(lock2);
|
let _answer = Answer(lock2);
|
||||||
panic!("What the answer to my lifetimes dilemma is?");
|
panic!("What the answer to my lifetimes dilemma is?");
|
||||||
drop(answer);
|
|
||||||
}).join();
|
}).join();
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
let r = m.lock().err().unwrap().into_inner();
|
let r = m.lock().err().unwrap().into_inner();
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn wtf8buf_show_str() {
|
fn wtf8buf_show_str() {
|
||||||
let text = "a\té 💩\r";
|
let text = "a\té 💩\r";
|
||||||
let mut string = Wtf8Buf::from_str(text);
|
let string = Wtf8Buf::from_str(text);
|
||||||
assert_eq!(format!("{:?}", text), format!("{:?}", string));
|
assert_eq!(format!("{:?}", text), format!("{:?}", string));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub mod thread_local;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod stdio;
|
pub mod stdio;
|
||||||
|
|
||||||
#[cfg(not(target_os = "nacl"))]
|
#[cfg(not(any(target_os = "nacl", test)))]
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
use libc::signal;
|
use libc::signal;
|
||||||
// By default, some platforms will send a *signal* when an EPIPE error
|
// By default, some platforms will send a *signal* when an EPIPE error
|
||||||
|
@ -59,7 +59,8 @@ pub fn init() {
|
||||||
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0);
|
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "nacl")]
|
|
||||||
|
#[cfg(all(target_os = "nacl", not(test)))]
|
||||||
pub fn init() { }
|
pub fn init() { }
|
||||||
|
|
||||||
pub fn decode_error_kind(errno: i32) -> ErrorKind {
|
pub fn decode_error_kind(errno: i32) -> ErrorKind {
|
||||||
|
|
|
@ -462,8 +462,7 @@ mod tests {
|
||||||
use mem;
|
use mem;
|
||||||
use ptr;
|
use ptr;
|
||||||
use libc;
|
use libc;
|
||||||
use slice;
|
use sys::{self, cvt};
|
||||||
use sys::{self, cvt, pipe};
|
|
||||||
|
|
||||||
macro_rules! t {
|
macro_rules! t {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
|
@ -482,6 +481,8 @@ mod tests {
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int {
|
unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int {
|
||||||
|
use slice;
|
||||||
|
|
||||||
let raw = slice::from_raw_parts_mut(set as *mut u8, mem::size_of::<libc::sigset_t>());
|
let raw = slice::from_raw_parts_mut(set as *mut u8, mem::size_of::<libc::sigset_t>());
|
||||||
let bit = (signum - 1) as usize;
|
let bit = (signum - 1) as usize;
|
||||||
raw[bit / 8] |= 1 << (bit % 8);
|
raw[bit / 8] |= 1 << (bit % 8);
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![cfg_attr(test, allow(dead_code))]
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
use self::imp::{make_handler, drop_handler};
|
use self::imp::{make_handler, drop_handler};
|
||||||
|
|
||||||
pub use self::imp::{init, cleanup};
|
pub use self::imp::cleanup;
|
||||||
|
pub use self::imp::init;
|
||||||
|
|
||||||
pub struct Handler {
|
pub struct Handler {
|
||||||
_data: *mut libc::c_void
|
_data: *mut libc::c_void
|
||||||
|
@ -40,12 +42,11 @@ impl Drop for Handler {
|
||||||
target_os = "openbsd"))]
|
target_os = "openbsd"))]
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::Handler;
|
use super::Handler;
|
||||||
use sys_common::util::report_overflow;
|
|
||||||
use mem;
|
use mem;
|
||||||
use ptr;
|
use ptr;
|
||||||
|
use libc::{sigaltstack, SIGSTKSZ};
|
||||||
use libc::{sigaction, SIGBUS, SIG_DFL,
|
use libc::{sigaction, SIGBUS, SIG_DFL,
|
||||||
SA_SIGINFO, SA_ONSTACK, sigaltstack,
|
SA_SIGINFO, SA_ONSTACK, sighandler_t};
|
||||||
SIGSTKSZ, sighandler_t};
|
|
||||||
use libc;
|
use libc;
|
||||||
use libc::{mmap, munmap};
|
use libc::{mmap, munmap};
|
||||||
use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON};
|
use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON};
|
||||||
|
@ -94,6 +95,8 @@ mod imp {
|
||||||
unsafe extern fn signal_handler(signum: libc::c_int,
|
unsafe extern fn signal_handler(signum: libc::c_int,
|
||||||
info: *mut libc::siginfo_t,
|
info: *mut libc::siginfo_t,
|
||||||
_data: *mut libc::c_void) {
|
_data: *mut libc::c_void) {
|
||||||
|
use sys_common::util::report_overflow;
|
||||||
|
|
||||||
let guard = thread_info::stack_guard().unwrap_or(0);
|
let guard = thread_info::stack_guard().unwrap_or(0);
|
||||||
let addr = siginfo_si_addr(info) as usize;
|
let addr = siginfo_si_addr(info) as usize;
|
||||||
|
|
||||||
|
|
|
@ -830,14 +830,14 @@ mod tests {
|
||||||
fn test_park_timeout_unpark_before() {
|
fn test_park_timeout_unpark_before() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
thread::current().unpark();
|
thread::current().unpark();
|
||||||
thread::park_timeout_ms(u32::MAX);
|
thread::park_timeout(Duration::from_millis(u32::MAX as u64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_park_timeout_unpark_not_called() {
|
fn test_park_timeout_unpark_not_called() {
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
thread::park_timeout_ms(10);
|
thread::park_timeout(Duration::from_millis(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,17 +847,17 @@ mod tests {
|
||||||
let th = thread::current();
|
let th = thread::current();
|
||||||
|
|
||||||
let _guard = thread::spawn(move || {
|
let _guard = thread::spawn(move || {
|
||||||
super::sleep_ms(50);
|
super::sleep(Duration::from_millis(50));
|
||||||
th.unpark();
|
th.unpark();
|
||||||
});
|
});
|
||||||
|
|
||||||
thread::park_timeout_ms(u32::MAX);
|
thread::park_timeout(Duration::from_millis(u32::MAX as u64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sleep_ms_smoke() {
|
fn sleep_ms_smoke() {
|
||||||
thread::sleep_ms(2);
|
thread::sleep(Duration::from_millis(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: the corresponding test for stderr is in run-pass/thread-stderr, due
|
// NOTE: the corresponding test for stderr is in run-pass/thread-stderr, due
|
||||||
|
|
|
@ -173,7 +173,6 @@ impl Div<u32> for Duration {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use prelude::v1::*;
|
|
||||||
use super::Duration;
|
use super::Duration;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue