-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtestsuite
executable file
·108 lines (95 loc) · 2.77 KB
/
testsuite
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh -e
# Run integration tests (on the installed package).
#
# (C) 2005-2009 Martin Pitt <[email protected]>
# (C) 2012 Christoph Berg <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# default config
TESTSDIR="$(dirname $0)/t"
UMASKS="022 077"
help ()
{
echo "postgresql-common testsuite"
echo "Syntax: $0 [options] [test ...]"
echo " -u 'umask ...' list of umasks to run testsuite with [default: 022 077]"
exit ${1:-0}
}
# option parsing
while getopts "hu:" opt ; do
case $opt in
h) help ;;
u) UMASKS="$OPTARG" ;;
*) help 1 ;;
esac
done
# shift away args
shift $(($OPTIND - 1))
if [ "$(id -u)" != 0 ]; then
echo "Error: this test suite needs to be run as root" >&2
exit 1
fi
# always clean up behind us
trap '
if [ -d /etc/postgresql.testsuite ]; then
rm -rf /etc/postgresql;
mv /etc/postgresql.testsuite /etc/postgresql;
fi;
if [ -d /var/lib/postgresql.testsuite ]; then
rm -rf /var/lib/postgresql;
mv /var/lib/postgresql.testsuite /var/lib/postgresql;
fi;
if [ -d /var/log/postgresql.testsuite ]; then
rm -rf /var/log/postgresql;
mv /var/log/postgresql.testsuite /var/log/postgresql;
fi' 0 1 2 3 5 7 10 13 15
# temporarily move away existing clusters
for v in $(ls /usr/lib/postgresql/); do
if [ -x "/etc/init.d/postgresql-$v" ]; then
/etc/init.d/postgresql-$v stop
fi
done
if [ -x "/etc/init.d/postgresql" ]; then
/etc/init.d/postgresql stop
fi
if [ -d /etc/postgresql ]; then
mv /etc/postgresql /etc/postgresql.testsuite;
fi
if [ -d /var/lib/postgresql ]; then
mv /var/lib/postgresql /var/lib/postgresql.testsuite;
fi
if [ -d /var/log/postgresql ]; then
mv /var/log/postgresql /var/log/postgresql.testsuite;
install -d -m 1775 -o root -g postgres /var/log/postgresql
fi
# reset core limit for pg_ctl tests
ulimit -S -c 0
# set variables which cause taint check errors
export IFS=' '
export CDPATH=/usr
export ENV=/nonexisting
export BASH_ENV=/nonexisting
if [ $# -eq 0 ]; then
set -- $TESTSDIR/*.t
fi
for U in $UMASKS; do
case $U in
022) TYPE="default" ;;
077) TYPE="tight" ;;
*) TYPE="custom" ;;
esac
echo "====== Running all tests with $TYPE umask $U ======="
umask $U
for T; do
echo "=== Running test `basename $T`... ==="
perl $T
done
done