mirror of
https://github.com/lxc/incus.git
synced 2026-10-12 02:18:30 +00:00
33 lines
1.1 KiB
Bash
33 lines
1.1 KiB
Bash
# Test setup helper functions.
|
|
|
|
ensure_has_localhost_remote() {
|
|
# shellcheck disable=SC2039,3043
|
|
local addr="${1}"
|
|
|
|
incus remote remove localhost 2>/dev/null || true
|
|
if ! incus remote list | grep -q "localhost"; then
|
|
token="$(incus config trust add foo -q)"
|
|
incus remote add localhost "https://${addr}" --accept-certificate --token "${token}"
|
|
fi
|
|
}
|
|
|
|
ensure_import_testimage() {
|
|
if ! incus image alias list --format=csv --columns=a | grep -q "^testimage$"; then
|
|
if [ -e "${INCUS_TEST_IMAGE:-}" ]; then
|
|
incus image import "${INCUS_TEST_IMAGE}" --alias testimage
|
|
else
|
|
if [ ! -e "/bin/busybox" ]; then
|
|
echo "Please install busybox (busybox-static) or set INCUS_TEST_IMAGE"
|
|
exit 1
|
|
fi
|
|
|
|
if ldd /bin/busybox > /dev/null 2>&1; then
|
|
echo "The testsuite requires /bin/busybox to be a static binary"
|
|
exit 1
|
|
fi
|
|
|
|
deps/import-busybox --alias testimage --project "$(incus project get-current)"
|
|
fi
|
|
fi
|
|
}
|