File: setup.sh

package info (click to toggle)
incus 6.0.5-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,788 kB
  • sloc: sh: 16,313; ansic: 3,121; python: 457; makefile: 337; ruby: 51; sql: 50; lisp: 6
file content (31 lines) | stat: -rw-r--r-- 1,073 bytes parent folder | download | duplicates (3)
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
# Test setup helper functions.

ensure_has_localhost_remote() {
    # shellcheck disable=SC2039,3043
    local addr="${1}"
    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 | grep -q "^| testimage\\s*|.*$"; 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

            project="$(incus project list | awk '/(current)/ {print $2}')"
            deps/import-busybox --alias testimage --project "$project"
        fi
    fi
}