1#!/bin/sh 2 3BASEDIR="$(dirname $(readlink -f $0))" 4 5# init and start postgresql server for testing 6PGDATA="/var/lib/postgresql/data" 7if [ -f "${PGDATA}/PG_VERSION" ]; then 8 echo "Data directory is not empty! Skip initdb." 9else 10 echo "Initializing database: " 11 chown -R postgres:postgres ${PGDATA} 12 su -l postgres -c "/usr/bin/initdb --pgdata='$PGDATA'" 13fi 14 15SYSV_INIT="/etc/init.d/postgresql-server" 16if [ -e ${SYSV_INIT} ]; then 17 RESTART_POSTGRESQL="${SYSV_INIT} restart" 18 STOP_POSTGRESQL="${SYSV_INIT} stop" 19else 20 RESTART_POSTGRESQL="systemctl restart postgresql" 21 STOP_POSTGRESQL="systemctl stop postgresql" 22fi 23 24${RESTART_POSTGRESQL} || echo "Failed to restart postgresql, skip the tests." 25 26if [ ! -d ${BASEDIR}/results ]; then 27 mkdir ${BASEDIR}/results 28fi 29 30# Generate odbc config files and reset db 31${BASEDIR}/odbcini-gen.sh || echo "FAIL: Generate odbc config files" 32ODBCSYSINI=. ODBCINSTINI=./odbcinst.ini ODBCINI=./odbc.ini \ 33 ${BASEDIR}/reset-db < ${BASEDIR}/sampletables.sql \ 34 || echo "FAIL: reset db with sample tables" 35 36# Run the actual tests 37TESTS= 38for i in `ls ${BASEDIR}/exe/*-test`; do 39 TESTS="$TESTS $(basename ${i%-test})" 40done 41 42${BASEDIR}/runsuite ${TESTS} --inputdir=${BASEDIR} 43 44# Cleanup 45${STOP_POSTGRESQL} 46rm -f regression.diffs odbcinst.ini odbc.ini 47