diff options
author | 2019-11-13 14:55:25 -0800 | |
---|---|---|
committer | 2019-11-13 14:55:25 -0800 | |
commit | 9a10addb444314f48ddae96958e7b0951b907012 (patch) | |
tree | 85548001dcda3263c0675b633390abf229797895 /tests | |
parent | b32f6298e289958986b68982788562f3c097f8fc (diff) | |
download | bytes-9a10addb444314f48ddae96958e7b0951b907012.tar.gz bytes-9a10addb444314f48ddae96958e7b0951b907012.tar.zst bytes-9a10addb444314f48ddae96958e7b0951b907012.zip |
Change loom tests to use cfg(loom) internally (#314)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fuzz_bytes.rs | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/tests/fuzz_bytes.rs b/tests/fuzz_bytes.rs deleted file mode 100644 index 5f894dd..0000000 --- a/tests/fuzz_bytes.rs +++ /dev/null @@ -1,73 +0,0 @@ -// pretend to like `crate::` -extern crate alloc; -#[path = "../src/buf/mod.rs"] -#[allow(warnings)] -mod buf; -#[path = "../src/debug.rs"] -#[allow(warnings)] -mod debug; -#[path = "../src/bytes.rs"] -#[allow(warnings)] -mod bytes; -#[path = "../src/bytes_mut.rs"] -#[allow(warnings)] -mod bytes_mut; -use std::process::abort; - -use self::buf::{Buf, BufMut}; -use self::bytes::Bytes; -use self::bytes_mut::BytesMut; - -use std::sync::Arc; -use loom; -use loom::thread; - -#[test] -fn bytes_cloning_vec() { - loom::model(|| { - let a = Bytes::from(b"abcdefgh".to_vec()); - let addr = a.as_ptr() as usize; - - // test the Bytes::clone is Sync by putting it in an Arc - let a1 = Arc::new(a); - let a2 = a1.clone(); - - let t1 = thread::spawn(move || { - let b: Bytes = (*a1).clone(); - assert_eq!(b.as_ptr() as usize, addr); - }); - - let t2 = thread::spawn(move || { - let b: Bytes = (*a2).clone(); - assert_eq!(b.as_ptr() as usize, addr); - }); - - t1.join().unwrap(); - t2.join().unwrap(); - }); -} - -#[test] -fn bytes_mut_cloning_frozen() { - loom::model(|| { - let a = BytesMut::from(&b"abcdefgh"[..]).split().freeze(); - let addr = a.as_ptr() as usize; - - // test the Bytes::clone is Sync by putting it in an Arc - let a1 = Arc::new(a); - let a2 = a1.clone(); - - let t1 = thread::spawn(move || { - let b: Bytes = (*a1).clone(); - assert_eq!(b.as_ptr() as usize, addr); - }); - - let t2 = thread::spawn(move || { - let b: Bytes = (*a2).clone(); - assert_eq!(b.as_ptr() as usize, addr); - }); - - t1.join().unwrap(); - t2.join().unwrap(); - }); -} |