#!/bin/bash
# usage: run-b-intake.sh <exe-relative-to-repo> <testfn> <tag> <secret>
# Role B on kitsubito, explicit exe (never a glob), in ~/spt-351-w2.
cd ~/spt-351-w2
for v in $(env | grep -E '^(OWL_|SPT_)' | cut -d= -f1); do unset $v; done
export SPT_TWO_HOST=1 SPT_TWO_HOST_ROLE=b SPT_TWO_HOST_SECRET="$4" SPT_TWO_HOST_PEER_IP=192.168.1.81
{
  echo "exe=$1 head=$(git rev-parse HEAD) dirty=$(git status --porcelain | wc -l) start=$(date -u +%FT%TZ)"
  ls -la --time-style=full-iso "$1"
} > ~/intake-$3-b.raw
S0=$(date +%s.%N)
"$1" --nocapture --test-threads 1 --exact "$2" >> ~/intake-$3-b.raw 2>&1
RC=$?
echo "rc=$RC wall=$(echo "$(date +%s.%N) - $S0" | bc)" >> ~/intake-$3-b.raw
echo $RC > ~/intake-$3-b.exit
