diff options
| author | bors <bors@rust-lang.org> | 2019-08-02 15:22:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-08-02 15:22:50 +0000 |
| commit | cf048cc115860cc110865f460f3f2b9b4308ad92 (patch) | |
| tree | 883bd4b5406aa47155d362bbadfe0b6f3d795793 /src/liballoc/alloc | |
| parent | 1df512fcaeaf17639c5d28a3045814d6f7a7db97 (diff) | |
| parent | 62ec2cb7acb1b16d0abd8a2cf40da545a13d29f3 (diff) | |
| download | rust-cf048cc115860cc110865f460f3f2b9b4308ad92.tar.gz rust-cf048cc115860cc110865f460f3f2b9b4308ad92.zip | |
Auto merge of #63207 - petrochenkov:outest2, r=Mark-Simulacrum
Unconfigure compiler unit test files during normal build I haven't touched libstd though, it had a lot of tests and I'm not sure the people maintaining it want this. Closes https://github.com/rust-lang/rust/issues/61097 r? @Mark-Simulacrum
Diffstat (limited to 'src/liballoc/alloc')
| -rw-r--r-- | src/liballoc/alloc/tests.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/liballoc/alloc/tests.rs b/src/liballoc/alloc/tests.rs new file mode 100644 index 00000000000..c69f4e49ee1 --- /dev/null +++ b/src/liballoc/alloc/tests.rs @@ -0,0 +1,30 @@ +use super::*; + +extern crate test; +use test::Bencher; +use crate::boxed::Box; + +#[test] +fn allocate_zeroed() { + unsafe { + let layout = Layout::from_size_align(1024, 1).unwrap(); + let ptr = Global.alloc_zeroed(layout.clone()) + .unwrap_or_else(|_| handle_alloc_error(layout)); + + let mut i = ptr.cast::<u8>().as_ptr(); + let end = i.add(layout.size()); + while i < end { + assert_eq!(*i, 0); + i = i.offset(1); + } + Global.dealloc(ptr, layout); + } +} + +#[bench] +#[cfg(not(miri))] // Miri does not support benchmarks +fn alloc_owned_small(b: &mut Bencher) { + b.iter(|| { + let _: Box<_> = box 10; + }) +} |
