| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| ARGV0=`basename "$0"` |
| PREFIX="bk_test_" |
| SHELLS="/bin/sh /bin/bash" |
|
|
| find_tests_at() { |
| DIR=$1 |
| PREF=$2 |
| REGEX="^${PREF}[a-z_]*.sh$" |
| RESULTS="" |
| if [ -d ${DIR} ]; then |
| cd ${DIR} |
| for f in *.sh; do |
| if [[ ${f} =~ ${REGEX} ]]; then |
| RESULTS="${RESULTS} ${f}" |
| fi |
| done |
| fi |
| echo ${RESULTS} |
| } |
|
|
| TESTS=$(find_tests_at "." ${PREFIX}) |
|
|
| |
| source ./versions |
| source ./bk_test_helpers |
|
|
| usage() { |
| echo "usage: ${ARGV0} [-e key=val ...] [-s shell(s)] [-t test(s)]" |
| } |
|
|
| env='' |
|
|
| |
| while getopts 'e:hs:t:' opt; do |
| case ${opt} in |
| e) |
| key=`expr "${OPTARG}" : '\([^=]*\)='` |
| val=`expr "${OPTARG}" : '[^=]*=\(.*\)'` |
| if [ -z "${key}" -o -z "${val}" ]; then |
| usage |
| exit 1 |
| fi |
| eval "${key}='${val}'" |
| export ${key} |
| env="${env:+${env} }${key}" |
| ;; |
| h) usage; exit 0 ;; |
| s) shells=${OPTARG} ;; |
| t) tests=${OPTARG} ;; |
| *) usage; exit 1 ;; |
| esac |
| done |
| shift `expr ${OPTIND} - 1` |
|
|
| |
| shells=${shells:-${SHELLS}} |
| tests=${tests:-${TESTS}} |
|
|
| |
| if [ -z "${tests}" ]; then |
| bk_info 'no tests found to run; exiting' |
| exit 0 |
| fi |
|
|
| |
| cat <<EOF |
| #------------------------------------------------------------------------------ |
| # System data |
| # |
| # test run info |
| shells="${shells}" |
| tests="${tests}" |
| EOF |
| for key in ${env}; do |
| eval "echo \"${key}=\$${key}\"" |
| done |
| echo |
|
|
| |
| echo "# system info" |
| echo "$ date" |
| date |
|
|
| echo "$ uname -mprsv" |
| uname -mprsv |
|
|
| |
| |
| |
|
|
| for shell in ${shells}; do |
| echo |
|
|
| |
| if [ ! -x ${shell} ]; then |
| bk_warn "unable to run tests with the ${shell} shell" |
| continue |
| fi |
|
|
| cat <<EOF |
| #------------------------------------------------------------------------------ |
| # Running the test suite with ${shell} |
| # |
| EOF |
|
|
| shell_name=`basename ${shell}` |
| shell_version=`versions_shellVersion "${shell}"` |
|
|
| echo "shell name: ${shell_name}" |
| echo "shell version: ${shell_version}" |
|
|
| |
| for suite in ${tests}; do |
| suiteName=`expr "${suite}" : "${PREFIX}\(.*\).sh"` |
| echo |
| echo "--- Executing the '${suiteName}' test suite ---" |
| ( exec ${shell} ./${suite} 2>&1; ) |
| done |
| done |
|
|