File: run-all

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 (62 lines) | stat: -rwxr-xr-x 1,303 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash

id=$(id -u)

needs_root() {
    grep -q NEED_ROOT "$1"
}


tests=( )
for t in ./test/test-*; do
    [ -x "$t" ] && [ -f "$t" ] && tests[${#tests[@]}]="$t"
done

if [ "$id" != "0" ]; then
    echo "not root, (id=$id), only executing subset of tests."
fi

passes=( )
skips=( )
fails=( )

# allow environment to specify , separated list of tests to skip
skiptests=",$SKIP,"

for t in "${tests[@]}"; do
    name=${t##*/}
    short=${name#test-}
    if [ "$id" != "0" ] && needs_root "$t"; then
        skips[${#skips[@]}]="$name"
        echo "$name: SKIP (not root)"
        continue
    fi
    case "$skiptests" in
        *,$name,*|*,$short,*)
            echo "$name: SKIP (environ)"
            skips[${#skips[@]}]="$name"
            continue
            ;;
    esac
    # send test output to stderr, so it can all be redirected.
    "$t" 1>&2
    r=$?
    if [ $r -eq 0 ]; then
        echo "$name: PASS"
        passes[${#passes[@]}]="$name"
    else
        echo "$name: FAIL"
        fails[${#fails[@]}]="$name"
    fi
done

echo "== results =="
echo "${#passes[@]} passed. ${#fails[@]} failed. ${#skips[@]} skipped."
echo "PASSES: ${passes[*]}"
echo "FAILS: ${fails[*]}"
echo "SKIP: ${skips[*]}"

if [ "${#fails[@]}" != "0" ] && [ "${#passes[@]}" != "0" ]; then
    exit 1
fi
exit 0