xref: /dflybsd-src/contrib/lvm2/dist/test/harness.sh (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino#!/bin/sh
286d7f5d3SJohn Marino
386d7f5d3SJohn Marinotests="$@"
486d7f5d3SJohn Marinotest -z "$tests" && tests=`echo t-*.sh`
586d7f5d3SJohn Marino
686d7f5d3SJohn Marinofor t in $tests; do
786d7f5d3SJohn Marino    printf "Running %-40s" "$t ..."
886d7f5d3SJohn Marino    out=`bash ./$t 2>&1`
986d7f5d3SJohn Marino    ret=$?
1086d7f5d3SJohn Marino    if test $ret = 0; then
1186d7f5d3SJohn Marino	echo " passed."
1286d7f5d3SJohn Marino    elif test $ret = 200; then
1386d7f5d3SJohn Marino        skipped="$skipped $t"
1486d7f5d3SJohn Marino	echo " skipped."
1586d7f5d3SJohn Marino    else
1686d7f5d3SJohn Marino	echo " FAILED!"
1786d7f5d3SJohn Marino	len=`echo $t | wc -c`
1886d7f5d3SJohn Marino	# fancy formatting...
1986d7f5d3SJohn Marino	printf -- "--- Output: $t -"
2086d7f5d3SJohn Marino	for i in `seq $(($len + 14)) 78`; do echo -n "-"; done; echo
2186d7f5d3SJohn Marino	printf "%s\n" "$out"
2286d7f5d3SJohn Marino	printf -- "--- End: $t ----"
2386d7f5d3SJohn Marino	for i in `seq $(($len + 14)) 78`; do echo -n "-"; done; echo
2486d7f5d3SJohn Marino	failed="$failed $t"
2586d7f5d3SJohn Marino    fi
2686d7f5d3SJohn Marinodone
2786d7f5d3SJohn Marino
2886d7f5d3SJohn Marinoif test -n "$failed"; then
2986d7f5d3SJohn Marino    echo "Tests skipped:"
3086d7f5d3SJohn Marino    for t in $skipped; do
3186d7f5d3SJohn Marino	printf "\t%s\n" $t
3286d7f5d3SJohn Marino    done
3386d7f5d3SJohn Marino    echo "TESTS FAILED:"
3486d7f5d3SJohn Marino    for t in $failed; do
3586d7f5d3SJohn Marino	printf "\t%s\n" $t
3686d7f5d3SJohn Marino    done
3786d7f5d3SJohn Marino    exit 1
3886d7f5d3SJohn Marinoelse
3986d7f5d3SJohn Marino    echo "All tests passed."
4086d7f5d3SJohn Marinofi
41