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