Debian Codegraph @

debian/tests/functions

raw
1 #!/bin/sh
2 unset PT_TYPE GROWPART_RESIZER
3
4 error() { echo "$@" 1>&2; }
5 fail() { [ $# -eq 0 ] || error "$@"; }
6
7 runtests() {
8 local mytest="$1" pt_type resizer
9 make_executable "$1"
10 for pt_type in gpt dos; do
11 for resizer in auto sfdisk sgdisk; do
12 echo "-- PT_TYPE=$pt_type GROWPART_RESIZER=$resizer --"
13 case "$pt_type:$resizer" in
14 # not supported
15 dos:sgdisk)
16 echo "Skipping resize test for dos/sgdisk. not supported."
17 continue;;
18 esac
19 env "PT_TYPE=$pt_type" "GROWPART_RESIZER=$resizer" "$mytest"
20 ret=$?
21 [ $ret -eq 0 ] || {
22 error "FAIL: $mytest failed. pt_type=$pt_type resizer=$resizer"
23 return $ret
24 }
25 echo; echo;
26 done
27 done
28 }
29
30 make_executable() {
31 # in case the thing to be executed is not executable
32 # as it might be created by a patch application.
33 if [ -f "$1" -a ! -x "$1" ]; then
34 chmod +x "$1" || return
35 fi
36 return 0
37 }
38
39 execute() {
40 make_executable "$1"
41 "$@"
42 }
43
44 # vi: ts=4 expandtab