Debian Codegraph @

test/run-all

raw
1 #!/bin/bash
2
3 id=$(id -u)
4
5 needs_root() {
6 grep -q NEED_ROOT "$1"
7 }
8
9
10 tests=( )
11 for t in ./test/test-*; do
12 [ -x "$t" ] && [ -f "$t" ] && tests[${#tests[@]}]="$t"
13 done
14
15 if [ "$id" != "0" ]; then
16 echo "not root, (id=$id), only executing subset of tests."
17 fi
18
19 passes=( )
20 skips=( )
21 fails=( )
22
23 # allow environment to specify , separated list of tests to skip
24 skiptests=",$SKIP,"
25
26 for t in "${tests[@]}"; do
27 name=${t##*/}
28 short=${name#test-}
29 if [ "$id" != "0" ] && needs_root "$t"; then
30 skips[${#skips[@]}]="$name"
31 echo "$name: SKIP (not root)"
32 continue
33 fi
34 case "$skiptests" in
35 *,$name,*|*,$short,*)
36 echo "$name: SKIP (environ)"
37 skips[${#skips[@]}]="$name"
38 continue
39 ;;
40 esac
41 # send test output to stderr, so it can all be redirected.
42 "$t" 1>&2
43 r=$?
44 if [ $r -eq 0 ]; then
45 echo "$name: PASS"
46 passes[${#passes[@]}]="$name"
47 else
48 echo "$name: FAIL"
49 fails[${#fails[@]}]="$name"
50 fi
51 done
52
53 echo "== results =="
54 echo "${#passes[@]} passed. ${#fails[@]} failed. ${#skips[@]} skipped."
55 echo "PASSES: ${passes[*]}"
56 echo "FAILS: ${fails[*]}"
57 echo "SKIP: ${skips[*]}"
58
59 if [ "${#fails[@]}" != "0" ] && [ "${#passes[@]}" != "0" ]; then
60 exit 1
61 fi
62 exit 0