diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/run-make/libtest-thread-limit | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/libtest-thread-limit')
-rw-r--r-- | tests/run-make/libtest-thread-limit/Makefile | 7 | ||||
-rw-r--r-- | tests/run-make/libtest-thread-limit/test.rs | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/run-make/libtest-thread-limit/Makefile b/tests/run-make/libtest-thread-limit/Makefile new file mode 100644 index 000000000..d43a89e60 --- /dev/null +++ b/tests/run-make/libtest-thread-limit/Makefile @@ -0,0 +1,7 @@ +include ../../run-make-fulldeps/tools.mk + +# only-linux + +all: + $(RUSTC) test.rs --test --target $(TARGET) + $(shell ulimit -p 0 && $(call RUN,test)) diff --git a/tests/run-make/libtest-thread-limit/test.rs b/tests/run-make/libtest-thread-limit/test.rs new file mode 100644 index 000000000..26bc29216 --- /dev/null +++ b/tests/run-make/libtest-thread-limit/test.rs @@ -0,0 +1,20 @@ +#![feature(once_cell)] + +use std::{ + io::ErrorKind, + sync::OnceLock, + thread::{self, Builder, ThreadId}, +}; + +static THREAD_ID: OnceLock<ThreadId> = OnceLock::new(); + +#[test] +fn spawn_thread_would_block() { + assert_eq!(Builder::new().spawn(|| unreachable!()).unwrap_err().kind(), ErrorKind::WouldBlock); + THREAD_ID.set(thread::current().id()).unwrap(); +} + +#[test] +fn run_in_same_thread() { + assert_eq!(*THREAD_ID.get().unwrap(), thread::current().id()); +} |