regress.sh 3.8 KB
Newer Older
1
#!/bin/sh
2
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.40 2000/02/13 21:45:15 petere Exp $
3
#
4
if [ $# -eq 0 ]
5
then
6
	echo "Syntax: $0 <hostname> [extra-tests]"
7 8 9
	exit 1
fi

10
hostname=$1
11 12 13
shift
extratests="$*"

14
if [ "x$hostname" = "xwin" -o "x$hostname" = "xqnx4" ]
15
then
16
	HOSTLOC="-h localhost"
17
else
18
	HOSTLOC=""
19 20
fi

21 22 23 24 25 26 27 28 29
if echo '\c' | grep -s c >/dev/null 2>&1
then
	ECHO_N="echo -n"
	ECHO_C=""
else
	ECHO_N="echo"
	ECHO_C='\c'
fi

30 31
PGTZ="PST8PDT"; export PGTZ
PGDATESTYLE="Postgres,US"; export PGDATESTYLE
B
Bruce Momjian 已提交
32

33
FRONTEND="psql $HOSTLOC -a -q"
34

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
# ----------
# Scan resultmap file to find which platform-specific expected files to use.
# The format of each line of the file is
#		testname/hostnamepattern=substitutefile
# where the hostnamepattern is evaluated per the rules of expr(1) --- namely,
# it is a standard regular expression with an implicit ^ at the start.
# ----------
SUBSTLIST=""
exec 4<resultmap
while read LINE <&4
do
	HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
	if [ `expr "$hostname" : "$HOSTPAT"` -ne 0 ]
	then
		SUBSTLIST="$SUBSTLIST $LINE"
	fi
done
exec 4<&-

if [ -d ./obj ]; then
	cd ./obj
fi

58 59
echo "=============== Notes...                              ================="
echo "postmaster must already be running for the regression tests to succeed."
60
echo "Please report any apparent problems to ports@postgresql.org"
61
echo "See regress/README for more information."
62
echo ""
63

T
Thomas G. Lockhart 已提交
64
echo "=============== dropping old regression database...   ================="
65
dropdb $HOSTLOC regression
66

67
echo "=============== creating new regression database...   ================="
M
 
Marc G. Fournier 已提交
68
if [ -n "$MULTIBYTE" ];then
69 70 71
	mbtests=`echo $MULTIBYTE | tr "[A-Z]" "[a-z]"`
	PGCLIENTENCODING="$MULTIBYTE"
	export PGCLIENTENCODING
72
	ENCODINGOPT="-E $MULTIBYTE"
M
Marc G. Fournier 已提交
73 74
else
	mbtests=""
75
	unset PGCLIENTENCODING
76
	ENCODINGOPT=""
M
Marc G. Fournier 已提交
77
fi
78
createdb $ENCODINGOPT $HOSTLOC regression
79 80 81 82 83
if [ $? -ne 0 ]; then
     echo createdb failed
     exit 1
fi

84
if [ "x$hostname" != "xqnx4" ]
85
then
86
echo "=============== installing PL/pgSQL...                ================="
87
createlang $HOSTLOC plpgsql regression
88
if [ $? -ne 0 -a $? -ne 2 ]; then
89 90 91
     echo createlang failed
     exit 1
fi
92
fi
93

94 95
echo "=============== running regression queries...         ================="
echo "" > regression.diffs
96

97
if [ "x$hostname" = "xqnx4" ]
98 99 100 101 102 103
then
	DIFFOPT="-b"
else
	DIFFOPT="-w"
fi

104 105 106 107 108
stdtests=`awk '
$1=="test"	{ print $2; }
			{}
' < sql/run_check.tests`

109
for tst in $stdtests $mbtests $extratests
110
do
111 112 113 114
	$ECHO_N "${tst} .. " $ECHO_C
	$FRONTEND regression < sql/${tst}.sql > results/${tst}.out 2>&1

	#
115 116
	# Check list extracted from resultmap to see if we should compare
	# to a system-specific expected file.
117 118 119
	# There shouldn't be multiple matches, but take the last if there are.
	#
	EXPECTED="expected/${tst}.out"
120 121 122 123 124 125
	for LINE in $SUBSTLIST
	do
		if [ `expr "$LINE" : "$tst/"` -ne 0 ]
		then
			SUBST=`echo "$LINE" | sed 's/^.*=//'`
			EXPECTED="expected/${SUBST}.out"
126
		fi
127
	done
128 129

	if [ `diff ${DIFFOPT} ${EXPECTED} results/${tst}.out | wc -l` -ne 0 ]
130
	then
131
		( diff ${DIFFOPT} -C3 ${EXPECTED} results/${tst}.out; \
132 133 134
		echo "";  \
		echo "----------------------"; \
		echo "" ) >> regression.diffs
135 136 137 138 139
		echo failed
	else
		echo ok
	fi
done
140 141

exit 0
142

143
echo "=============== running error queries ...             ================="
144
$FRONTEND regression < errors.sql
145
# this will generate error result code
146 147 148 149 150 151 152 153

#set this to 1 to avoid clearing the database
debug=0

if test "$debug" -eq 1
then
echo Skipping clearing and deletion of the regression database
else
154
echo "=============== clearing regression database...       ================="
155
$FRONTEND regression < drop.sql
156
if [ $? -ne 0 ]; then
157
     echo the drop script has an error
158 159 160 161
     exit 1
fi

exit 0
T
Thomas G. Lockhart 已提交
162
echo "=============== dropping regression database...       ================="
163
dropdb regression
164
if [ $? -ne 0 ]; then
165
     echo dropdb failed
166 167 168 169 170
     exit 1
fi

exit 0
fi