Skip to content

Assert failure because of SkipWithError() #937

@chfast

Description

@chfast

If SkipWithError() is used before the benchmark loop, and we also early exit before the benchmark loop starts the assert failure is triggered:

src/benchmark_runner.cc:120: RunInThread: Check `st.iterations() >= st.max_iterations' failed. Benchmark returned before State::KeepRunning() returned false!

at https://github.com/google/benchmark/blob/master/src/benchmark_runner.cc#L120.

The example unit test:

void BM_error_no_running(benchmark::State& state) {
  state.SkipWithError("error message");
}
BENCHMARK(BM_error_no_running);
ADD_CASES("BM_error_before_running", {{"", true, "error message"}});

I was thinking about fixing the issue by modifying the assert condition allow it pass if there was a failure in the benchmark. But there is no API to read this information from a State object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions