File: functions

package info (click to toggle)
cloud-utils 0.33-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 368 kB
  • sloc: sh: 2,889; python: 280; makefile: 25
file content (44 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
unset PT_TYPE GROWPART_RESIZER

error() { echo "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; }

runtests() {
    local mytest="$1" pt_type resizer
    make_executable "$1"
    for pt_type in gpt dos; do
        for resizer in auto sfdisk sgdisk; do
            echo "-- PT_TYPE=$pt_type GROWPART_RESIZER=$resizer --"
            case "$pt_type:$resizer" in
                # not supported
                dos:sgdisk)
                    echo "Skipping resize test for dos/sgdisk. not supported."
                    continue;;
            esac
            env "PT_TYPE=$pt_type" "GROWPART_RESIZER=$resizer" "$mytest"
            ret=$?
            [ $ret -eq 0 ] || {
                error "FAIL: $mytest failed. pt_type=$pt_type resizer=$resizer"
                return $ret
            }
            echo; echo;
        done
    done
}

make_executable() {
    # in case the thing to be executed is not executable
    # as it might be created by a patch application.
    if [ -f "$1" -a ! -x "$1" ]; then
        chmod +x "$1" || return
    fi
    return 0
}

execute() {
    make_executable "$1"
    "$@"
}

# vi: ts=4 expandtab