]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | set -e | |
3 | ||
4 | FAIL=0 | |
5 | FAILED_TESTS="" | |
6 | DIR=$(readlink -f $(dirname $0)) | |
7 | if [ "$1" = "-q" ]; then | |
8 | export MSGLEVEL=2 | |
9 | elif [ "$1" = "-v" ]; then | |
10 | export MSGLEVEL=4 | |
11 | fi | |
12 | ||
13 | if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then | |
14 | CTEST='\033[1;32m' | |
15 | CHIGH='\033[1;35m' | |
16 | CRESET='\033[0m' | |
17 | elif [ -z "${MSGLEVEL}" ]; then | |
18 | export MSGLEVEL=2 | |
19 | fi | |
20 | ||
21 | if [ -z "$MSGLEVEL" ]; then | |
22 | MSGLEVEL=5 | |
23 | fi | |
24 | ||
25 | for testcase in $(run-parts --list $DIR | grep '/test-'); do | |
26 | if [ "$MSGLEVEL" -le 2 ]; then | |
27 | echo -n "${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: " | |
28 | else | |
29 | echo "${CTEST}Run Testcase ${CHIGH}$(basename ${testcase})${CRESET}" | |
30 | fi | |
31 | if ! ${testcase}; then | |
32 | FAIL=$((FAIL+1)) | |
33 | FAILED_TESTS="$FAILED_TESTS $(basename $testcase)" | |
34 | echo "$(basename $testcase) ... FAIL" | |
35 | fi | |
36 | if [ "$MSGLEVEL" -le 2 ]; then | |
37 | echo | |
38 | fi | |
39 | done | |
40 | ||
41 | echo "failures: $FAIL" | |
42 | if [ -n "$FAILED_TESTS" ]; then | |
43 | echo "Failed tests: $FAILED_TESTS"; | |
44 | fi | |
45 | # ensure we don't overflow | |
46 | exit $((FAIL <= 255 ? FAIL : 255)) |