Skip to content

Commit 9e9ac1a

Browse files
committed
Add regression test for deadlocking rayon
1 parent 98c62d0 commit 9e9ac1a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ harness = false
2727
name = "large_image"
2828
harness = false
2929

30+
[[test]]
31+
name = "rayon"
32+
required-features = ["rayon"]
33+
3034
[features]
3135
default = ["rayon"]
3236
platform_independent = []

tests/rayon.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use std::{fs::File, path::Path};
2+
use jpeg_decoder::Decoder;
3+
4+
#[test]
5+
fn decoding_in_limited_threadpool_does_not_deadlock() {
6+
let path = Path::new("tests").join("reftest").join("images").join("mozilla").join("jpg-progressive.jpg");
7+
8+
let pool = rayon::ThreadPoolBuilder::new()
9+
.num_threads(1)
10+
.build()
11+
.unwrap();
12+
pool.install(|| {
13+
let mut decoder = Decoder::new(File::open(&path).unwrap());
14+
let _ = decoder.decode().unwrap();
15+
});
16+
}

0 commit comments

Comments
 (0)