/ tests / chutney / teardown
teardown
 1  #!/usr/bin/env bash
 2  set -xeuo pipefail
 3  
 4  cd "$(git rev-parse --show-toplevel)"
 5  
 6  # Tell shellcheck that yes, we know that we're sourcing a file.
 7  # shellcheck disable=SC1091
 8  source tests/chutney/arti.run
 9  
10  # Validate that these are set (from arti.run)
11  [ -n "${target:?}" ]
12  [ -n "${CHUTNEY_BIN:?}" ]
13  
14  # If Arti was started, stop it. If it wasn't, that's an error and it'll be reported
15  # when we can't read $result later.
16  if [ -n "${pid:-}" ]; then
17      # Tolerate a failure here: even in case the arti process already died
18      # for some reason, we still want to shut down the chutney network.
19      kill -s INT "$pid" || true
20      # wait $pid, but $pid was started by a different process
21      tail --pid="$pid" -f /dev/null
22  fi
23  
24  "${CHUTNEY_BIN}" stop "$target"
25  
26  # Tell shellcheck that yes, we know that we're sourcing a file.
27  # shellcheck disable=SC1091
28  source tests/chutney/arti.run
29  
30  # As above, make sure this is defined.  (It won't be defined until
31  # this point, so we can't check it earlier.)
32  result="${result:?}"
33  
34  exit "$result"