Back to examples

Real example 02 · Mission harness · open PR #109

A two-second failure lasted four seconds

The behavior accepted a two-second burn duration and appeared to honor it, but the helm remained blocked for roughly four seconds because the completion callback could trigger the burn twice.

Real upstream PR PR #109 by cbenjamin23 Corrected upstream; PR remains open · failing 2fa08bd7 · corrected 7e6e6129

The upstream problem

A plausible solution was incomplete

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) {}
   }
}

The test

Run the focused check

Command

cd harnesses/testfailure_behavior_harnesses/H01-testfailure_behavior_unit
./zlaunch.sh --case=burn_gap_detected_pass \
  --port_base=45500 --log=minimal 10

At the incomplete revision

The focused check fails

Configured burn: 2 seconds
Observed normalized helm gap: approximately 4 seconds

Expected gap band: 1.6–2.4 seconds
Result: FAIL — burn lasted about twice as long as requested

The correction

What changed before the final upstream result

What the test proved

The strengthened mission harness measures the gap between helm iterations and checks duration-specific bands. That distinguishes a two-second burn from a three-second burn instead of merely proving that some delay occurred.

Open the protecting test

Corrected solution

The proposed correction makes failure triggering one-shot and measures the burn with std::chrono::steady_clock. The duration cases then track their configured values across time warps 5, 10, and 20.

Open the corrected source

Upstream result

All nine harness cases pass on corrected commit 7e6e6129. PR #109 is still open, so this result is corrected and reproducible but not yet merged.

Open PR #109

Next example

A valid viewer setting was silently ignored

Continue