diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-27 01:33:01 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-27 18:56:16 +0300 |
| commit | 9be35f82c1abf2ecbab489bca9eca138ea648312 (patch) | |
| tree | 69888506e34af447d9748c0d542de3ba1dd76210 /src/test/run-pass/allocator | |
| parent | ca9faa52f5ada0054b1fa27d97aedf448afb059b (diff) | |
| download | rust-9be35f82c1abf2ecbab489bca9eca138ea648312.tar.gz rust-9be35f82c1abf2ecbab489bca9eca138ea648312.zip | |
tests: Move run-pass tests without naming conflicts to ui
Diffstat (limited to 'src/test/run-pass/allocator')
| -rw-r--r-- | src/test/run-pass/allocator/auxiliary/custom-as-global.rs | 16 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/auxiliary/custom.rs | 21 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/auxiliary/helper.rs | 9 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/custom-in-block.rs | 22 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/custom-in-submodule.rs | 26 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/custom.rs | 58 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/xcrate-use.rs | 35 | ||||
| -rw-r--r-- | src/test/run-pass/allocator/xcrate-use2.rs | 47 |
8 files changed, 0 insertions, 234 deletions
diff --git a/src/test/run-pass/allocator/auxiliary/custom-as-global.rs b/src/test/run-pass/allocator/auxiliary/custom-as-global.rs deleted file mode 100644 index a5e96e77501..00000000000 --- a/src/test/run-pass/allocator/auxiliary/custom-as-global.rs +++ /dev/null @@ -1,16 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] - -extern crate custom; - -use std::sync::atomic::{AtomicUsize, Ordering}; - -use custom::A; - -#[global_allocator] -static ALLOCATOR: A = A(AtomicUsize::new(0)); - -pub fn get() -> usize { - ALLOCATOR.0.load(Ordering::SeqCst) -} diff --git a/src/test/run-pass/allocator/auxiliary/custom.rs b/src/test/run-pass/allocator/auxiliary/custom.rs deleted file mode 100644 index b0ec9ab0929..00000000000 --- a/src/test/run-pass/allocator/auxiliary/custom.rs +++ /dev/null @@ -1,21 +0,0 @@ -// no-prefer-dynamic - -#![feature(allocator_api)] -#![crate_type = "rlib"] - -use std::alloc::{GlobalAlloc, System, Layout}; -use std::sync::atomic::{AtomicUsize, Ordering}; - -pub struct A(pub AtomicUsize); - -unsafe impl GlobalAlloc for A { - unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - self.0.fetch_add(1, Ordering::SeqCst); - System.alloc(layout) - } - - unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - self.0.fetch_add(1, Ordering::SeqCst); - System.dealloc(ptr, layout) - } -} diff --git a/src/test/run-pass/allocator/auxiliary/helper.rs b/src/test/run-pass/allocator/auxiliary/helper.rs deleted file mode 100644 index 7f6770c226a..00000000000 --- a/src/test/run-pass/allocator/auxiliary/helper.rs +++ /dev/null @@ -1,9 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] - -use std::fmt; - -pub fn work_with(p: &fmt::Debug) { - drop(p); -} diff --git a/src/test/run-pass/allocator/custom-in-block.rs b/src/test/run-pass/allocator/custom-in-block.rs deleted file mode 100644 index 12813a1fc8b..00000000000 --- a/src/test/run-pass/allocator/custom-in-block.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -// no-prefer-dynamic -// aux-build:custom.rs -// aux-build:helper.rs - -extern crate custom; -extern crate helper; - -use custom::A; -use std::sync::atomic::{AtomicUsize, Ordering}; - -fn main() { - #[global_allocator] - pub static GLOBAL: A = A(AtomicUsize::new(0)); - - let n = GLOBAL.0.load(Ordering::SeqCst); - let s = Box::new(0); - helper::work_with(&s); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 1); - drop(s); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); -} diff --git a/src/test/run-pass/allocator/custom-in-submodule.rs b/src/test/run-pass/allocator/custom-in-submodule.rs deleted file mode 100644 index ea341b1ac14..00000000000 --- a/src/test/run-pass/allocator/custom-in-submodule.rs +++ /dev/null @@ -1,26 +0,0 @@ -// run-pass -// no-prefer-dynamic -// aux-build:custom.rs -// aux-build:helper.rs - -extern crate custom; -extern crate helper; - -use custom::A; -use std::sync::atomic::{AtomicUsize, Ordering}; - -mod submodule { - use super::*; - - #[global_allocator] - pub static GLOBAL: A = A(AtomicUsize::new(0)); -} - -fn main() { - let n = submodule::GLOBAL.0.load(Ordering::SeqCst); - let s = Box::new(0); - helper::work_with(&s); - assert_eq!(submodule::GLOBAL.0.load(Ordering::SeqCst), n + 1); - drop(s); - assert_eq!(submodule::GLOBAL.0.load(Ordering::SeqCst), n + 2); -} diff --git a/src/test/run-pass/allocator/custom.rs b/src/test/run-pass/allocator/custom.rs deleted file mode 100644 index 71f72ae46c2..00000000000 --- a/src/test/run-pass/allocator/custom.rs +++ /dev/null @@ -1,58 +0,0 @@ -// run-pass - -// aux-build:helper.rs -// no-prefer-dynamic - -#![feature(allocator_api)] - -extern crate helper; - -use std::alloc::{self, Global, Alloc, System, Layout}; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static HITS: AtomicUsize = AtomicUsize::new(0); - -struct A; - -unsafe impl alloc::GlobalAlloc for A { - unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - HITS.fetch_add(1, Ordering::SeqCst); - System.alloc(layout) - } - - unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - HITS.fetch_add(1, Ordering::SeqCst); - System.dealloc(ptr, layout) - } -} - -#[global_allocator] -static GLOBAL: A = A; - -fn main() { - println!("hello!"); - - let n = HITS.load(Ordering::SeqCst); - assert!(n > 0); - unsafe { - let layout = Layout::from_size_align(4, 2).unwrap(); - - let ptr = Global.alloc(layout.clone()).unwrap(); - helper::work_with(&ptr); - assert_eq!(HITS.load(Ordering::SeqCst), n + 1); - Global.dealloc(ptr, layout.clone()); - assert_eq!(HITS.load(Ordering::SeqCst), n + 2); - - let s = String::with_capacity(10); - helper::work_with(&s); - assert_eq!(HITS.load(Ordering::SeqCst), n + 3); - drop(s); - assert_eq!(HITS.load(Ordering::SeqCst), n + 4); - - let ptr = System.alloc(layout.clone()).unwrap(); - assert_eq!(HITS.load(Ordering::SeqCst), n + 4); - helper::work_with(&ptr); - System.dealloc(ptr, layout); - assert_eq!(HITS.load(Ordering::SeqCst), n + 4); - } -} diff --git a/src/test/run-pass/allocator/xcrate-use.rs b/src/test/run-pass/allocator/xcrate-use.rs deleted file mode 100644 index 039c70e77be..00000000000 --- a/src/test/run-pass/allocator/xcrate-use.rs +++ /dev/null @@ -1,35 +0,0 @@ -// run-pass - -// aux-build:custom.rs -// aux-build:helper.rs -// no-prefer-dynamic - -#![feature(allocator_api)] - -extern crate custom; -extern crate helper; - -use std::alloc::{Global, Alloc, System, Layout}; -use std::sync::atomic::{Ordering, AtomicUsize}; - -#[global_allocator] -static GLOBAL: custom::A = custom::A(AtomicUsize::new(0)); - -fn main() { - unsafe { - let n = GLOBAL.0.load(Ordering::SeqCst); - let layout = Layout::from_size_align(4, 2).unwrap(); - - let ptr = Global.alloc(layout.clone()).unwrap(); - helper::work_with(&ptr); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 1); - Global.dealloc(ptr, layout.clone()); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); - - let ptr = System.alloc(layout.clone()).unwrap(); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); - helper::work_with(&ptr); - System.dealloc(ptr, layout); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); - } -} diff --git a/src/test/run-pass/allocator/xcrate-use2.rs b/src/test/run-pass/allocator/xcrate-use2.rs deleted file mode 100644 index d8478fb5eaa..00000000000 --- a/src/test/run-pass/allocator/xcrate-use2.rs +++ /dev/null @@ -1,47 +0,0 @@ -// run-pass - -// aux-build:custom.rs -// aux-build:custom-as-global.rs -// aux-build:helper.rs -// no-prefer-dynamic - -#![feature(allocator_api)] - -extern crate custom; -extern crate custom_as_global; -extern crate helper; - -use std::alloc::{alloc, dealloc, GlobalAlloc, System, Layout}; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static GLOBAL: custom::A = custom::A(AtomicUsize::new(0)); - -fn main() { - unsafe { - let n = custom_as_global::get(); - let layout = Layout::from_size_align(4, 2).unwrap(); - - // Global allocator routes to the `custom_as_global` global - let ptr = alloc(layout.clone()); - helper::work_with(&ptr); - assert_eq!(custom_as_global::get(), n + 1); - dealloc(ptr, layout.clone()); - assert_eq!(custom_as_global::get(), n + 2); - - // Usage of the system allocator avoids all globals - let ptr = System.alloc(layout.clone()); - helper::work_with(&ptr); - assert_eq!(custom_as_global::get(), n + 2); - System.dealloc(ptr, layout.clone()); - assert_eq!(custom_as_global::get(), n + 2); - - // Usage of our personal allocator doesn't affect other instances - let ptr = GLOBAL.alloc(layout.clone()); - helper::work_with(&ptr); - assert_eq!(custom_as_global::get(), n + 2); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 1); - GLOBAL.dealloc(ptr, layout); - assert_eq!(custom_as_global::get(), n + 2); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 2); - } -} |
