summaryrefslogtreecommitdiffstats
path: root/vendor/rustc-rayon-core/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/rustc-rayon-core/tests
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-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-core/tests')
-rw-r--r--vendor/rustc-rayon-core/tests/double_init_fail.rs3
-rw-r--r--vendor/rustc-rayon-core/tests/init_zero_threads.rs1
-rw-r--r--vendor/rustc-rayon-core/tests/scoped_threadpool.rs3
-rw-r--r--vendor/rustc-rayon-core/tests/stack_overflow_crash.rs95
4 files changed, 61 insertions, 41 deletions
diff --git a/vendor/rustc-rayon-core/tests/double_init_fail.rs b/vendor/rustc-rayon-core/tests/double_init_fail.rs
index ea06bf0e1..15915304d 100644
--- a/vendor/rustc-rayon-core/tests/double_init_fail.rs
+++ b/vendor/rustc-rayon-core/tests/double_init_fail.rs
@@ -2,9 +2,10 @@ use rayon_core::ThreadPoolBuilder;
use std::error::Error;
#[test]
+#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn double_init_fail() {
let result1 = ThreadPoolBuilder::new().build_global();
- assert_eq!(result1.unwrap(), ());
+ assert!(result1.is_ok());
let err = ThreadPoolBuilder::new().build_global().unwrap_err();
assert!(err.source().is_none());
assert_eq!(
diff --git a/vendor/rustc-rayon-core/tests/init_zero_threads.rs b/vendor/rustc-rayon-core/tests/init_zero_threads.rs
index ebd73c585..3c1ad251c 100644
--- a/vendor/rustc-rayon-core/tests/init_zero_threads.rs
+++ b/vendor/rustc-rayon-core/tests/init_zero_threads.rs
@@ -1,6 +1,7 @@
use rayon_core::ThreadPoolBuilder;
#[test]
+#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn init_zero_threads() {
ThreadPoolBuilder::new()
.num_threads(0)
diff --git a/vendor/rustc-rayon-core/tests/scoped_threadpool.rs b/vendor/rustc-rayon-core/tests/scoped_threadpool.rs
index db3d0b874..534e8bbf4 100644
--- a/vendor/rustc-rayon-core/tests/scoped_threadpool.rs
+++ b/vendor/rustc-rayon-core/tests/scoped_threadpool.rs
@@ -7,6 +7,7 @@ struct Local(i32);
scoped_tls::scoped_thread_local!(static LOCAL: Local);
#[test]
+#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn missing_scoped_tls() {
LOCAL.set(&Local(42), || {
let pool = ThreadPoolBuilder::new()
@@ -21,6 +22,7 @@ fn missing_scoped_tls() {
}
#[test]
+#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn spawn_scoped_tls_threadpool() {
LOCAL.set(&Local(42), || {
LOCAL.with(|x| {
@@ -63,6 +65,7 @@ fn spawn_scoped_tls_threadpool() {
}
#[test]
+#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn build_scoped_tls_threadpool() {
LOCAL.set(&Local(42), || {
LOCAL.with(|x| {
diff --git a/vendor/rustc-rayon-core/tests/stack_overflow_crash.rs b/vendor/rustc-rayon-core/tests/stack_overflow_crash.rs
index 61288982c..7dcde43c4 100644
--- a/vendor/rustc-rayon-core/tests/stack_overflow_crash.rs
+++ b/vendor/rustc-rayon-core/tests/stack_overflow_crash.rs
@@ -1,13 +1,14 @@
use rayon_core::ThreadPoolBuilder;
use std::env;
-use std::process::Command;
+use std::process::{Command, ExitStatus, Stdio};
#[cfg(target_os = "linux")]
use std::os::unix::process::ExitStatusExt;
fn force_stack_overflow(depth: u32) {
- let _buffer = [0u8; 1024 * 1024];
+ let mut buffer = [0u8; 1024 * 1024];
+ std::hint::black_box(&mut buffer);
if depth > 0 {
force_stack_overflow(depth - 1);
}
@@ -34,49 +35,63 @@ fn overflow_code() -> Option<i32> {
#[cfg(windows)]
fn overflow_code() -> Option<i32> {
use std::os::windows::process::ExitStatusExt;
- use std::process::ExitStatus;
ExitStatus::from_raw(0xc00000fd /*STATUS_STACK_OVERFLOW*/).code()
}
-fn main() {
- if env::args().len() == 1 {
- // first check that the recursivecall actually causes a stack overflow, and does not get optimized away
- {
- let status = Command::new(env::current_exe().unwrap())
- .arg("8")
- .status()
- .unwrap();
+#[test]
+#[cfg_attr(not(any(unix, windows)), ignore)]
+fn stack_overflow_crash() {
+ // First check that the recursive call actually causes a stack overflow,
+ // and does not get optimized away.
+ let status = run_ignored("run_with_small_stack");
+ assert!(!status.success());
+ #[cfg(any(unix, windows))]
+ assert_eq!(status.code(), overflow_code());
+ #[cfg(target_os = "linux")]
+ assert!(matches!(
+ status.signal(),
+ Some(libc::SIGABRT | libc::SIGSEGV)
+ ));
- #[cfg(any(unix, windows))]
- assert_eq!(status.code(), overflow_code());
+ // Now run with a larger stack and verify correct operation.
+ let status = run_ignored("run_with_large_stack");
+ assert_eq!(status.code(), Some(0));
+ #[cfg(target_os = "linux")]
+ assert_eq!(status.signal(), None);
+}
- #[cfg(target_os = "linux")]
- assert!(
- status.signal() == Some(11 /*SIGABRT*/) || status.signal() == Some(6 /*SIGSEGV*/)
- );
- }
+fn run_ignored(test: &str) -> ExitStatus {
+ Command::new(env::current_exe().unwrap())
+ .arg("--ignored")
+ .arg("--exact")
+ .arg(test)
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status()
+ .unwrap()
+}
- // now run with a larger stack and verify correct operation
- {
- let status = Command::new(env::current_exe().unwrap())
- .arg("48")
- .status()
- .unwrap();
- assert_eq!(status.code(), Some(0));
- #[cfg(target_os = "linux")]
- assert_eq!(status.signal(), None);
- }
- } else {
- let stack_size_in_mb: usize = env::args().nth(1).unwrap().parse().unwrap();
- let pool = ThreadPoolBuilder::new()
- .stack_size(stack_size_in_mb * 1024 * 1024)
- .build()
- .unwrap();
- pool.install(|| {
- #[cfg(unix)]
- disable_core();
- force_stack_overflow(32);
- });
- }
+#[test]
+#[ignore]
+fn run_with_small_stack() {
+ run_with_stack(8);
+}
+
+#[test]
+#[ignore]
+fn run_with_large_stack() {
+ run_with_stack(48);
+}
+
+fn run_with_stack(stack_size_in_mb: usize) {
+ let pool = ThreadPoolBuilder::new()
+ .stack_size(stack_size_in_mb * 1024 * 1024)
+ .build()
+ .unwrap();
+ pool.install(|| {
+ #[cfg(unix)]
+ disable_core();
+ force_stack_overflow(32);
+ });
}