Skip to content

Commit

Permalink
smoketest that libtest doesn't panic in #[bench]
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc committed Oct 31, 2022
1 parent b56cb9e commit 8c71820
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/run-make/test-benches/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include ../../run-make-fulldeps/tools.mk

all:
# Smoke-test that `#[bench]` isn't entirely broken.
$(RUSTC) --test smokebench.rs -O
$(call RUN,smokebench --bench)
$(call RUN,smokebench --bench noiter)
$(call RUN,smokebench --bench yesiter)
$(call RUN,smokebench)
14 changes: 14 additions & 0 deletions src/test/run-make/test-benches/smokebench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![feature(test)]
extern crate test;

#[bench]
fn smoke_yesiter(b: &mut test::Bencher) {
let mut i = 0usize;
b.iter(|| {
i = i.wrapping_add(1);
i
})
}

#[bench]
fn smoke_noiter(_: &mut test::Bencher) {}

0 comments on commit 8c71820

Please sign in to comment.