]>
Commit | Line | Data |
---|---|---|
8d876415 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
adee3bae | 4 | FAIL=0 |
0954c58e DK |
5 | PASS=0 |
6 | ALL=0 | |
7 | ||
2b4e2e83 | 8 | FAILED_TESTS="" |
9962ae93 | 9 | DIR=$(readlink -f $(dirname $0)) |
39cc8228 DK |
10 | if [ "$1" = "-q" ]; then |
11 | export MSGLEVEL=2 | |
12 | elif [ "$1" = "-v" ]; then | |
18331adf | 13 | export MSGLEVEL=4 |
39cc8228 | 14 | fi |
682a3bf7 DK |
15 | |
16 | if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then | |
17 | CTEST='\033[1;32m' | |
18 | CHIGH='\033[1;35m' | |
19 | CRESET='\033[0m' | |
20 | elif [ -z "${MSGLEVEL}" ]; then | |
21 | export MSGLEVEL=2 | |
22 | fi | |
23 | ||
fe268128 DK |
24 | if [ -z "$MSGLEVEL" ]; then |
25 | MSGLEVEL=5 | |
26 | fi | |
27 | ||
8d876415 | 28 | for testcase in $(run-parts --list $DIR | grep '/test-'); do |
682a3bf7 DK |
29 | if [ "$MSGLEVEL" -le 2 ]; then |
30 | echo -n "${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: " | |
39cc8228 | 31 | else |
682a3bf7 | 32 | echo "${CTEST}Run Testcase ${CHIGH}$(basename ${testcase})${CRESET}" |
39cc8228 | 33 | fi |
adee3bae | 34 | if ! ${testcase}; then |
0954c58e DK |
35 | FAIL=$((FAIL+1)) |
36 | FAILED_TESTS="$FAILED_TESTS $(basename $testcase)" | |
37 | echo >&2 "$(basename $testcase) ... FAIL" | |
38 | else | |
39 | PASS=$((PASS+1)) | |
40 | fi | |
41 | ALL=$((ALL+1)) | |
682a3bf7 | 42 | if [ "$MSGLEVEL" -le 2 ]; then |
39cc8228 DK |
43 | echo |
44 | fi | |
8d876415 | 45 | done |
adee3bae | 46 | |
0954c58e DK |
47 | echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed" |
48 | if [ -n "$FAILED_TESTS" ]; then | |
49 | echo >&2 "Failed tests: $FAILED_TESTS" | |
50 | else | |
51 | echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?' | |
2b4e2e83 | 52 | fi |
f91bd741 MV |
53 | # ensure we don't overflow |
54 | exit $((FAIL <= 255 ? FAIL : 255)) |