Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions google_benchmark/src/benchmark_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ void RunInThread(const BenchmarkInstance* b, IterationCount iters,

State st = b->__codspeed_root_frame__Run(iters, thread_id, &timer, manager,
perf_counters_measurement, profiler_manager_, is_warmup);
BM_CHECK(st.skipped() || st.iterations() >= st.max_iterations)
<< "Benchmark returned before State::KeepRunning() returned false!";
if (!(st.skipped() || st.iterations() >= st.max_iterations)) {
st.SkipWithError(
"The benchmark didn't run, nor was it explicitly skipped. Please call "
"'SkipWithXXX` in your benchmark as appropriate.");
}
{
MutexLock l(manager->GetBenchmarkMutex());
internal::ThreadManager::Result& results = manager->results;
Expand Down
9 changes: 9 additions & 0 deletions google_benchmark/test/skip_with_error_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ ADD_CASES("BM_error_while_paused", {{"/1/threads:1", true, "error message"},
{"/2/threads:4", false, ""},
{"/2/threads:8", false, ""}});

void BM_malformed(benchmark::State&) {
// NOTE: empty body wanted. No thing else.
}
BENCHMARK(BM_malformed);
ADD_CASES("BM_malformed",
{{"", true,
"The benchmark didn't run, nor was it explicitly skipped. Please "
"call 'SkipWithXXX` in your benchmark as appropriate."}});

int main(int argc, char* argv[]) {
benchmark::Initialize(&argc, argv);

Expand Down