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