run tests in thread with bigger stack
This commit is contained in:
parent
bf2fedb690
commit
ef5ef9252e
3 changed files with 47 additions and 28 deletions
|
@ -72,6 +72,10 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn compile_examples() {
|
||||
let builder = std::thread::Builder::new().stack_size(8388608);
|
||||
|
||||
builder
|
||||
.spawn(|| {
|
||||
for p in glob("./examples/**/*").expect("Failed to read glob pattern") {
|
||||
let path = match p {
|
||||
Ok(x) => x,
|
||||
|
@ -101,6 +105,8 @@ mod tests {
|
|||
|
||||
assert_eq!(res.is_err(), should_error);
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -60,6 +60,7 @@ pub trait Field:
|
|||
+ Ord
|
||||
+ Display
|
||||
+ Debug
|
||||
+ Send
|
||||
+ Add<Self, Output = Self>
|
||||
+ for<'a> Add<&'a Self, Output = Self>
|
||||
+ Sub<Self, Output = Self>
|
||||
|
@ -151,6 +152,8 @@ mod prime_field {
|
|||
value: BigInt,
|
||||
}
|
||||
|
||||
unsafe impl Send for FieldPrime {}
|
||||
|
||||
impl Field for FieldPrime {
|
||||
fn bits(&self) -> u32 {
|
||||
self.value.bits() as u32
|
||||
|
|
|
@ -95,6 +95,12 @@ pub fn test_inner(test_path: &str) {
|
|||
|
||||
let curves = t.curves.clone().unwrap_or(vec![Curve::Bn128]);
|
||||
|
||||
// this function typically runs in a spawn thread whose stack size is small, leading to stack overflows
|
||||
// to avoid that, run the stack-heavy bit in a thread with a larger stack (8M)
|
||||
let builder = std::thread::Builder::new().stack_size(8388608);
|
||||
|
||||
builder
|
||||
.spawn(move || {
|
||||
for c in &curves {
|
||||
match c {
|
||||
Curve::Bn128 => compile_and_run::<Bn128Field>(t.clone()),
|
||||
|
@ -103,6 +109,10 @@ pub fn test_inner(test_path: &str) {
|
|||
Curve::Bw6_761 => compile_and_run::<Bw6_761Field>(t.clone()),
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap()
|
||||
.join()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn compile_and_run<T: Field>(t: Tests) {
|
||||
|
|
Loading…
Reference in a new issue