From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/run-make/libtest-thread-limit/Makefile | 7 +++++++ tests/run-make/libtest-thread-limit/test.rs | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/run-make/libtest-thread-limit/Makefile create mode 100644 tests/run-make/libtest-thread-limit/test.rs (limited to 'tests/run-make/libtest-thread-limit') 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 = 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()); +} -- cgit v1.2.3