Tizen 2.1 base
[external/device-mapper.git] / test / harness.sh
1 #!/bin/sh
2
3 # Copyright (C) 2010 Red Hat, Inc. All rights reserved.
4 #
5 # This copyrighted material is made available to anyone wishing to use,
6 # modify, copy, or redistribute it subject to the terms and conditions
7 # of the GNU General Public License v.2.
8 #
9 # You should have received a copy of the GNU General Public License
10 # along with this program; if not, write to the Free Software Foundation,
11 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
12
13 tests="$@"
14 test -z "$tests" && tests=`echo t-*.sh`
15
16 for t in $tests; do
17     printf "Running %-40s" "$t ..."
18     out=`bash ./$t 2>&1`
19     ret=$?
20     if test $ret = 0; then
21         echo " passed."
22     elif test $ret = 200; then
23         skipped="$skipped $t"
24         echo " skipped."
25     else
26         echo " FAILED!"
27         len=`echo $t | wc -c`
28         # fancy formatting...
29         printf -- "--- Output: $t -"
30         for i in `seq $(($len + 14)) 78`; do echo -n "-"; done; echo
31         printf "%s\n" "$out"
32         printf -- "--- End: $t ----"
33         for i in `seq $(($len + 14)) 78`; do echo -n "-"; done; echo
34         failed="$failed $t"
35     fi
36 done
37
38 if test -n "$failed"; then
39     echo "Tests skipped:"
40     for t in $skipped; do
41         printf "\t%s\n" $t
42     done
43     echo "TESTS FAILED:"
44     for t in $failed; do
45         printf "\t%s\n" $t
46     done
47     exit 1
48 else
49     echo "All tests passed."
50 fi