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

Allow running benchmarks as tests under Miri #778

Open
gefjon opened this issue May 2, 2024 · 0 comments
Open

Allow running benchmarks as tests under Miri #778

gefjon opened this issue May 2, 2024 · 0 comments

Comments

@gefjon
Copy link

gefjon commented May 2, 2024

I have a set of benchmarks for some unsafe memory-management code. I also run these benches as tests via cargo test --benches. Ideally, I'd like to run the benchmarks as tests under Miri, but that doesn't seem to be possible with Criterion right now.

Specifically, criterion_plot::version unconditionally spawns a process to check for the Gnuplot version during Criterion::default, which leads through a long chain to an unsupported pipe2 call. Note that this happens even when passing --noplot or programmatically disabling plotting, as the only way to construct a Criterion appears to be by default.

The simplest way to avoid this, in my opinion, is likely to gate the current implementation of criterion_plot::version behind #[cfg(not(miri))], and to add a separate version behind #[cfg(miri)] which always returns an Err. I haven't tried this myself, so I don't know if that would be sufficient to run under Miri (given suitable command-line arguments), or if something else later down the line will cause issues.

I'd be happy to open a PR if that would help!

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

No branches or pull requests

1 participant