diff options
| author | Pavel Raiskup <praiskup@redhat.com> | 2014-10-02 12:33:52 +0200 |
|---|---|---|
| committer | Pavel Raiskup <praiskup@redhat.com> | 2014-10-03 09:24:13 +0200 |
| commit | 3a60df60e73c23730210f3706233d74597034148 (patch) | |
| tree | d614b441813e0d4e2299461bf093a3129b4da42b /run | |
| download | postgresql-setup-tests-3a60df60e73c23730210f3706233d74597034148.tar.gz postgresql-setup-tests-3a60df60e73c23730210f3706233d74597034148.tar.xz postgresql-setup-tests-3a60df60e73c23730210f3706233d74597034148.zip | |
Initial commit
Initializet the lib/run structure and created two basic tests for
PostgreSQL.
* README: New file.
* lib.sh: Likewise.
* lib_pgsql.sh: Likewise.
* run: Likewise.
* tasks/initdb/config.sh: Likewise.
* tasks/initdb/runtest.sh: Likewise.
* tasks/initdb_old/config.sh: Likewise.
* tasks/initdb_old/runtest.sh: Likewise.
Diffstat (limited to 'run')
| -rwxr-xr-x | run | 151 |
1 files changed, 151 insertions, 0 deletions
@@ -0,0 +1,151 @@ +#!/bin/bash + +## CONFIG ## + +export dtf_resultdir=${dtf_resultdir_override-/var/tmp/dtf} +export dtf_srcdir=$(dirname $(readlink -f ${BASH_SOURCE[0]})) +export dtf_testdir=${dtf_testdir-$dtf_srcdir} + +export dtf_option_verbose=0 +export dtf_option_force=0 +export dtf_option_testids="" +export dtf_option_listonly=0 + +## F.DEFS ## + +info() +{ + echo " * $@" +} + +die() +{ + echo "$@" >&2 + exit 1 +} + +# run TESTDIR +# ----------- +# source the $TESTDIR/runtest.sh +run() +{ + export dtf_workdir=$1 + export dtf_test_id=`basename $dtf_workdir` + + ( cd $dtf_workdir + + outlog="$dtf_resultdir/$dtf_test_id.log" + output_wrapper="cat > $outlog" + + test $dtf_option_verbose = 1 \ + && output_wrapper="tee $outlog" + + test ! -e ./config.sh -o ! -e ./config.sh \ + && echo "can not find one of {config,runtest}.sh" + + . ./config.sh + + if test "$dtf_option_listonly" -eq 1; then + echo $DTF_TEST_ID + exit 0 + fi + + if test -n "$dtf_option_testids"; then + [[ "$dtf_option_testids" = *\ $DTF_TEST_ID\ * ]] || exit 0 + fi + + printf "%-40s" "RUN $DTF_TEST_ID ..." + + set -o pipefail + + ( . $dtf_srcdir/lib.sh || exit 1 + + . ./config.sh + . ./runtest.sh + rv=$? + + test -n "$DTF_RESULT_TARBALL" \ + && cp "$DTF_RESULT_TARBALL" $dtf_resultdir/$dtf_test_id.tar.gz + + exit $rv + ) 2>&1 | eval $output_wrapper + rv=$? + + test $rv -eq 0 && echo "[ OK ]" || echo "[ FAIL ]" + exit $rv + ) +} + +prepare_resultdir() +{ + if test -e "$dtf_resultdir"; then + test $dtf_option_force -eq 0 && die "result dir $dtf_resultdir exits" + + rm -rf $dtf_resultdir || die "can not remove $dtf_resultdir" + fi + + mkdir -p "$dtf_resultdir" || die "can not create $dtf_resultdir" +} + +show_help() +{ +cat <<EOHELP >&2 +Usage: $0 [OPTIONS] + +Script is aimed to perform set of tests in subdirectories. + +Options: + --force Overwrite result dir if exists + --listonly List the available test ids + --testid=TESTID Perform this test only + --verbose Show complete output from each test + --help Show this help +EOHELP +test -n "$1" && exit $1 +} + +longopts="verbose,help,force,testid:,listonly" +ARGS=`getopt -o "v" -l "$longopts" -n "getopt" -- "$@"` +if [ $? -ne 0 ]; then + echo "getopt error" + exit 1 +fi +eval set -- "$ARGS" + +while true; do + case "$1" in + --verbose) + dtf_option_verbose=1 + shift + ;; + --force) + dtf_option_force=1 + shift + ;; + --listonly) + dtf_option_listonly=1 + shift + ;; + --testid) + dtf_option_testids="$dtf_option_testids $2 " + shift 2 + ;; + --help) + show_help 0 + ;; + --) + shift + break + ;; + esac +done + +test $dtf_option_listonly -ne 1 && prepare_resultdir + +result=0 +for i in `find $dtf_testdir -name runtest.sh`; do + testdir=`dirname $i` + run $testdir || result=1 +done + +exit $result |
