#!/bin/sh
# DF-0033 run script. Unprivileged. The race is intermittent (AC:H); this runs
# short bursts until the guest panics or 12 rounds elapse.
#   arg1 = secs per burst   (default 20)
#   arg2 = peer count       (default 10)
cd "$(dirname "$0")"
SECS="${1:-20}"
PEERS="${2:-10}"
for r in 1 2 3 4 5 6 7 8 9 10 11 12; do
  echo "=== burst $r (${SECS}s, ${PEERS} peers) ==="
  timeout "$((SECS + 5))" ./fdtol_race "$SECS" "$PEERS"
  rc=$?
  echo "burst $r exit=$rc"
  # If the guest is still up after this burst, loop; if it panicked the ssh
  # connection drops and this script dies. A kernel panic lands in the serial
  # console log (dfbsd-qemu/boot.log on the host).
done
echo "completed without panic (race is intermittent; rerun to retry)"
