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