Run a state machine test by generating `max_steps` commands. It is expected to panic if some post condition fails.
(
u: &mut Unstructured,
t: &T,
max_steps: usize,
)
| 60 | /// |
| 61 | /// It is expected to panic if some post condition fails. |
| 62 | pub fn run<T: StateMachine>( |
| 63 | u: &mut Unstructured, |
| 64 | t: &T, |
| 65 | max_steps: usize, |
| 66 | ) -> arbitrary::Result<()> { |
| 67 | let mut state = t.gen_state(u)?; |
| 68 | let mut system = t.new_system(&state); |
| 69 | for _ in 0..max_steps { |
| 70 | ensure_has_randomness(u)?; |
| 71 | let cmd = t.gen_command(u, &state)?; |
| 72 | let res = t.run_command(&mut system, &cmd); |
| 73 | t.check_result(&cmd, &state, res); |
| 74 | state = t.next_state(&cmd, state); |
| 75 | if !t.check_system(&cmd, &state, &system) { |
| 76 | break; |
| 77 | } |
| 78 | } |
| 79 | Ok(()) |
| 80 | } |
| 81 | |
| 82 | /// Once we run out of randomness, most of the arbitrary data generated by it will |
| 83 | /// be zeroes, which is is not very realistic. Calling this method can highlight |
no test coverage detected