forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libtest] Run the test synchronously when hitting thread limit
- Loading branch information
hyd-dev
committed
Feb 17, 2021
1 parent
099f27b
commit 43aed74
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![feature(once_cell)] | ||
|
||
use std::{io::ErrorKind, lazy::SyncOnceCell, thread::{self, Builder, ThreadId}}; | ||
|
||
static THREAD_ID: SyncOnceCell<ThreadId> = SyncOnceCell::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()); | ||
} |