bzr branch
/loggerhead/pkg-postgresql/postgresql-common/trunk
| Line | Revision | Contents |
| 1 | 1232 | #!/bin/sh |
| 2 | 384.1.23 | |
| 3 | 1232 | # Run integration tests (on the installed package). This happens on unshared |
| 4 | # tmpfses, so does not interfere with installed clusters. |
|
| 5 | 973 | # |
| 6 | 1232 | # (C) 2005-2012 Martin Pitt <mpitt@debian.org> |
| 7 | 1267 | # (C) 2012-2013 Christoph Berg <myon@debian.org> |
| 8 | 973 | # |
| 9 | # This program is free software; you can redistribute it and/or modify |
|
| 10 | # it under the terms of the GNU General Public License as published by |
|
| 11 | # the Free Software Foundation; either version 2 of the License, or |
|
| 12 | # (at your option) any later version. |
|
| 13 | # |
|
| 14 | # This program is distributed in the hope that it will be useful, |
|
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 17 | # GNU General Public License for more details. |
|
| 18 | ||
| 19 | 1232 | set -e |
| 20 | ||
| 21 | # call ourselves through unshare in a way that keeps normal stdin |
|
| 22 | 1238 | if [ -z "$UNSHARED" ]; then |
| 23 | 1240 | UNSHARED=1 exec unshare -uimn -- "$0" "$@" |
| 24 | 1238 | fi |
| 25 | 1232 | |
| 26 | # unshared program starts here |
|
| 27 | set -e |
|
| 28 | ||
| 29 | 1205 | # default config |
| 30 | TESTSDIR="$(dirname $0)/t" |
|
| 31 | 1267 | : ${PG_UMASKS="022 077"} |
| 32 | 1205 | |
| 33 | help () |
|
| 34 | { |
|
| 35 | echo "postgresql-common testsuite" |
|
| 36 | echo "Syntax: $0 [options] [test ...]" |
|
| 37 | 1344 | echo " -u 'umask ...' umasks to run testsuite with [default: 022 077]" |
| 38 | echo " -v 'version ...' PostgreSQL versions to test [default: client versions installed]" |
|
| 39 | 1205 | exit ${1:-0} |
| 40 | } |
|
| 41 | ||
| 42 | # option parsing |
|
| 43 | 1344 | while getopts "hu:v:" opt ; do |
| 44 | 1205 | case $opt in |
| 45 | h) help ;; |
|
| 46 | 1267 | u) PG_UMASKS="$OPTARG" ;; |
| 47 | 1344 | v) export PG_VERSIONS="$OPTARG" ;; # used in t/TestLib.pm |
| 48 | 1205 | *) help 1 ;; |
| 49 | esac |
|
| 50 | done |
|
| 51 | # shift away args |
|
| 52 | shift $(($OPTIND - 1)) |
|
| 53 | ||
| 54 | 384.1.23 | if [ "$(id -u)" != 0 ]; then |
| 55 | echo "Error: this test suite needs to be run as root" >&2 |
|
| 56 | exit 1 |
|
| 57 | fi |
|
| 58 | ||
| 59 | 1261 | # install locales; this happens differently on Debian and Ubuntu |
| 60 | if [ -e /etc/locale.gen ]; then |
|
| 61 | # Debian |
|
| 62 | while read locale ; do |
|
| 63 | if ! grep -q "^$locale\$" /etc/locale.gen ; then |
|
| 64 | echo "$locale" >> /etc/locale.gen |
|
| 65 | run=1 |
|
| 66 | fi |
|
| 67 | done <<-EOF |
|
| 68 | en_US.UTF-8 UTF-8 |
|
| 69 | ru_RU ISO-8859-5 |
|
| 70 | ru_RU.UTF-8 UTF-8 |
|
| 71 | EOF |
|
| 72 | [ "$run" ] && locale-gen |
|
| 73 | else |
|
| 74 | # Ubuntu |
|
| 75 | # locale-gen will skip existing locales, so just call it for all here |
|
| 76 | locale-gen en_US.UTF-8 ru_RU ru_RU.UTF-8 |
|
| 77 | fi |
|
| 78 | ||
| 79 | 1237 | # stop currently running clusters |
| 80 | if [ -x "/etc/init.d/postgresql" ]; then |
|
| 81 | /etc/init.d/postgresql stop |
|
| 82 | fi |
|
| 83 | ||
| 84 | 1232 | # let everything happen in overlay tmpfses to avoid interfering with already |
| 85 | # existing clusters; this also speeds up testing |
|
| 86 | created_dirs="" |
|
| 87 | for d in /etc/postgresql /var/lib/postgresql /var/log/postgresql /var/run/postgresql; do |
|
| 88 | if ! [ -d $d ]; then |
|
| 89 | created_dirs="$created_dirs $d" |
|
| 90 | mkdir -p $d |
|
| 91 | 384.1.23 | fi |
| 92 | 1232 | mount -n -t tmpfs -o mode=755 tmpfs $d |
| 93 | 384.1.23 | done |
| 94 | 1232 | # clean up created directories after us |
| 95 | if [ -n "$created_dirs" ]; then |
|
| 96 | trap "umount $created_dirs; rmdir --ignore-fail-on-non-empty -p $created_dirs" 0 HUP INT QUIT ILL ABRT PIPE TERM |
|
| 97 | fi |
|
| 98 | chown root:postgres /var/log/postgresql |
|
| 99 | chmod 1775 /var/log/postgresql |
|
| 100 | chown postgres:postgres /var/run/postgresql |
|
| 101 | chmod 2775 /var/run/postgresql |
|
| 102 | 384.1.23 | |
| 103 | 1184 | # reset core limit for pg_ctl tests |
| 104 | ulimit -S -c 0 |
|
| 105 | ||
| 106 | 1236 | # start localhost interface |
| 107 | ifconfig lo up |
|
| 108 | ||
| 109 | 1261 | # set environment |
| 110 | unset TMPDIR |
|
| 111 | unset LC_ALL |
|
| 112 | export LANG=en_US.utf8 |
|
| 113 | ||
| 114 | 582 | # set variables which cause taint check errors |
| 115 | export IFS=' ' |
|
| 116 | export CDPATH=/usr |
|
| 117 | export ENV=/nonexisting |
|
| 118 | export BASH_ENV=/nonexisting |
|
| 119 | ||
| 120 | 1185 | if [ $# -eq 0 ]; then |
| 121 | set -- $TESTSDIR/*.t |
|
| 122 | fi |
|
| 123 | ||
| 124 | 1267 | for U in $PG_UMASKS; do |
| 125 | 1205 | case $U in |
| 126 | 022) TYPE="default" ;; |
|
| 127 | 077) TYPE="tight" ;; |
|
| 128 | *) TYPE="custom" ;; |
|
| 129 | esac |
|
| 130 | ||
| 131 | echo "====== Running all tests with $TYPE umask $U =======" |
|
| 132 | umask $U |
|
| 133 | for T; do |
|
| 134 | echo "=== Running test `basename $T`... ===" |
|
| 135 | perl $T |
|
| 136 | done |
|
| 137 | 384.1.23 | done |
Loggerhead 1.17 is a web-based interface for Bazaar branches