summaryrefslogtreecommitdiff
path: root/.gitlab-ci/bare-metal/expect-output.sh
blob: db82ea097e3e895ea7359592cfd52d3f9eba5c5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

set -e

STRINGS=$(mktemp)
ERRORS=$(mktemp)

trap "rm $STRINGS; rm $ERRORS;" EXIT

FILE=$1
shift 1

while getopts "f:e:" opt; do
  case $opt in
    f) echo "$OPTARG" >> $STRINGS;;
    e) echo "$OPTARG" >> $STRINGS ; echo "$OPTARG" >> $ERRORS;;
  esac
done
shift $((OPTIND -1))

echo "Waiting for $FILE to say one of following strings"
cat $STRINGS

while ! egrep -wf $STRINGS $FILE; do
  sleep 2
done

if egrep -wf $ERRORS $FILE; then
  exit 1
fi