Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to limit rng output #224

Merged
merged 1 commit into from
Jun 8, 2024
Merged

add option to limit rng output #224

merged 1 commit into from
Jun 8, 2024

Conversation

camshaft
Copy link
Owner

@camshaft camshaft commented Jun 8, 2024

This PR adds a max_len value to the driver::Options struct. This option will limit the amount of bytes generated by the particular driver. As seen in practice, some generators could run forever with unbounded inputs so this tries to avoid that by setting the default value to 4096. Individual tests can override it if larger inputs are desired:

check!()
    .with_max_len(8192)
    .for_each(|input| { ... })

I've also lowered the max_depth from 32 to 5. This should also prevent unbounded input generation and can be raised by the harness:

check!()
    .with_type::<MyType>()
    .with_max_depth(32)
    .for_each(|input| { ... })

Finally, I've simplified the driver::Rng::gen_from_bytes implementation to avoid branching on DriverMode. This ends up being a lot easier to reason about, since the driver no longer loops to try and provide incrementally larger inputs.

@camshaft camshaft marked this pull request as ready for review June 8, 2024 13:08
@camshaft camshaft merged commit e45edd3 into master Jun 8, 2024
8 of 9 checks passed
@camshaft camshaft deleted the bounded-rng branch June 8, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant