The problem
BHV_TestFailure intentionally stalls the helm to exercise failure handling. Its configurable burn time looked complete, but onCompleteState() could be invoked more than once and each invocation started a fresh busy wait.
The incomplete solution
The initial implementation measured elapsed wall time inside onCompleteState() and returned after the requested duration. It had no one-shot guard, so a two-second configuration could burn twice and produce a four-second operational gap.
Open the source at the failing revision
One-shot guard and monotonic timer in the corrected PR
void BHV_TestFailure::onCompleteState()
{
+ if(m_failure_triggered)
+ return;
+ m_failure_triggered = true;
+
if(m_failure_crash)
assert(0);
else if(m_failure_burn) {
- MBTimer timer;
- timer.start();
- bool done = false;
- while(!done) {
- double elapsed_time = timer.get_float_wall_time();
- if(elapsed_time > m_failure_burn_time)
- done = true;
- }
- timer.stop();
+ const auto start_time = std::chrono::steady_clock::now();
+ while(std::chrono::duration<double>(
+ std::chrono::steady_clock::now() - start_time).count()
+ <= m_failure_burn_time) {}
}
}