-
Notifications
You must be signed in to change notification settings - Fork 15
/
verify_example.sh
executable file
·45 lines (39 loc) · 1.04 KB
/
verify_example.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash -e
EXAMPLE_NAME="${1}"
EXAMPLE_DIR="${2}"
TMPOUT=$(mktemp)
RUNDIR=$(mktemp -d)
export TERM=xterm-256color
complete () {
EXITCODE="$(tail -n 1 "${TMPOUT}" | grep -oP '(?<=COMMAND_EXIT_CODE=")[0-9]+')"
echo "${EXAMPLE_NAME}: ${EXITCODE}:${TIME}"
tail -n 1 "$TMPOUT"
echo
echo
if [[ "$EXITCODE" != 0 ]]; then
cat "$TMPOUT"
fi
echo
echo
rm -rf "$RUNDIR"
rm -rf "$TMPOUT"
}
verify () {
tar xf "$EXAMPLE_DIR" -C "$RUNDIR"
export DOCKER_NO_PULL=1
export DOCKER_RMI_CLEANUP=1
# This is set to simulate an environment where users have shared home drives protected
# by a strong umask (ie only group readable by default).
umask 027
chmod -R o-rwx "$RUNDIR"
cd "$RUNDIR"
dirlist=$(ls .)
if [[ "$dirlist" == "external" ]]; then
cd "external/envoy_examples/${EXAMPLE_NAME}"
else
cd "${EXAMPLE_NAME}"
fi
script -q -c "unbuffer ./verify.sh" "$TMPOUT" >/dev/null
}
trap complete EXIT
TIME=$({ time verify; } 2>&1 | grep real | cut -dl -f2)