diff options
author | Determinant <[email protected]> | 2020-06-11 16:59:51 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2020-06-11 16:59:51 -0400 |
commit | b02d58c4f3a2b7ad6e32fe3e7a493cec655631ba (patch) | |
tree | af658667c8f3c993f98653ee3ac96e794f5e1f53 /tests/rand_fail.rs | |
parent | a24f46984d51d8533c5ce85d18566394883fcf4b (diff) |
add more tests
Diffstat (limited to 'tests/rand_fail.rs')
-rw-r--r-- | tests/rand_fail.rs | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/tests/rand_fail.rs b/tests/rand_fail.rs index da583b2..055f933 100644 --- a/tests/rand_fail.rs +++ b/tests/rand_fail.rs @@ -3,12 +3,15 @@ use std::collections::HashMap; use std::rc::Rc; -fn single_point_failure(sim: &common::PaintingSim) { - let nticks = sim.get_nticks(); - println!("nticks = {}", nticks); +fn _multi_point_failure(sims: &[common::PaintingSim], state: &common::WALStoreEmulState, f: usize) { + let sim = &sims[0]; + // save the current state and start from there + let mut state = state.clone(); + let mut state0 = state.clone(); + let nticks = sim.get_nticks(&mut state0); + println!("fail = {}, nticks = {}", f, nticks); for i in 0..nticks { - print!("fail pos = {}, ", i); - let mut state = common::WALStoreEmulState::new(); + println!("fail = {}, pos = {}", f, i); let mut canvas = sim.new_canvas(); let mut ops: Vec<common::PaintStrokes> = Vec::new(); let mut ringid_map = HashMap::new(); @@ -24,17 +27,25 @@ fn single_point_failure(sim: &common::PaintingSim) { ) .is_err() { - assert!(sim.check( - &mut state, - &mut canvas, - sim.get_walloader(), - &ops, - &ringid_map, - )) + if sims.len() > 1 { + _multi_point_failure(&sims[1..], &state, f + 1) + } else { + assert!(sim.check( + &mut state, + &mut canvas, + sim.get_walloader(), + &ops, + &ringid_map, + )) + } } } } +fn multi_point_failure(sims: &[common::PaintingSim]) { + _multi_point_failure(sims, &common::WALStoreEmulState::new(), 1); +} + #[test] fn single_point_failure1() { let sim = common::PaintingSim { @@ -50,5 +61,35 @@ fn single_point_failure1() { stroke_max_n: 5, seed: 0, }; - single_point_failure(&sim); + multi_point_failure(&[sim]); +} + +#[test] +fn two_failures() { + let sims = [common::PaintingSim { + block_nbit: 5, + file_nbit: 6, + file_cache: 1000, + n: 10, + m: 5, + k: 100, + csize: 1000, + stroke_max_len: 10, + stroke_max_col: 256, + stroke_max_n: 3, + seed: 0, + }, common::PaintingSim { + block_nbit: 5, + file_nbit: 6, + file_cache: 1000, + n: 10, + m: 5, + k: 100, + csize: 1000, + stroke_max_len: 10, + stroke_max_col: 256, + stroke_max_n: 3, + seed: 0, + }]; + multi_point_failure(&sims); } |