]> granicus.if.org Git - postgresql/blob - src/test/regress/regress.sh
cf5dc2409cdb68943a6e7ca2228f8363ce777c4c
[postgresql] / src / test / regress / regress.sh
1 #!/bin/sh
2 # $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.44 2000/03/14 23:06:55 thomas Exp $
3 #
4 if [ $# -eq 0 ]; then
5         echo "Syntax: $0 <hostname> [extra-tests]"
6         exit 1
7 fi
8
9 hostname=$1
10 shift
11 extratests="$*"
12
13 if [ "x$hostname" = "xwin" -o "x$hostname" = "xi386-pc-qnx4" ]; then
14         HOSTLOC="-h localhost"
15 else
16         HOSTLOC=""
17 fi
18
19 if echo '\c' | grep -s c >/dev/null 2>&1
20 then
21         ECHO_N="echo -n"
22         ECHO_C=""
23 else
24         ECHO_N="echo"
25         ECHO_C='\c'
26 fi
27
28 PGTZ="PST8PDT"; export PGTZ
29 PGDATESTYLE="Postgres,US"; export PGDATESTYLE
30
31 FRONTEND="psql $HOSTLOC -a -q -X"
32
33 # ----------
34 # Scan resultmap file to find which platform-specific expected files to use.
35 # The format of each line of the file is
36 #               testname/hostnamepattern=substitutefile
37 # where the hostnamepattern is evaluated per the rules of expr(1) --- namely,
38 # it is a standard regular expression with an implicit ^ at the start.
39 # ----------
40 SUBSTLIST=""
41 RESULTMAP=`cat resultmap`
42 for LINE in $RESULTMAP
43 do
44         HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
45         if [ `expr "$hostname" : "$HOSTPAT"` -ne 0 ]
46         then
47                 SUBSTLIST="$SUBSTLIST $LINE"
48         fi
49 done
50
51 if [ -d ./obj ]; then
52         cd ./obj
53 fi
54
55 echo "=============== Notes...                              ================="
56 echo "postmaster must already be running for the regression tests to succeed."
57 echo "The time zone is set to PST8PDT for these tests by the client frontend."
58 echo "Please report any apparent problems to ports@postgresql.org"
59 echo "See regress/README for more information."
60 echo ""
61
62 echo "=============== dropping old regression database...   ================="
63 dropdb $HOSTLOC regression
64
65 echo "=============== creating new regression database...   ================="
66 if [ -n "$MULTIBYTE" ];then
67         mbtests=`echo $MULTIBYTE | tr "[A-Z]" "[a-z]"`
68         PGCLIENTENCODING="$MULTIBYTE"
69         export PGCLIENTENCODING
70         ENCODINGOPT="-E $MULTIBYTE"
71 else
72         mbtests=""
73         unset PGCLIENTENCODING
74         ENCODINGOPT=""
75 fi
76 createdb $ENCODINGOPT $HOSTLOC regression
77 if [ $? -ne 0 ]; then
78      echo createdb failed
79      exit 1
80 fi
81
82 if [ "x$hostname" != "xi386-pc-qnx4" ]; then
83 echo "=============== installing languages...                ================="
84 $ECHO_N "installing PL/pgSQL .. " $ECHO_C
85 createlang $HOSTLOC plpgsql regression
86 if [ $? -ne 0 -a $? -ne 2 ]; then
87      echo failed
88      exit 1
89 else
90         echo ok
91 fi
92 fi
93
94 echo "=============== running regression queries...         ================="
95 echo "" > regression.diffs
96
97 if [ "x$hostname" = "xi386-pc-qnx4" ]; then
98         DIFFOPT="-b"
99 else
100         DIFFOPT="-w"
101 fi
102
103 stdtests=`awk '
104 $1=="test"      { print $2; }
105                         {}
106 ' < sql/run_check.tests`
107
108 for tst in $stdtests $mbtests $extratests
109 do
110         $ECHO_N "${tst} .. " $ECHO_C
111         $FRONTEND regression < sql/${tst}.sql > results/${tst}.out 2>&1
112
113         #
114         # Check list extracted from resultmap to see if we should compare
115         # to a system-specific expected file.
116         # There shouldn't be multiple matches, but take the last if there are.
117         #
118         EXPECTED="expected/${tst}.out"
119         for LINE in $SUBSTLIST
120         do
121                 if [ `expr "$LINE" : "$tst/"` -ne 0 ]
122                 then
123                         SUBST=`echo "$LINE" | sed 's/^.*=//'`
124                         EXPECTED="expected/${SUBST}.out"
125                 fi
126         done
127
128         if [ `diff ${DIFFOPT} ${EXPECTED} results/${tst}.out | wc -l` -ne 0 ]; then
129                 ( diff ${DIFFOPT} -C3 ${EXPECTED} results/${tst}.out; \
130                 echo "";  \
131                 echo "----------------------"; \
132                 echo "" ) >> regression.diffs
133                 echo failed
134         else
135                 echo ok
136         fi
137 done
138
139 exit 0
140
141 echo "=============== running error queries ...             ================="
142 $FRONTEND regression < errors.sql
143 # this will generate error result code
144
145 #set this to 1 to avoid clearing the database
146 debug=0
147
148 if [ test "$debug" -eq 1 ]; then
149         echo Skipping clearing and deletion of the regression database
150 else
151         echo "=============== clearing regression database...       ================="
152         $FRONTEND regression < drop.sql
153         if [ $? -ne 0 ]; then
154                 echo the drop script has an error
155                 exit 1
156         fi
157
158         exit 0
159         echo "=============== dropping regression database...       ================="
160         dropdb regression
161         if [ $? -ne 0 ]; then
162                 echo dropdb failed
163                 exit 1
164         fi
165
166         exit 0
167 fi