diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/rustc-rayon/tests | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustc-rayon/tests')
-rw-r--r-- | vendor/rustc-rayon/tests/clones.rs | 26 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/collect.rs | 2 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/cross-pool.rs | 1 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/debug.rs | 6 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/drain_vec.rs | 41 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/iter_panic.rs | 3 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/named-threads.rs | 1 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/octillion.rs | 32 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/par_bridge_recursion.rs | 31 | ||||
-rw-r--r-- | vendor/rustc-rayon/tests/sort-panic-safe.rs | 10 |
10 files changed, 143 insertions, 10 deletions
diff --git a/vendor/rustc-rayon/tests/clones.rs b/vendor/rustc-rayon/tests/clones.rs index 2f512ca05..0d6c86487 100644 --- a/vendor/rustc-rayon/tests/clones.rs +++ b/vendor/rustc-rayon/tests/clones.rs @@ -10,6 +10,13 @@ where assert_eq!(a, b); } +fn check_count<I>(iter: I) +where + I: ParallelIterator + Clone, +{ + assert_eq!(iter.clone().count(), iter.count()); +} + #[test] fn clone_binary_heap() { use std::collections::BinaryHeap; @@ -130,6 +137,12 @@ fn clone_adaptors() { check(v.par_iter().flatten_iter()); check(v.par_iter().with_max_len(1).fold(|| 0, |x, _| x)); check(v.par_iter().with_max_len(1).fold_with(0, |x, _| x)); + check(v.par_iter().with_max_len(1).fold_chunks(1, || 0, |x, _| x)); + check( + v.par_iter() + .with_max_len(1) + .fold_chunks_with(1, 0, |x, _| x), + ); check(v.par_iter().with_max_len(1).try_fold(|| 0, |_, &x| x)); check(v.par_iter().with_max_len(1).try_fold_with(0, |_, &x| x)); check(v.par_iter().inspect(|_| ())); @@ -144,8 +157,10 @@ fn clone_adaptors() { check(v.par_iter().panic_fuse()); check(v.par_iter().positions(|_| true)); check(v.par_iter().rev()); - check(v.par_iter().skip(1)); - check(v.par_iter().take(1)); + check(v.par_iter().skip(42)); + check(v.par_iter().skip_any_while(|_| false)); + check(v.par_iter().take(42)); + check(v.par_iter().take_any_while(|_| true)); check(v.par_iter().cloned().while_some()); check(v.par_iter().with_max_len(1)); check(v.par_iter().with_min_len(1)); @@ -155,6 +170,13 @@ fn clone_adaptors() { } #[test] +fn clone_counted_adaptors() { + let v: Vec<_> = (0..1000).collect(); + check_count(v.par_iter().skip_any(42)); + check_count(v.par_iter().take_any(42)); +} + +#[test] fn clone_empty() { check(rayon::iter::empty::<i32>()); } diff --git a/vendor/rustc-rayon/tests/collect.rs b/vendor/rustc-rayon/tests/collect.rs index 48b80f699..bfb080ceb 100644 --- a/vendor/rustc-rayon/tests/collect.rs +++ b/vendor/rustc-rayon/tests/collect.rs @@ -6,6 +6,7 @@ use std::sync::atomic::Ordering; use std::sync::Mutex; #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn collect_drop_on_unwind() { struct Recorddrop<'a>(i64, &'a Mutex<Vec<i64>>); @@ -61,6 +62,7 @@ fn collect_drop_on_unwind() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn collect_drop_on_unwind_zst() { static INSERTS: AtomicUsize = AtomicUsize::new(0); static DROPS: AtomicUsize = AtomicUsize::new(0); diff --git a/vendor/rustc-rayon/tests/cross-pool.rs b/vendor/rustc-rayon/tests/cross-pool.rs index f0a2128a7..835e2e27f 100644 --- a/vendor/rustc-rayon/tests/cross-pool.rs +++ b/vendor/rustc-rayon/tests/cross-pool.rs @@ -2,6 +2,7 @@ use rayon::prelude::*; use rayon::ThreadPoolBuilder; #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn cross_pool_busy() { let pool1 = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); let pool2 = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); diff --git a/vendor/rustc-rayon/tests/debug.rs b/vendor/rustc-rayon/tests/debug.rs index d107b1377..14f37917b 100644 --- a/vendor/rustc-rayon/tests/debug.rs +++ b/vendor/rustc-rayon/tests/debug.rs @@ -155,6 +155,8 @@ fn debug_adaptors() { check(v.par_iter().map(Some).flatten_iter()); check(v.par_iter().fold(|| 0, |x, _| x)); check(v.par_iter().fold_with(0, |x, _| x)); + check(v.par_iter().fold_chunks(3, || 0, |x, _| x)); + check(v.par_iter().fold_chunks_with(3, 0, |x, _| x)); check(v.par_iter().try_fold(|| 0, |x, _| Some(x))); check(v.par_iter().try_fold_with(0, |x, _| Some(x))); check(v.par_iter().inspect(|_| ())); @@ -170,7 +172,11 @@ fn debug_adaptors() { check(v.par_iter().positions(|_| true)); check(v.par_iter().rev()); check(v.par_iter().skip(1)); + check(v.par_iter().skip_any(1)); + check(v.par_iter().skip_any_while(|_| false)); check(v.par_iter().take(1)); + check(v.par_iter().take_any(1)); + check(v.par_iter().take_any_while(|_| true)); check(v.par_iter().map(Some).while_some()); check(v.par_iter().with_max_len(1)); check(v.par_iter().with_min_len(1)); diff --git a/vendor/rustc-rayon/tests/drain_vec.rs b/vendor/rustc-rayon/tests/drain_vec.rs new file mode 100644 index 000000000..08f1120b7 --- /dev/null +++ b/vendor/rustc-rayon/tests/drain_vec.rs @@ -0,0 +1,41 @@ +use rayon::prelude::*; + +#[test] +fn drain_vec_yielded() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(0..5).collect::<Vec<_>>(); + + assert_eq!(&yielded, &[0, 1, 2, 3, 4]); + assert_eq!(&vec_org, &[5, 6, 7, 8, 9]); +} + +#[test] +fn drain_vec_dropped() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(0..5); + + drop(yielded); + assert_eq!(&vec_org, &[5, 6, 7, 8, 9]); +} + +#[test] +fn drain_vec_empty_range_yielded() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(5..5).collect::<Vec<_>>(); + + assert_eq!(&yielded, &[]); + assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); +} + +#[test] +fn drain_vec_empty_range_dropped() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(5..5); + + drop(yielded); + assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); +} diff --git a/vendor/rustc-rayon/tests/iter_panic.rs b/vendor/rustc-rayon/tests/iter_panic.rs index 4885a28be..c62a8dbda 100644 --- a/vendor/rustc-rayon/tests/iter_panic.rs +++ b/vendor/rustc-rayon/tests/iter_panic.rs @@ -20,6 +20,7 @@ fn iter_panic() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn iter_panic_fuse() { // We only use a single thread in order to make the behavior // of 'panic_fuse' deterministic @@ -47,6 +48,6 @@ fn iter_panic_fuse() { assert!(count(iter.clone().panic_fuse().inspect(check)) < expected); // Try in reverse to be sure we hit the producer case. - assert!(count(iter.clone().panic_fuse().inspect(check).rev()) < expected); + assert!(count(iter.panic_fuse().inspect(check).rev()) < expected); }); } diff --git a/vendor/rustc-rayon/tests/named-threads.rs b/vendor/rustc-rayon/tests/named-threads.rs index fd1b0be2d..dadb37ba6 100644 --- a/vendor/rustc-rayon/tests/named-threads.rs +++ b/vendor/rustc-rayon/tests/named-threads.rs @@ -4,6 +4,7 @@ use rayon::prelude::*; use rayon::*; #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn named_threads() { ThreadPoolBuilder::new() .thread_name(|i| format!("hello-name-test-{}", i)) diff --git a/vendor/rustc-rayon/tests/octillion.rs b/vendor/rustc-rayon/tests/octillion.rs index cff2b1192..1af9ad8ba 100644 --- a/vendor/rustc-rayon/tests/octillion.rs +++ b/vendor/rustc-rayon/tests/octillion.rs @@ -68,7 +68,14 @@ fn two_threads<F: Send + FnOnce() -> R, R: Send>(f: F) -> R { } #[test] -#[cfg_attr(not(target_pointer_width = "64"), ignore)] +#[cfg_attr( + any( + not(target_pointer_width = "64"), + target_os = "emscripten", + target_family = "wasm" + ), + ignore +)] fn find_last_octillion() { // It would be nice if `find_last` could prioritize the later splits, // basically flipping the `join` args, without needing indexed `rev`. @@ -78,32 +85,49 @@ fn find_last_octillion() { } #[test] -#[cfg_attr(not(target_pointer_width = "64"), ignore)] +#[cfg_attr( + any( + not(target_pointer_width = "64"), + target_os = "emscripten", + target_family = "wasm" + ), + ignore +)] fn find_last_octillion_inclusive() { let x = two_threads(|| octillion_inclusive().find_last(|_| true)); assert_eq!(x, Some(OCTILLION)); } #[test] -#[cfg_attr(not(target_pointer_width = "64"), ignore)] +#[cfg_attr( + any( + not(target_pointer_width = "64"), + target_os = "emscripten", + target_family = "wasm" + ), + ignore +)] fn find_last_octillion_flat() { let x = two_threads(|| octillion_flat().find_last(|_| true)); assert_eq!(x, Some(OCTILLION - 1)); } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn find_any_octillion() { let x = two_threads(|| octillion().find_any(|x| *x > OCTILLION / 2)); assert!(x.is_some()); } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn find_any_octillion_flat() { let x = two_threads(|| octillion_flat().find_any(|x| *x > OCTILLION / 2)); assert!(x.is_some()); } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn filter_find_any_octillion() { let x = two_threads(|| { octillion() @@ -114,6 +138,7 @@ fn filter_find_any_octillion() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn filter_find_any_octillion_flat() { let x = two_threads(|| { octillion_flat() @@ -124,6 +149,7 @@ fn filter_find_any_octillion_flat() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn fold_find_any_octillion_flat() { let x = two_threads(|| octillion_flat().fold(|| (), |_, _| ()).find_any(|_| true)); assert!(x.is_some()); diff --git a/vendor/rustc-rayon/tests/par_bridge_recursion.rs b/vendor/rustc-rayon/tests/par_bridge_recursion.rs new file mode 100644 index 000000000..3a48ef143 --- /dev/null +++ b/vendor/rustc-rayon/tests/par_bridge_recursion.rs @@ -0,0 +1,31 @@ +use rayon::prelude::*; +use std::iter::once_with; + +const N: usize = 100_000; + +#[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] +fn par_bridge_recursion() { + let pool = rayon::ThreadPoolBuilder::new() + .num_threads(10) + .build() + .unwrap(); + + let seq: Vec<_> = (0..N).map(|i| (i, i.to_string())).collect(); + + pool.broadcast(|_| { + let mut par: Vec<_> = (0..N) + .into_par_iter() + .flat_map(|i| { + once_with(move || { + // Using rayon within the serial iterator creates an opportunity for + // work-stealing to make par_bridge's mutex accidentally recursive. + rayon::join(move || i, move || i.to_string()) + }) + .par_bridge() + }) + .collect(); + par.par_sort_unstable(); + assert_eq!(seq, par); + }); +} diff --git a/vendor/rustc-rayon/tests/sort-panic-safe.rs b/vendor/rustc-rayon/tests/sort-panic-safe.rs index 00a973106..95ef88d39 100644 --- a/vendor/rustc-rayon/tests/sort-panic-safe.rs +++ b/vendor/rustc-rayon/tests/sort-panic-safe.rs @@ -8,11 +8,12 @@ use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::Relaxed; use std::thread; -static VERSIONS: AtomicUsize = AtomicUsize::new(0); +const ZERO: AtomicUsize = AtomicUsize::new(0); +const LEN: usize = 20_000; -lazy_static::lazy_static! { - static ref DROP_COUNTS: Vec<AtomicUsize> = (0..20_000).map(|_| AtomicUsize::new(0)).collect(); -} +static VERSIONS: AtomicUsize = ZERO; + +static DROP_COUNTS: [AtomicUsize; LEN] = [ZERO; LEN]; #[derive(Clone, Eq)] struct DropCounter { @@ -117,6 +118,7 @@ macro_rules! test { thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false)); #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn sort_panic_safe() { let prev = panic::take_hook(); panic::set_hook(Box::new(move |info| { |