36
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
1 #!/bin/sh
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
2 #
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
3 # Copyright (C) 2019 Guido Berhoerster <guido+pwm@berhoerster.name>
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
4 #
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
5 # Permission is hereby granted, free of charge, to any person obtaining
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
6 # a copy of this software and associated documentation files (the
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
7 # "Software"), to deal in the Software without restriction, including
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
8 # without limitation the rights to use, copy, modify, merge, publish,
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
9 # distribute, sublicense, and/or sell copies of the Software, and to
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
10 # permit persons to whom the Software is furnished to do so, subject to
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
11 # the following conditions:
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
12 #
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
13 # The above copyright notice and this permission notice shall be included
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
14 # in all copies or substantial portions of the Software.
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
15 #
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
19 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
20 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
21 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
22 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
23 #
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
24
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
25 export PWM="${PWM:-pwm}"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
26
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
27 export LC_ALL=C
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
28
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
29 l="$(locale -a | sort | grep -E '^(C|en_US)\.([uU][tT][fF]-?8)$' | head -1)"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
30 if [ -z "$l" ]; then
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
31 printf 'no suitable UTF-8 locale found\n' >&2
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
32 exit 1
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
33 fi
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
34
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
35 export LC_ALL="$l"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
36 export TESTS_PATH="$(dirname "$0")"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
37 export TESTS_OUTPUT_PATH="${TESTS_OUTPUT_PATH:-${TESTS_PATH}/output}"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
38
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
39 tests_passed=0
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
40 tests_failed=0
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
41
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
42 mkdir -p "${TESTS_OUTPUT_PATH}" || exit 1
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
43
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
44 for t in "${TESTS_PATH}"/test-*.sh; do
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
45 [ -r "${t}" ] || break
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
46
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
47 export LOGFILE="${TESTS_OUTPUT_PATH}/$(basename "${t}" .sh).log"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
48 export TEST_NAME="$(basename "${t}" .sh)"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
49
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
50 [ -t 1 ] && printf "Running %s" "${t}"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
51 if ${SHELL:-/bin/sh} "$t" >/dev/null 2>"${LOGFILE}"; then
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
52 tests_passed=$(( tests_passed + 1 ))
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
53 if [ -t 1 ]; then
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
54 printf "\rOK "
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
55 else
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
56 printf "OK %s" "${t}"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
57 fi
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
58 else
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
59 tests_failed=$(( tests_failed + 1 ))
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
60 if [ -t 1 ]; then
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
61 printf "\rFAILED "
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
62 else
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
63 printf "FAILED %s" "${t}"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
64 fi
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
65 fi
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
66 printf "%s\n" "${t}"
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
67 done
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
68
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
69 printf -- "-----------\npassed: %3d\nfailed: %3d\ntotal: %3d\n" $tests_passed \
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
70 $tests_failed $(( tests_failed + tests_passed ))
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
71
|
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
72 [ $tests_failed -eq 0 ]
|