mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Rewrite pg_regress as a C program instead of a shell script.
This allows it to be used on Windows without installing mingw (though you do still need 'diff'), and opens the door to future improvements such as message localization. Magnus Hagander and Tom Lane.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# PGXS: PostgreSQL extensions makefile
|
||||
|
||||
# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.7 2005/12/09 21:19:36 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.8 2006/07/19 02:37:00 tgl Exp $
|
||||
|
||||
# This file contains generic rules to build many kinds of simple
|
||||
# extension modules. You only need to set a few variables and include
|
||||
@ -230,16 +230,16 @@ endif # VPATH
|
||||
.PHONY: submake
|
||||
submake:
|
||||
ifndef PGXS
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
||||
endif
|
||||
|
||||
# against installed postmaster
|
||||
installcheck: submake
|
||||
$(SHELL) $(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
|
||||
# in-tree test doesn't work yet (no way to install my shared library)
|
||||
#check: all submake
|
||||
# $(SHELL) $(top_builddir)/src/test/regress/pg_regress --temp-install \
|
||||
# $(top_builddir)/src/test/regress/pg_regress --temp-install \
|
||||
# --top-builddir=$(top_builddir) $(REGRESS_OPTS) $(REGRESS)
|
||||
check:
|
||||
@echo "'make check' is not supported."
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Makefile for PL/Perl
|
||||
# $PostgreSQL: pgsql/src/pl/plperl/GNUmakefile,v 1.26 2005/12/09 21:19:36 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/pl/plperl/GNUmakefile,v 1.27 2006/07/19 02:37:00 tgl Exp $
|
||||
|
||||
subdir = src/pl/plperl
|
||||
top_builddir = ../../..
|
||||
@ -84,11 +84,11 @@ uninstall:
|
||||
rm -f '$(DESTDIR)$(pkglibdir)/plperl$(DLSUFFIX)'
|
||||
|
||||
installcheck: submake
|
||||
$(SHELL) $(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
|
||||
.PHONY: submake
|
||||
submake:
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
||||
|
||||
clean distclean maintainer-clean: clean-lib
|
||||
rm -f SPI.c $(OBJS)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.24 2005/12/09 21:19:36 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.25 2006/07/19 02:37:00 tgl Exp $
|
||||
|
||||
subdir = src/pl/plpython
|
||||
top_builddir = ../../..
|
||||
@ -103,11 +103,11 @@ uninstall:
|
||||
rm -f '$(DESTDIR)$(pkglibdir)/plpython$(DLSUFFIX)'
|
||||
|
||||
installcheck: submake
|
||||
$(SHELL) $(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
|
||||
.PHONY: submake
|
||||
submake:
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
||||
|
||||
clean distclean maintainer-clean: clean-lib
|
||||
rm -f $(OBJS)
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Makefile for the pltcl shared object
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/pl/tcl/Makefile,v 1.48 2005/12/09 21:19:36 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/pl/tcl/Makefile,v 1.49 2006/07/19 02:37:00 tgl Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -90,11 +90,11 @@ uninstall:
|
||||
$(MAKE) -C modules $@
|
||||
|
||||
installcheck: submake
|
||||
$(SHELL) $(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS)
|
||||
|
||||
.PHONY: submake
|
||||
submake:
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress
|
||||
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
||||
|
||||
else # TCL_SHARED_BUILD = 0
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||
# Portions Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.57 2006/03/05 15:59:11 momjian Exp $
|
||||
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.58 2006/07/19 02:37:00 tgl Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -34,32 +34,33 @@ ifdef NO_LOCALE
|
||||
NOLOCALE += --no-locale
|
||||
endif
|
||||
|
||||
# stuff to pass into build of pg_regress
|
||||
EXTRADEFS = '-DPGBINDIR="$(bindir)"' \
|
||||
'-DLIBDIR="$(libdir)"' \
|
||||
'-DPGSHAREDIR="$(datadir)"' \
|
||||
'-DHOST_TUPLE="$(host_tuple)"' \
|
||||
'-DMAKEPROG="$(MAKE)"'
|
||||
|
||||
##
|
||||
## Prepare for tests
|
||||
##
|
||||
|
||||
# Build regression test driver
|
||||
|
||||
all: pg_regress
|
||||
all: submake-libpgport pg_regress$(X)
|
||||
|
||||
pg_regress: pg_regress.sh GNUmakefile $(top_builddir)/src/Makefile.global
|
||||
sed -e 's,@bindir@,$(bindir),g' \
|
||||
-e 's,@libdir@,$(libdir),g' \
|
||||
-e 's,@pkglibdir@,$(pkglibdir),g' \
|
||||
-e 's,@datadir@,$(datadir),g' \
|
||||
-e 's/@VERSION@/$(VERSION)/g' \
|
||||
-e 's/@host_tuple@/$(host_tuple)/g' \
|
||||
-e 's,@GMAKE@,$(MAKE),g' \
|
||||
-e 's/@enable_shared@/$(enable_shared)/g' \
|
||||
-e 's/@GCC@/$(GCC)/g' \
|
||||
$< >$@
|
||||
chmod a+x $@
|
||||
pg_regress$(X): pg_regress.o
|
||||
$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@
|
||||
|
||||
install: pg_regress
|
||||
$(INSTALL_SCRIPT) pg_regress '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress'
|
||||
# depend on Makefile.global to ensure that symbol changes propagate
|
||||
pg_regress.o: pg_regress.c $(top_builddir)/src/Makefile.global
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRADEFS) -c -o $@ $<
|
||||
|
||||
install: pg_regress$(X)
|
||||
$(INSTALL_PROGRAM) pg_regress$(X) '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
|
||||
|
||||
uninstall:
|
||||
rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress'
|
||||
rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
|
||||
|
||||
|
||||
# Build dynamically-loaded object file for CREATE FUNCTION ... LANGUAGE C.
|
||||
@ -143,17 +144,17 @@ all-spi:
|
||||
check: all
|
||||
-rm -rf ./testtablespace
|
||||
mkdir ./testtablespace
|
||||
$(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
|
||||
./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
|
||||
|
||||
installcheck: all
|
||||
-rm -rf ./testtablespace
|
||||
mkdir ./testtablespace
|
||||
$(SHELL) ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
|
||||
./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
|
||||
|
||||
installcheck-parallel: all
|
||||
-rm -rf ./testtablespace
|
||||
mkdir ./testtablespace
|
||||
$(SHELL) ./pg_regress --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
|
||||
./pg_regress --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
|
||||
|
||||
|
||||
# old interfaces follow...
|
||||
@ -163,10 +164,10 @@ runtest: installcheck
|
||||
runtest-parallel: installcheck-parallel
|
||||
|
||||
bigtest:
|
||||
$(SHELL) ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) numeric_big
|
||||
./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) numeric_big
|
||||
|
||||
bigcheck:
|
||||
$(SHELL) ./pg_regress --temp-install --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) numeric_big
|
||||
./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) numeric_big
|
||||
|
||||
|
||||
##
|
||||
@ -177,7 +178,7 @@ clean distclean maintainer-clean: clean-lib
|
||||
# things built by `all' target
|
||||
rm -f $(NAME)$(DLSUFFIX) $(OBJS)
|
||||
$(MAKE) -C $(contribdir)/spi clean
|
||||
rm -f $(output_files) $(input_files) pg_regress
|
||||
rm -f $(output_files) $(input_files) pg_regress.o pg_regress$(X)
|
||||
# things created by various check targets
|
||||
rm -rf testtablespace
|
||||
rm -rf results tmp_check log
|
||||
|
@ -7,6 +7,6 @@
|
||||
# GNU make uses a make file named "GNUmakefile" in preference to "Makefile"
|
||||
# if it exists. Postgres is shipped with a "GNUmakefile".
|
||||
|
||||
all install clean dep depend:
|
||||
all install clean dep depend check installcheck:
|
||||
@echo "You must use GNU make to use Postgres. It may be installed"
|
||||
@echo "on your system with the name 'gmake'."
|
||||
|
1601
src/test/regress/pg_regress.c
Normal file
1601
src/test/regress/pg_regress.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,777 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.65 2006/07/18 00:32:41 tgl Exp $
|
||||
|
||||
me=`basename $0`
|
||||
: ${TMPDIR=/tmp}
|
||||
TMPFILE=$TMPDIR/pg_regress.$$
|
||||
|
||||
help="\
|
||||
PostgreSQL regression test driver
|
||||
|
||||
Usage: $me [options...] [extra tests...]
|
||||
|
||||
Options:
|
||||
--dbname=DB use database DB (default \`regression')
|
||||
--debug turn on debug mode in programs that are run
|
||||
--inputdir=DIR take input files from DIR (default \`.')
|
||||
--load-language=lang load the named language before running the
|
||||
tests; can appear multiple times
|
||||
--max-connections=N maximum number of concurrent connections
|
||||
(default is 0 meaning unlimited)
|
||||
--multibyte=ENCODING use ENCODING as the multibyte encoding, and
|
||||
also run a test by the same name
|
||||
--outputdir=DIR place output files in DIR (default \`.')
|
||||
--schedule=FILE use test ordering schedule from FILE
|
||||
(may be used multiple times to concatenate)
|
||||
--temp-install[=DIR] create a temporary installation (in DIR)
|
||||
--no-locale use C locale
|
||||
|
||||
Options for \`temp-install' mode:
|
||||
--top-builddir=DIR (relative) path to top level build directory
|
||||
--temp-port=PORT port number to start temp postmaster on
|
||||
|
||||
Options for using an existing installation:
|
||||
--host=HOST use postmaster running on HOST
|
||||
--port=PORT use postmaster running at PORT
|
||||
--user=USER connect as USER
|
||||
|
||||
The exit status is 0 if all tests passed, 1 if some tests failed, and 2
|
||||
if the tests could not be run for some reason.
|
||||
|
||||
Report bugs to <pgsql-bugs@postgresql.org>."
|
||||
|
||||
|
||||
message(){
|
||||
_dashes='==============' # 14
|
||||
_spaces=' ' # 38
|
||||
_msg=`echo "$1$_spaces" | cut -c 1-38`
|
||||
echo "$_dashes $_msg $_dashes"
|
||||
}
|
||||
|
||||
|
||||
# ----------
|
||||
# Unset locale settings
|
||||
# ----------
|
||||
|
||||
unset LC_COLLATE LC_CTYPE LC_MONETARY LC_MESSAGES LC_NUMERIC LC_TIME LC_ALL LANG LANGUAGE
|
||||
|
||||
# On Windows the default locale may not be English, so force it
|
||||
case $host_platform in
|
||||
*-*-cygwin*|*-*-mingw32*)
|
||||
LANG=en
|
||||
export LANG
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# ----------
|
||||
# Check for echo -n vs echo \c
|
||||
# ----------
|
||||
|
||||
if echo '\c' | grep c >/dev/null 2>&1; then
|
||||
ECHO_N='echo -n'
|
||||
ECHO_C=''
|
||||
else
|
||||
ECHO_N='echo'
|
||||
ECHO_C='\c'
|
||||
fi
|
||||
|
||||
|
||||
# ----------
|
||||
# Initialize default settings
|
||||
# ----------
|
||||
|
||||
: ${inputdir=.}
|
||||
: ${outputdir=.}
|
||||
|
||||
libdir='@libdir@'
|
||||
bindir='@bindir@'
|
||||
datadir='@datadir@'
|
||||
host_platform='@host_tuple@'
|
||||
enable_shared='@enable_shared@'
|
||||
GCC=@GCC@
|
||||
|
||||
if [ "$GCC" = yes ]; then
|
||||
compiler=gcc
|
||||
else
|
||||
compiler=cc
|
||||
fi
|
||||
|
||||
unset mode
|
||||
unset schedule
|
||||
unset debug
|
||||
unset nolocale
|
||||
unset top_builddir
|
||||
unset temp_install
|
||||
unset multibyte
|
||||
|
||||
dbname=regression
|
||||
hostname=localhost
|
||||
maxconnections=0
|
||||
temp_port=65432
|
||||
load_langs=""
|
||||
|
||||
: ${GMAKE='@GMAKE@'}
|
||||
|
||||
|
||||
# ----------
|
||||
# Parse command line options
|
||||
# ----------
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case $1 in
|
||||
--help|-\?)
|
||||
echo "$help"
|
||||
exit 0;;
|
||||
--version)
|
||||
echo "pg_regress (PostgreSQL @VERSION@)"
|
||||
exit 0;;
|
||||
--dbname=*)
|
||||
dbname=`expr "x$1" : "x--dbname=\(.*\)"`
|
||||
shift;;
|
||||
--debug)
|
||||
debug=yes
|
||||
shift;;
|
||||
--inputdir=*)
|
||||
inputdir=`expr "x$1" : "x--inputdir=\(.*\)"`
|
||||
shift;;
|
||||
--load-language=*)
|
||||
lang=`expr "x$1" : "x--load-language=\(.*\)"`
|
||||
load_langs="$load_langs $lang"
|
||||
unset lang
|
||||
shift;;
|
||||
--multibyte=*)
|
||||
multibyte=`expr "x$1" : "x--multibyte=\(.*\)"`
|
||||
shift;;
|
||||
--no-locale)
|
||||
nolocale=yes
|
||||
shift;;
|
||||
--temp-install)
|
||||
temp_install=./tmp_check
|
||||
shift;;
|
||||
--temp-install=*)
|
||||
temp_install=`expr "x$1" : "x--temp-install=\(.*\)"`
|
||||
shift;;
|
||||
--max-connections=*)
|
||||
maxconnections=`expr "x$1" : "x--max-connections=\(.*\)"`
|
||||
shift;;
|
||||
--outputdir=*)
|
||||
outputdir=`expr "x$1" : "x--outputdir=\(.*\)"`
|
||||
shift;;
|
||||
--schedule=*)
|
||||
foo=`expr "x$1" : "x--schedule=\(.*\)"`
|
||||
schedule="$schedule $foo"
|
||||
shift;;
|
||||
--top-builddir=*)
|
||||
top_builddir=`expr "x$1" : "x--top-builddir=\(.*\)"`
|
||||
shift;;
|
||||
--temp-port=*)
|
||||
temp_port=`expr "x$1" : "x--temp-port=\(.*\)"`
|
||||
shift;;
|
||||
--host=*)
|
||||
PGHOST=`expr "x$1" : "x--host=\(.*\)"`
|
||||
export PGHOST
|
||||
unset PGHOSTADDR
|
||||
shift;;
|
||||
--port=*)
|
||||
PGPORT=`expr "x$1" : "x--port=\(.*\)"`
|
||||
export PGPORT
|
||||
shift;;
|
||||
--user=*)
|
||||
PGUSER=`expr "x$1" : "x--user=\(.*\)"`
|
||||
export PGUSER
|
||||
shift;;
|
||||
-*)
|
||||
echo "$me: invalid argument $1" 1>&2
|
||||
exit 2;;
|
||||
*)
|
||||
extra_tests="$extra_tests $1"
|
||||
shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ----------
|
||||
# warn of Cygwin likely failure if maxconnections = 0
|
||||
# and we are running parallel tests
|
||||
# ----------
|
||||
|
||||
case $host_platform in
|
||||
*-*-cygwin*)
|
||||
case "$schedule" in
|
||||
*parallel_schedule*)
|
||||
if [ $maxconnections -eq 0 ] ; then
|
||||
echo Using unlimited parallel connections is likely to fail or hang on Cygwin.
|
||||
echo Try \"$me --max-connections=n\" or \"gmake MAX_CONNECTIONS=n check\"
|
||||
echo with n = 5 or 10 if this happens.
|
||||
echo
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# ----------
|
||||
# On some platforms we can't use Unix sockets.
|
||||
# ----------
|
||||
case $host_platform in
|
||||
*-*-cygwin* | *-*-mingw32*)
|
||||
unix_sockets=no;;
|
||||
*)
|
||||
unix_sockets=yes;;
|
||||
esac
|
||||
|
||||
|
||||
# ----------
|
||||
# Set up diff to ignore horizontal white space differences.
|
||||
# ----------
|
||||
|
||||
case $host_platform in
|
||||
*-*-sco3.2v5*)
|
||||
DIFFFLAGS=-b;;
|
||||
*)
|
||||
DIFFFLAGS=-w;;
|
||||
esac
|
||||
|
||||
|
||||
# ----------
|
||||
# Set backend timezone and datestyle explicitly
|
||||
#
|
||||
# To pass the horology test in its current form, the postmaster must be
|
||||
# started with PGDATESTYLE=ISO, while the frontend must be started with
|
||||
# PGDATESTYLE=Postgres. We set the postmaster values here and change
|
||||
# to the frontend settings after the postmaster has been started.
|
||||
# ----------
|
||||
|
||||
PGTZ='PST8PDT'; export PGTZ
|
||||
PGDATESTYLE='ISO, MDY'; export PGDATESTYLE
|
||||
|
||||
|
||||
# ----------
|
||||
# Exit trap to remove temp file and shut down postmaster
|
||||
# ----------
|
||||
|
||||
# Note: There are some stupid shells (even among recent ones) that
|
||||
# ignore the argument to exit (as in `exit 1') if there is an exit
|
||||
# trap. The trap (and thus the shell script) will then always exit
|
||||
# with the result of the last shell command before the `exit'. Hence
|
||||
# we have to write `(exit x); exit' below this point.
|
||||
|
||||
exit_trap(){
|
||||
savestatus=$1
|
||||
if [ -n "$postmaster_pid" ]; then
|
||||
kill -2 "$postmaster_pid"
|
||||
wait "$postmaster_pid"
|
||||
unset postmaster_pid
|
||||
fi
|
||||
rm -f "$TMPFILE" && exit $savestatus
|
||||
}
|
||||
|
||||
trap 'exit_trap $?' 0
|
||||
|
||||
sig_trap() {
|
||||
savestatus=$1
|
||||
echo; echo "caught signal"
|
||||
if [ -n "$postmaster_pid" ]; then
|
||||
echo "signalling fast shutdown to postmaster with pid $postmaster_pid"
|
||||
kill -2 "$postmaster_pid"
|
||||
wait "$postmaster_pid"
|
||||
unset postmaster_pid
|
||||
fi
|
||||
(exit $savestatus); exit
|
||||
}
|
||||
|
||||
trap 'sig_trap $?' 1 2 13 15
|
||||
|
||||
|
||||
|
||||
# ----------
|
||||
# Scan resultmap file to find which platform-specific expected files to use.
|
||||
# The format of each line of the file is
|
||||
# testname/hostplatformpattern=substitutefile
|
||||
# where the hostplatformpattern is evaluated per the rules of expr(1),
|
||||
# namely, it is a standard regular expression with an implicit ^ at the start.
|
||||
# What hostplatformpattern will be matched against is the config.guess output
|
||||
# followed by either ':gcc' or ':cc' (independent of the actual name of the
|
||||
# compiler executable).
|
||||
#
|
||||
# The tempfile hackery is needed because some shells will run the loop
|
||||
# inside a subshell, whereupon shell variables set therein aren't seen
|
||||
# outside the loop :-(
|
||||
# ----------
|
||||
|
||||
cat /dev/null >$TMPFILE
|
||||
if [ -f "$inputdir/resultmap" ]
|
||||
then
|
||||
while read LINE
|
||||
do
|
||||
HOSTPAT=`expr "$LINE" : '.*/\(.*\)='`
|
||||
if [ `expr "$host_platform:$compiler" : "$HOSTPAT"` -ne 0 ]
|
||||
then
|
||||
# remove hostnamepattern from line so that there are no shell
|
||||
# wildcards in SUBSTLIST; else later 'for' could expand them!
|
||||
TESTNAME=`expr "$LINE" : '\(.*\)/'`
|
||||
SUBST=`echo "$LINE" | sed 's/^.*=//'`
|
||||
echo "$TESTNAME=$SUBST" >> $TMPFILE
|
||||
fi
|
||||
done <"$inputdir/resultmap"
|
||||
fi
|
||||
SUBSTLIST=`cat $TMPFILE`
|
||||
rm -f $TMPFILE
|
||||
|
||||
|
||||
LOGDIR=$outputdir/log
|
||||
|
||||
if [ x"$temp_install" != x"" ]
|
||||
then
|
||||
if echo x"$temp_install" | grep -v '^x/' >/dev/null 2>&1; then
|
||||
temp_install="`pwd`/$temp_install"
|
||||
fi
|
||||
|
||||
bindir=$temp_install/install/$bindir
|
||||
libdir=$temp_install/install/$libdir
|
||||
datadir=$temp_install/install/$datadir
|
||||
PGDATA=$temp_install/data
|
||||
|
||||
if [ "$unix_sockets" = no ]; then
|
||||
PGHOST=$hostname
|
||||
export PGHOST
|
||||
unset PGHOSTADDR
|
||||
else
|
||||
unset PGHOST
|
||||
unset PGHOSTADDR
|
||||
fi
|
||||
|
||||
# since Makefile isn't very bright, check for out-of-range temp_port
|
||||
if [ "$temp_port" -ge 1024 -a "$temp_port" -le 65535 ] ; then
|
||||
PGPORT=$temp_port
|
||||
else
|
||||
PGPORT=65432
|
||||
fi
|
||||
export PGPORT
|
||||
|
||||
# Get rid of environment stuff that might cause psql to misbehave
|
||||
# while contacting our temp installation
|
||||
unset PGDATABASE PGUSER PGSERVICE PGSSLMODE PGREQUIRESSL PGCONNECT_TIMEOUT
|
||||
|
||||
# ----------
|
||||
# Set up shared library paths, needed by psql and pg_encoding
|
||||
# (if you run multibyte). LD_LIBRARY_PATH covers many platforms.
|
||||
# DYLD_LIBRARY_PATH works on Darwin, and maybe other Mach-based systems.
|
||||
# Feel free to account for others as well.
|
||||
# ----------
|
||||
|
||||
if [ -n "$LD_LIBRARY_PATH" ]; then
|
||||
LD_LIBRARY_PATH="$libdir:$LD_LIBRARY_PATH"
|
||||
else
|
||||
LD_LIBRARY_PATH=$libdir
|
||||
fi
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
if [ -n "$DYLD_LIBRARY_PATH" ]; then
|
||||
DYLD_LIBRARY_PATH="$libdir:$DYLD_LIBRARY_PATH"
|
||||
else
|
||||
DYLD_LIBRARY_PATH=$libdir
|
||||
fi
|
||||
export DYLD_LIBRARY_PATH
|
||||
|
||||
# ----------
|
||||
# Windows needs shared libraries in PATH. (Only those linked into
|
||||
# executables, not dlopen'ed ones)
|
||||
# ----------
|
||||
case $host_platform in
|
||||
*-*-cygwin*|*-*-mingw32*)
|
||||
PATH=$libdir:$PATH
|
||||
export PATH
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -d "$temp_install" ]; then
|
||||
message "removing existing temp installation"
|
||||
rm -rf "$temp_install"
|
||||
fi
|
||||
|
||||
message "creating temporary installation"
|
||||
if [ ! -d "$LOGDIR" ]; then
|
||||
mkdir -p "$LOGDIR" || { (exit 2); exit; }
|
||||
fi
|
||||
$GMAKE -C "$top_builddir" DESTDIR="$temp_install/install" install with_perl=no with_python=no >"$LOGDIR/install.log" 2>&1
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo
|
||||
echo "$me: installation failed"
|
||||
echo "Examine $LOGDIR/install.log for the reason."
|
||||
echo
|
||||
(exit 2); exit
|
||||
fi
|
||||
|
||||
message "initializing database system"
|
||||
[ "$debug" = yes ] && initdb_options="--debug"
|
||||
[ "$nolocale" = yes ] && initdb_options="$initdb_options --no-locale"
|
||||
"$bindir/initdb" -D "$PGDATA" -L "$datadir" --noclean $initdb_options >"$LOGDIR/initdb.log" 2>&1
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo
|
||||
echo "$me: initdb failed"
|
||||
echo "Examine $LOGDIR/initdb.log for the reason."
|
||||
echo
|
||||
(exit 2); exit
|
||||
fi
|
||||
|
||||
|
||||
# ----------
|
||||
# Start postmaster
|
||||
# ----------
|
||||
|
||||
message "starting postmaster"
|
||||
[ "$debug" = yes ] && postmaster_options="$postmaster_options -d 5"
|
||||
if [ "$unix_sockets" = no ]; then
|
||||
postmaster_options="$postmaster_options -c listen_addresses=$hostname"
|
||||
else
|
||||
postmaster_options="$postmaster_options -c listen_addresses="
|
||||
fi
|
||||
"$bindir/postmaster" -D "$PGDATA" -F $postmaster_options >"$LOGDIR/postmaster.log" 2>&1 &
|
||||
postmaster_pid=$!
|
||||
|
||||
# Wait till postmaster is able to accept connections (normally only
|
||||
# a second or so, but Cygwin is reportedly *much* slower). Don't
|
||||
# wait forever, however.
|
||||
i=0
|
||||
max=60
|
||||
until "$bindir/psql" -X $psql_options postgres </dev/null 2>/dev/null
|
||||
do
|
||||
i=`expr $i + 1`
|
||||
if [ $i -ge $max ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
if kill -0 $postmaster_pid >/dev/null 2>&1
|
||||
then
|
||||
: still starting up
|
||||
else
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if kill -0 $postmaster_pid >/dev/null 2>&1
|
||||
then
|
||||
echo "running on port $PGPORT with pid $postmaster_pid"
|
||||
else
|
||||
echo
|
||||
echo "$me: postmaster did not start"
|
||||
echo "Examine $LOGDIR/postmaster.log for the reason."
|
||||
echo
|
||||
(exit 2); exit
|
||||
fi
|
||||
|
||||
else # not temp-install
|
||||
|
||||
# ----------
|
||||
# Windows needs shared libraries in PATH. (Only those linked into
|
||||
# executables, not dlopen'ed ones)
|
||||
# ----------
|
||||
case $host_platform in
|
||||
*-*-cygwin*|*-*-mingw32*)
|
||||
PATH=$libdir:$PATH
|
||||
export PATH
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$PGPORT" ]; then
|
||||
port_info="port $PGPORT"
|
||||
else
|
||||
port_info="default port"
|
||||
fi
|
||||
|
||||
if [ -n "$PGHOST" ]; then
|
||||
echo "(using postmaster on $PGHOST, $port_info)"
|
||||
else
|
||||
if [ "$unix_sockets" = no ]; then
|
||||
echo "(using postmaster on localhost, $port_info)"
|
||||
else
|
||||
echo "(using postmaster on Unix socket, $port_info)"
|
||||
fi
|
||||
fi
|
||||
|
||||
message "dropping database \"$dbname\""
|
||||
"$bindir/dropdb" $psql_options "$dbname"
|
||||
# errors can be ignored
|
||||
fi
|
||||
|
||||
|
||||
# ----------
|
||||
# Set up SQL shell for the test.
|
||||
# ----------
|
||||
|
||||
psql_test_options="-a -q -X $psql_options"
|
||||
|
||||
|
||||
# ----------
|
||||
# Set frontend timezone and datestyle explicitly
|
||||
# ----------
|
||||
|
||||
PGTZ='PST8PDT'; export PGTZ
|
||||
PGDATESTYLE='Postgres, MDY'; export PGDATESTYLE
|
||||
|
||||
|
||||
# ----------
|
||||
# Set up multibyte environment
|
||||
# ----------
|
||||
|
||||
if [ -n "$multibyte" ]; then
|
||||
PGCLIENTENCODING=$multibyte
|
||||
export PGCLIENTENCODING
|
||||
encoding_opt="-E $multibyte"
|
||||
else
|
||||
unset PGCLIENTENCODING
|
||||
fi
|
||||
|
||||
|
||||
# ----------
|
||||
# Create the regression database
|
||||
# We use template0 so that any installation-local cruft in template1
|
||||
# will not mess up the tests.
|
||||
# ----------
|
||||
|
||||
message "creating database \"$dbname\""
|
||||
"$bindir/createdb" $encoding_opt $psql_options --template template0 "$dbname"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$me: createdb failed"
|
||||
(exit 2); exit
|
||||
fi
|
||||
|
||||
"$bindir/psql" -q -X $psql_options -c "\
|
||||
alter database \"$dbname\" set lc_messages to 'C';
|
||||
alter database \"$dbname\" set lc_monetary to 'C';
|
||||
alter database \"$dbname\" set lc_numeric to 'C';
|
||||
alter database \"$dbname\" set lc_time to 'C';" "$dbname"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$me: could not set database default locales"
|
||||
(exit 2); exit
|
||||
fi
|
||||
|
||||
|
||||
# ----------
|
||||
# Install any requested PL languages
|
||||
# ----------
|
||||
|
||||
if [ "$enable_shared" = yes ]; then
|
||||
for lang in xyzzy $load_langs ; do
|
||||
if [ "$lang" != "xyzzy" ]; then
|
||||
message "installing $lang"
|
||||
"$bindir/createlang" $psql_options $lang $dbname
|
||||
if [ $? -ne 0 ] && [ $? -ne 2 ]; then
|
||||
echo "$me: createlang $lang failed"
|
||||
(exit 2); exit
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# ----------
|
||||
# Let's go
|
||||
# ----------
|
||||
|
||||
message "running regression test queries"
|
||||
|
||||
if [ ! -d "$outputdir/results" ]; then
|
||||
mkdir -p "$outputdir/results" || { (exit 2); exit; }
|
||||
fi
|
||||
result_summary_file=$outputdir/regression.out
|
||||
diff_file=$outputdir/regression.diffs
|
||||
|
||||
cat /dev/null >"$result_summary_file"
|
||||
cat /dev/null >"$diff_file"
|
||||
|
||||
lno=0
|
||||
(
|
||||
[ "$enable_shared" != yes ] && echo "ignore: plpgsql"
|
||||
cat $schedule </dev/null
|
||||
for x in $extra_tests; do
|
||||
echo "test: $x"
|
||||
done
|
||||
) | sed 's/[ ]*#.*//g' | \
|
||||
while read line
|
||||
do
|
||||
# Count line numbers
|
||||
lno=`expr $lno + 1`
|
||||
[ -z "$line" ] && continue
|
||||
|
||||
set X $line; shift
|
||||
|
||||
if [ x"$1" = x"ignore:" ]; then
|
||||
shift
|
||||
ignore_list="$ignore_list $@"
|
||||
continue
|
||||
elif [ x"$1" != x"test:" ]; then
|
||||
echo "$me:$schedule:$lno: syntax error"
|
||||
(exit 2); exit
|
||||
fi
|
||||
|
||||
shift
|
||||
|
||||
# ----------
|
||||
# Start tests
|
||||
# ----------
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
# Run a single test
|
||||
formatted=`echo $1 | awk '{printf "%-20.20s", $1;}'`
|
||||
$ECHO_N "test $formatted ... $ECHO_C"
|
||||
( "$bindir/psql" $psql_test_options -d "$dbname" <"$inputdir/sql/$1.sql" >"$outputdir/results/$1.out" 2>&1 )&
|
||||
wait
|
||||
else
|
||||
# Start a parallel group
|
||||
$ECHO_N "parallel group ($# tests): $ECHO_C"
|
||||
if [ $maxconnections -gt 0 ] ; then
|
||||
connnum=0
|
||||
test $# -gt $maxconnections && $ECHO_N "(in groups of $maxconnections) $ECHO_C"
|
||||
fi
|
||||
for name do
|
||||
(
|
||||
"$bindir/psql" $psql_test_options -d "$dbname" <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1
|
||||
$ECHO_N " $name$ECHO_C"
|
||||
) &
|
||||
if [ $maxconnections -gt 0 ] ; then
|
||||
connnum=`expr \( $connnum + 1 \) % $maxconnections`
|
||||
test $connnum -eq 0 && wait
|
||||
fi
|
||||
done
|
||||
wait
|
||||
echo
|
||||
fi
|
||||
|
||||
# ----------
|
||||
# Run diff
|
||||
# (We do not want to run the diffs immediately after each test,
|
||||
# because they would certainly get corrupted if run in parallel
|
||||
# subshells.)
|
||||
# ----------
|
||||
|
||||
for name do
|
||||
if [ $# -ne 1 ]; then
|
||||
formatted=`echo "$name" | awk '{printf "%-20.20s", $1;}'`
|
||||
$ECHO_N " $formatted ... $ECHO_C"
|
||||
fi
|
||||
|
||||
# Check list extracted from resultmap to see if we should compare
|
||||
# to a system-specific expected file.
|
||||
# There shouldn't be multiple matches, but take the last if there are.
|
||||
|
||||
EXPECTED="$inputdir/expected/${name}"
|
||||
for LINE in $SUBSTLIST
|
||||
do
|
||||
if [ `expr "$LINE" : "$name="` -ne 0 ]
|
||||
then
|
||||
SUBST=`echo "$LINE" | sed 's/^.*=//'`
|
||||
EXPECTED="$inputdir/expected/${SUBST}"
|
||||
fi
|
||||
done
|
||||
|
||||
# If there are multiple equally valid result files, loop to get the right one.
|
||||
# If none match, diff against the closest one.
|
||||
|
||||
bestfile=
|
||||
bestdiff=
|
||||
result=2
|
||||
for thisfile in $EXPECTED.out ${EXPECTED}_[0-9].out; do
|
||||
[ ! -r "$thisfile" ] && continue
|
||||
diff $DIFFFLAGS $thisfile $outputdir/results/${name}.out >/dev/null 2>&1
|
||||
result=$?
|
||||
case $result in
|
||||
0) break;;
|
||||
1) thisdiff=`diff $DIFFFLAGS $thisfile $outputdir/results/${name}.out | wc -l`
|
||||
if [ -z "$bestdiff" ] || [ "$thisdiff" -lt "$bestdiff" ]; then
|
||||
bestdiff=$thisdiff; bestfile=$thisfile
|
||||
fi
|
||||
continue;;
|
||||
2) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Now print the result.
|
||||
|
||||
case $result in
|
||||
0)
|
||||
echo "ok";;
|
||||
1)
|
||||
( diff $DIFFFLAGS -C3 $bestfile $outputdir/results/${name}.out
|
||||
echo
|
||||
echo "======================================================================"
|
||||
echo ) >> "$diff_file"
|
||||
if echo " $ignore_list " | grep " $name " >/dev/null 2>&1 ; then
|
||||
echo "failed (ignored)"
|
||||
else
|
||||
echo "FAILED"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
# disaster struck
|
||||
echo "trouble" 1>&2
|
||||
(exit 2); exit;;
|
||||
esac
|
||||
done
|
||||
done | tee "$result_summary_file" 2>&1
|
||||
|
||||
[ $? -ne 0 ] && exit
|
||||
|
||||
# ----------
|
||||
# Server shutdown
|
||||
# ----------
|
||||
|
||||
if [ -n "$postmaster_pid" ]; then
|
||||
message "shutting down postmaster"
|
||||
"$bindir/pg_ctl" -s -D "$PGDATA" stop
|
||||
wait "$postmaster_pid"
|
||||
unset postmaster_pid
|
||||
fi
|
||||
|
||||
rm -f "$TMPFILE"
|
||||
|
||||
|
||||
# ----------
|
||||
# Evaluation
|
||||
# ----------
|
||||
|
||||
count_total=`cat "$result_summary_file" | grep '\.\.\.' | wc -l | sed 's/ //g'`
|
||||
count_ok=`cat "$result_summary_file" | grep '\.\.\. ok' | wc -l | sed 's/ //g'`
|
||||
count_failed=`cat "$result_summary_file" | grep '\.\.\. FAILED' | wc -l | sed 's/ //g'`
|
||||
count_ignored=`cat "$result_summary_file" | grep '\.\.\. failed (ignored)' | wc -l | sed 's/ //g'`
|
||||
|
||||
echo
|
||||
if [ $count_total -eq $count_ok ]; then
|
||||
msg="All $count_total tests passed."
|
||||
result=0
|
||||
elif [ $count_failed -eq 0 ]; then
|
||||
msg="$count_ok of $count_total tests passed, $count_ignored failed test(s) ignored."
|
||||
result=0
|
||||
elif [ $count_ignored -eq 0 ]; then
|
||||
msg="$count_failed of $count_total tests failed."
|
||||
result=1
|
||||
else
|
||||
msg="`expr $count_failed + $count_ignored` of $count_total tests failed, $count_ignored of these failures ignored."
|
||||
result=1
|
||||
fi
|
||||
|
||||
dashes=`echo " $msg " | sed 's/./=/g'`
|
||||
echo "$dashes"
|
||||
echo " $msg "
|
||||
echo "$dashes"
|
||||
echo
|
||||
|
||||
if [ -s "$diff_file" ]; then
|
||||
echo "The differences that caused some tests to fail can be viewed in the"
|
||||
echo "file \`$diff_file'. A copy of the test summary that you see"
|
||||
echo "above is saved in the file \`$result_summary_file'."
|
||||
echo
|
||||
else
|
||||
rm -f "$diff_file" "$result_summary_file"
|
||||
fi
|
||||
|
||||
|
||||
(exit $result); exit
|
Reference in New Issue
Block a user