Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/hack/common.inc.sh
1639 views
1
# shellcheck shell=bash
2
cleanup_cmd=""
3
trap 'eval ${cleanup_cmd}' EXIT
4
function defer {
5
[ -n "${cleanup_cmd}" ] && cleanup_cmd="${cleanup_cmd}; "
6
cleanup_cmd="${cleanup_cmd}$1"
7
}
8
9
function INFO() {
10
echo "TEST| [INFO] $*"
11
}
12
13
function WARNING() {
14
echo >&2 "TEST| [WARNING] $*"
15
}
16
17
function ERROR() {
18
echo >&2 "TEST| [ERROR] $*"
19
}
20
21
if [[ ${BASH_VERSINFO:-0} -lt 4 ]]; then
22
ERROR "Bash version is too old: ${BASH_VERSION}"
23
exit 1
24
fi
25
26
: "${LIMA_HOME:=${HOME_HOST:-$HOME}/.lima}"
27
_IPERF3=iperf3
28
# iperf3-darwin does some magic on macOS to avoid "No route on host" on macOS 15
29
# https://github.com/lima-vm/socket_vmnet/issues/85
30
[ "$(uname -s)" = "Darwin" ] && _IPERF3="iperf3-darwin"
31
: "${IPERF3:=$_IPERF3}"
32
33
# Setup LIMA_TEMPLATES_PATH because the templates are not installed, but reference base templates
34
# via template://_images/* and template://_default/*.
35
templates_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../templates" && pwd)"
36
: "${LIMA_TEMPLATES_PATH:-$templates_dir}"
37
export LIMA_TEMPLATES_PATH
38
39