#!/usr/bin/env bash
# run-all.sh [REPS]: preflight, then REPS rounds (default 3). Each round runs every arm at once,
# one container per arm; rounds run one after another. Then summarize.py prints the table.
set -euo pipefail
KIT=$(cd "$(dirname "$0")" && pwd)
REPS=${1:-3}
ARMS="posctl ort130-default ort130-envoff ort130-apioff ort129-default ort128-default"

"$KIT/preflight.sh" || { echo "preflight failed: not running the subject" >&2; exit 1; }
for rep in $(seq 1 "$REPS"); do
  echo "round $rep starts $(date -u +%FT%TZ)"
  for arm in $ARMS; do "$KIT/run-arm.sh" "$arm" "$rep" & done
  wait
done
python3 "$KIT/summarize.py" "${PROBE_RUNS:-$KIT/runs}"
