summaryrefslogtreecommitdiff
path: root/tests/chutney/teardown
blob: 3bcb58ec231c4a5403f266b8e266a10f961569b7 (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
31
32
33
34
#!/usr/bin/env bash
set -xeuo pipefail

cd "$(git rev-parse --show-toplevel)"

# Tell shellcheck that yes, we know that we're sourcing a file.
# shellcheck disable=SC1091
source tests/chutney/arti.run

# Validate that these are set (from arti.run)
[ -n "${target:?}" ]
[ -n "${CHUTNEY_BIN:?}" ]

# If Arti was started, stop it. If it wasn't, that's an error and it'll be reported
# when we can't read $result later.
if [ -n "${pid:-}" ]; then
    # Tolerate a failure here: even in case the arti process already died
    # for some reason, we still want to shut down the chutney network.
    kill -s INT "$pid" || true
    # wait $pid, but $pid was started by a different process
    tail --pid="$pid" -f /dev/null
fi

"${CHUTNEY_BIN}" stop "$target"

# Tell shellcheck that yes, we know that we're sourcing a file.
# shellcheck disable=SC1091
source tests/chutney/arti.run

# As above, make sure this is defined.  (It won't be defined until
# this point, so we can't check it earlier.)
result="${result:?}"

exit "$result"