diff options
-rw-r--r-- | postgresql-tests/config.sh | 8 | ||||
-rw-r--r-- | postgresql-tests/tasks/initdb/config.sh | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | postgresql-tests/tasks/initdb/runtest.sh | 29 | ||||
-rw-r--r-- | postgresql-tests/tasks/initdb_old/config.sh | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | postgresql-tests/tasks/initdb_old/runtest.sh | 18 | ||||
-rw-r--r-- | postgresql-tests/tasks/upgrade-basic/config.sh | 2 | ||||
-rw-r--r-- | postgresql-tests/tasks/upgrade-basic/runtest.sh | 14 | ||||
-rw-r--r-- | postgresql-tests/tasks/upgrade-utf8-syntax/config.sh | 3 | ||||
-rw-r--r-- | postgresql-tests/tasks/upgrade-utf8-syntax/runtest.sh | 29 | ||||
-rwxr-xr-x | tester/run | 144 |
10 files changed, 146 insertions, 109 deletions
diff --git a/postgresql-tests/config.sh b/postgresql-tests/config.sh index 6650ed2..6dc859a 100644 --- a/postgresql-tests/config.sh +++ b/postgresql-tests/config.sh @@ -1,7 +1,4 @@ -# include PostgreSQL specific test-library -. "$srcdir/lib_pgsql.sh" || exit 1 - -export dtf_dataurls +export dtf_dataurls dtf_libfiles # this is needed for some tests dtf_dataurls[0]=http://172.16.125.10/root-tests/data/postgresql/ @@ -11,3 +8,6 @@ dtf_cb_dist_tasks() { tar -ch "$dir" --exclude gen-data } + +# include PostgreSQL specific test-library +dtf_libfiles[0]="$srcdir/lib_pgsql.sh" diff --git a/postgresql-tests/tasks/initdb/config.sh b/postgresql-tests/tasks/initdb/config.sh deleted file mode 100644 index c7f6619..0000000 --- a/postgresql-tests/tasks/initdb/config.sh +++ /dev/null @@ -1,4 +0,0 @@ -DTF_TEST_ID="initdb-basic" -DTF_TEST_DESCRIPTION="\ -Check that the syntax 'postgresql-setup --initdb' works together with following -'service start postgresql'." diff --git a/postgresql-tests/tasks/initdb/runtest.sh b/postgresql-tests/tasks/initdb/runtest.sh index ee520d6..f8cf3a5 100755..100644 --- a/postgresql-tests/tasks/initdb/runtest.sh +++ b/postgresql-tests/tasks/initdb/runtest.sh @@ -1,11 +1,20 @@ -dtf_postgresql_test_init -if rlIsFedora 18 19 20 21 || rlIsRHEL 5 6 7; then - # This syntaxe is not supported on oler systems. - : -else - rlRun "postgresql-setup --initdb" - rlServiceStart postgresql - dtf_postgresql_check_started -fi +export DTF_TEST_ID="initdb-basic" +export DTF_TEST_DESCRIPTION="\ +Check that the syntax 'postgresql-setup --initdb' works together with following +'service start postgresql'." + +run() +{ + dtf_postgresql_test_init + if rlIsFedora 18 19 20 21 || rlIsRHEL 5 6 7; then + # This syntaxe is not supported on oler systems. + : + else + rlRun "postgresql-setup --initdb" + rlServiceStart postgresql + dtf_postgresql_check_started + fi + + dtf_postgresql_test_finish +} -dtf_postgresql_test_finish diff --git a/postgresql-tests/tasks/initdb_old/config.sh b/postgresql-tests/tasks/initdb_old/config.sh deleted file mode 100644 index 2386677..0000000 --- a/postgresql-tests/tasks/initdb_old/config.sh +++ /dev/null @@ -1,4 +0,0 @@ -DTF_TEST_ID="initdb-old-syntax" -DTF_TEST_DESCRIPTION="\ -Check that the old syntax 'postgresql-setup initdb' works together with -following 'service start postgresql'." diff --git a/postgresql-tests/tasks/initdb_old/runtest.sh b/postgresql-tests/tasks/initdb_old/runtest.sh index 6a8d63c..1cd77f4 100755..100644 --- a/postgresql-tests/tasks/initdb_old/runtest.sh +++ b/postgresql-tests/tasks/initdb_old/runtest.sh @@ -1,5 +1,13 @@ -dtf_postgresql_test_init -rlRun "postgresql-setup initdb" -rlServiceStart postgresql -dtf_postgresql_check_started -dtf_postgresql_test_finish +export DTF_TEST_ID="initdb-old-syntax" +export DTF_TEST_DESCRIPTION="\ +Check that the old syntax 'postgresql-setup initdb' works together with +following 'service start postgresql'." + +run() +{ + dtf_postgresql_test_init + rlRun "postgresql-setup initdb" + rlServiceStart postgresql + dtf_postgresql_check_started + dtf_postgresql_test_finish +} diff --git a/postgresql-tests/tasks/upgrade-basic/config.sh b/postgresql-tests/tasks/upgrade-basic/config.sh deleted file mode 100644 index a1d4a2f..0000000 --- a/postgresql-tests/tasks/upgrade-basic/config.sh +++ /dev/null @@ -1,2 +0,0 @@ -export DTF_TEST_ID="basic-upgrade" -export DTF_TEST_DESCRIPTION="Check postgresql-setup [--]upgrade" diff --git a/postgresql-tests/tasks/upgrade-basic/runtest.sh b/postgresql-tests/tasks/upgrade-basic/runtest.sh index 37af60e..7952fe0 100644 --- a/postgresql-tests/tasks/upgrade-basic/runtest.sh +++ b/postgresql-tests/tasks/upgrade-basic/runtest.sh @@ -1,6 +1,12 @@ -dtf_postgresql_test_init +export DTF_TEST_ID="basic-upgrade" +export DTF_TEST_DESCRIPTION="Check postgresql-setup [--]upgrade" -dtf_postgresql_upgrade_tour "$(dtf_postgresql_data_mirror)" basic.tar.gz -rlAssert0 "test wrapper should finish successfully" $? +run() +{ + dtf_postgresql_test_init -dtf_postgresql_test_finish + dtf_postgresql_upgrade_tour "$(dtf_postgresql_data_mirror)" basic.tar.gz + rlAssert0 "test wrapper should finish successfully" $? + + dtf_postgresql_test_finish +} diff --git a/postgresql-tests/tasks/upgrade-utf8-syntax/config.sh b/postgresql-tests/tasks/upgrade-utf8-syntax/config.sh deleted file mode 100644 index bed95ad..0000000 --- a/postgresql-tests/tasks/upgrade-utf8-syntax/config.sh +++ /dev/null @@ -1,3 +0,0 @@ -export DTF_TEST_ID="basic-locale-utf8-syntax" -export DTF_TEST_DESCRIPTION="Check postgresql-setup --upgrade works even when \ -the system locale changed from xx_XX.utf8 to xx_XX.UTF-8" diff --git a/postgresql-tests/tasks/upgrade-utf8-syntax/runtest.sh b/postgresql-tests/tasks/upgrade-utf8-syntax/runtest.sh index cc8f8c4..c14a34e 100644 --- a/postgresql-tests/tasks/upgrade-utf8-syntax/runtest.sh +++ b/postgresql-tests/tasks/upgrade-utf8-syntax/runtest.sh @@ -1,15 +1,22 @@ -dtf_postgresql_test_init +export DTF_TEST_ID="basic-locale-utf8-syntax" +export DTF_TEST_DESCRIPTION="Check postgresql-setup --upgrade works even when \ +the system locale changed from xx_XX.utf8 to xx_XX.UTF-8" -dtf_postgresql_cb_upgrade_select() +run() { - if rlIsFedora 20 21 22; then - cat - else - cat >/dev/null - fi -} + dtf_postgresql_test_init + + dtf_postgresql_cb_upgrade_select() + { + if rlIsFedora 20 21 22; then + cat + else + cat >/dev/null + fi + } -dtf_postgresql_upgrade_tour "$(dtf_postgresql_data_mirror)" locale-utf-typo.tar.gz -rlAssert0 "test wrapper should finish successfully" $? + dtf_postgresql_upgrade_tour "$(dtf_postgresql_data_mirror)" locale-utf-typo.tar.gz + rlAssert0 "test wrapper should finish successfully" $? -dtf_postgresql_test_finish + dtf_postgresql_test_finish +} @@ -1,8 +1,24 @@ #!/bin/bash -## CONFIG ## +### test case return codes ### -srcdir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) || exit 1 +# basic error codes +export DTF_RESULT_SUCCES=0 +export DTF_RESULT_FAILURE=1 +export DTF_RESULT_EXP_FAILURE=2 + +# Inherited from (reserved for) autoconf +export DTF_RESULT_SKIP=77 +export DTF_RESULT_HARDFAIL=99 + +# Should not be used from test-cases +export DTF_RESULT_TS_SKIP=66 +export DTF_RESULT_TS_CONFIG=67 +export DTF_RESULT_USER_ERROR=68 + +srcdir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) || exit $DTF_RESULT_TS_CONFIG + +### paths ### export DTF_LIBDIR=${DTF_LIBDIR-$srcdir/libdtf} export DTF_TASKS=${DTF_TASKS-$srcdir/tasks} @@ -11,16 +27,16 @@ export DTF_RESULTDIR=${DTF_RESULTDIR-/var/tmp/dtf} # when exists per-testsuite config.sh, source it here test -r "$srcdir/config.sh" && . "$srcdir/config.sh" -export dtf_resultxml_file="$DTF_RESULTDIR/dtf.xml" +### options ### export dtf_option_verbose=0 export dtf_option_force=0 export dtf_option_testids="" export dtf_option_listonly=0 -. "$DTF_LIBDIR/libdtf.sh" || exit 1 +. "$DTF_LIBDIR/libdtf.sh" || exit $DTF_RESULT_TS_CONFIG -## F.DEFS ## +### function definitions ### info() { @@ -30,7 +46,7 @@ info() die() { echo "$@" >&2 - exit 1 + exit $DTF_RESULT_TS_CONFIG } dist() @@ -55,68 +71,64 @@ dist() # run TESTDIR # ----------- -# source the $TESTDIR/runtest.sh -run() -{ - export dtf_workdir=$1 - export dtf_test_id=$(basename "$dtf_workdir") - - dtf_resultxml_cache "$( cd "$dtf_workdir" - . ./config.sh - echo "<test>" - echo "<id>$DTF_TEST_ID</id>" - echo "<description>" - echo "$DTF_TEST_DESCRIPTION" - echo "</description>" - )" +# +# Sources the $TESTDIR/runtest.sh and executes the 'run' method from the sourced +# file. The RUN's exit value is propagated to the caller of RUN_TEST. - ( cd "$dtf_workdir" +run_test() +( + cd "$1" - outlog="$DTF_RESULTDIR/tasks/$dtf_test_id.log" - output_wrapper="cat > $outlog" + test ! -e ./runtest.sh \ + && echo "runtest.sh not found" \ + && exit $DTF_RESULT_TS_CONFIG - test $dtf_option_verbose = 1 \ - && output_wrapper="tee $outlog" + . ./runtest.sh - test ! -e ./config.sh -o ! -e ./config.sh \ - && echo "can not find one of {config,runtest}.sh" \ - && exit 1 + test -z "$DTF_TEST_ID" && exit $DTF_RESULT_TS_CONFIG - . ./config.sh + result_dir="$DTF_RESULTDIR/tasks/$DTF_TEST_ID" - if test "$dtf_option_listonly" -eq 1; then - echo "$DTF_TEST_ID" - exit 0 - fi + mkdir -p "$result_dir" || exit + outlog="$result_dir/run.log" - if test -n "$dtf_option_testids"; then - [[ "$dtf_option_testids" = *\ $DTF_TEST_ID\ * ]] || exit 0 - fi + output_wrapper="cat > $outlog" + test $dtf_option_verbose = 1 \ + && output_wrapper="tee $outlog" - printf "%-40s" "RUN $DTF_TEST_ID ..." + if test "$dtf_option_listonly" -eq 1; then + echo "$DTF_TEST_ID" + exit $DTF_RESULT_TS_SKIP + fi - set -o pipefail + if test -n "$dtf_option_testids"; then + [[ "$dtf_option_testids" = *\ $DTF_TEST_ID\ * ]] \ + || exit $DTF_RESULT_TS_SKIP + fi - ( . ./config.sh - . ./runtest.sh - rv=$? + printf "%-40s" "RUN $DTF_TEST_ID ..." - test -n "$DTF_RESULT_TARBALL" \ - && cp "$DTF_RESULT_TARBALL" "$DTF_RESULTDIR/tasks/$dtf_test_id.tar.gz" + set -o pipefail - { echo "---" - echo "exit_status: $rv" - echo "finished: \"$(date)\"" - } >> "$DTF_RESULTDIR/tasks/$dtf_test_id.result" + ( + for i in "${dtf_libfiles[@]}"; do + . "$i" + done - exit $rv - ) 2>&1 | eval "$output_wrapper" + run rv=$? - test $rv -eq 0 && echo "[ OK ]" || echo "[ FAIL ]" + test -n "$DTF_RESULT_TARBALL" \ + && cp "$DTF_RESULT_TARBALL" \ + "$DTF_RESULTDIR/tasks/$DTF_TEST_ID/output.tar.gz" + { echo "---" + echo "exit_status: $rv" + echo "finished: \"$(date)\"" + } >> "$DTF_RESULTDIR/tasks/$DTF_TEST_ID.result" + exit $rv - ) -} + ) 2>&1 | eval "$output_wrapper" +) prepare_resultdir() { @@ -150,7 +162,7 @@ longopts="verbose,help,force,testid:,listonly,dist" ARGS=$(getopt -o "v" -l "$longopts" -n "getopt" -- "$@") if [ $? -ne 0 ]; then echo "getopt error" - exit 1 + exit $DTF_RESULT_TS_CONFIG fi eval set -- "$ARGS" @@ -188,18 +200,26 @@ done test $dtf_option_listonly -ne 1 && prepare_resultdir -dtf_resultxml_init "$dtf_resultxml_file" result=0 while read i; do testdir=$(dirname "$i") - run "$testdir" || result=1 - - if test $result -eq 0; then - dtf_resultxml_cache "<result>Success</result></test>" - else - dtf_resultxml_cache "<result>Fail</result></test>" - fi + run_test "$testdir" + case "$?" in + $DTF_RESULT_SUCCES) + echo "[ OK ]" + ;; + $DTF_RESULT_TS_SKIP) + ;; + $DTF_RESULT_SKIP) + echo "[ SKIP ]" + ;; + $DTF_RESULT_HARDFAIL) + die "hard failure" + ;; + *) + result=1 + ;; + esac done <<<"$(find "$DTF_TASKS" -name runtest.sh)" -dtf_resultxml_finish exit $result |