Commit bc660c42 authored by Tom Lane's avatar Tom Lane

Ah, I finally realize why Magnus wanted to add a --bindir option to

pg_regress: there's no other way to cope with testing a relocated
installation.  Seems better to call it --psqldir though, since the
only thing we need to find in that case is psql.  It'd be better if
we could use find_other_exec, but that's not happening unless we are
willing to install pg_regress alongside psql, which seems unlikely
to happen.
parent 9652b79a
# PGXS: PostgreSQL extensions makefile # PGXS: PostgreSQL extensions makefile
# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.8 2006/07/19 02:37:00 tgl Exp $ # $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.9 2006/07/21 00:24:04 tgl Exp $
# This file contains generic rules to build many kinds of simple # This file contains generic rules to build many kinds of simple
# extension modules. You only need to set a few variables and include # extension modules. You only need to set a few variables and include
...@@ -210,6 +210,9 @@ ifndef REGRESS_OPTS ...@@ -210,6 +210,9 @@ ifndef REGRESS_OPTS
REGRESS_OPTS = --dbname=$(CONTRIB_TESTDB) REGRESS_OPTS = --dbname=$(CONTRIB_TESTDB)
endif endif
# where to find psql for running the tests
PSQLDIR = $(bindir)
# When doing a VPATH build, must copy over the test .sql and .out # When doing a VPATH build, must copy over the test .sql and .out
# files so that the driver script can find them. We have to use an # files so that the driver script can find them. We have to use an
# absolute path for the targets, because otherwise make will try to # absolute path for the targets, because otherwise make will try to
...@@ -235,7 +238,7 @@ endif ...@@ -235,7 +238,7 @@ endif
# against installed postmaster # against installed postmaster
installcheck: submake installcheck: submake
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS) $(top_builddir)/src/test/regress/pg_regress --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
# in-tree test doesn't work yet (no way to install my shared library) # in-tree test doesn't work yet (no way to install my shared library)
#check: all submake #check: all submake
......
# Makefile for PL/Perl # Makefile for PL/Perl
# $PostgreSQL: pgsql/src/pl/plperl/GNUmakefile,v 1.27 2006/07/19 02:37:00 tgl Exp $ # $PostgreSQL: pgsql/src/pl/plperl/GNUmakefile,v 1.28 2006/07/21 00:24:04 tgl Exp $
subdir = src/pl/plperl subdir = src/pl/plperl
top_builddir = ../../.. top_builddir = ../../..
...@@ -38,6 +38,8 @@ SHLIB_LINK = $(perl_embed_ldflags) $(BE_DLLLIBS) ...@@ -38,6 +38,8 @@ SHLIB_LINK = $(perl_embed_ldflags) $(BE_DLLLIBS)
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plperl REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plperl
REGRESS = plperl plperl_trigger plperl_shared plperl_elog REGRESS = plperl plperl_trigger plperl_shared plperl_elog
# where to find psql for running the tests
PSQLDIR = $(bindir)
include $(top_srcdir)/src/Makefile.shlib include $(top_srcdir)/src/Makefile.shlib
...@@ -84,7 +86,7 @@ uninstall: ...@@ -84,7 +86,7 @@ uninstall:
rm -f '$(DESTDIR)$(pkglibdir)/plperl$(DLSUFFIX)' rm -f '$(DESTDIR)$(pkglibdir)/plperl$(DLSUFFIX)'
installcheck: submake installcheck: submake
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS) $(top_builddir)/src/test/regress/pg_regress --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
.PHONY: submake .PHONY: submake
submake: submake:
......
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.25 2006/07/19 02:37:00 tgl Exp $ # $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.26 2006/07/21 00:24:04 tgl Exp $
subdir = src/pl/plpython subdir = src/pl/plpython
top_builddir = ../../.. top_builddir = ../../..
...@@ -60,6 +60,8 @@ SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) $(python_additional_libs) ...@@ -60,6 +60,8 @@ SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) $(python_additional_libs)
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plpythonu REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plpythonu
REGRESS = plpython_schema plpython_populate plpython_function plpython_test plpython_error plpython_drop REGRESS = plpython_schema plpython_populate plpython_function plpython_test plpython_error plpython_drop
# where to find psql for running the tests
PSQLDIR = $(bindir)
include $(top_srcdir)/src/Makefile.shlib include $(top_srcdir)/src/Makefile.shlib
...@@ -103,7 +105,7 @@ uninstall: ...@@ -103,7 +105,7 @@ uninstall:
rm -f '$(DESTDIR)$(pkglibdir)/plpython$(DLSUFFIX)' rm -f '$(DESTDIR)$(pkglibdir)/plpython$(DLSUFFIX)'
installcheck: submake installcheck: submake
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS) $(top_builddir)/src/test/regress/pg_regress --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
.PHONY: submake .PHONY: submake
submake: submake:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# Makefile for the pltcl shared object # Makefile for the pltcl shared object
# #
# $PostgreSQL: pgsql/src/pl/tcl/Makefile,v 1.49 2006/07/19 02:37:00 tgl Exp $ # $PostgreSQL: pgsql/src/pl/tcl/Makefile,v 1.50 2006/07/21 00:24:04 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -42,6 +42,8 @@ OBJS = pltcl.o ...@@ -42,6 +42,8 @@ OBJS = pltcl.o
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=pltcl REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=pltcl
REGRESS = pltcl_setup pltcl_queries REGRESS = pltcl_setup pltcl_queries
# where to find psql for running the tests
PSQLDIR = $(bindir)
include $(top_srcdir)/src/Makefile.shlib include $(top_srcdir)/src/Makefile.shlib
...@@ -90,7 +92,7 @@ uninstall: ...@@ -90,7 +92,7 @@ uninstall:
$(MAKE) -C modules $@ $(MAKE) -C modules $@
installcheck: submake installcheck: submake
$(top_builddir)/src/test/regress/pg_regress $(REGRESS_OPTS) $(REGRESS) $(top_builddir)/src/test/regress/pg_regress --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
.PHONY: submake .PHONY: submake
submake: submake:
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.61 2006/07/20 01:16:57 tgl Exp $ # $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.62 2006/07/21 00:24:04 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -19,6 +19,9 @@ contribdir := $(top_builddir)/contrib ...@@ -19,6 +19,9 @@ contribdir := $(top_builddir)/contrib
# port number for temp-installation test postmaster # port number for temp-installation test postmaster
TEMP_PORT = 5$(DEF_PGPORT) TEMP_PORT = 5$(DEF_PGPORT)
# where to find psql for testing an existing installation
PSQLDIR = $(bindir)
# default encoding # default encoding
MULTIBYTE = SQL_ASCII MULTIBYTE = SQL_ASCII
...@@ -150,12 +153,12 @@ check: all ...@@ -150,12 +153,12 @@ check: all
installcheck: all installcheck: all
-rm -rf ./testtablespace -rm -rf ./testtablespace
mkdir ./testtablespace mkdir ./testtablespace
./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) ./pg_regress --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
installcheck-parallel: all installcheck-parallel: all
-rm -rf ./testtablespace -rm -rf ./testtablespace
mkdir ./testtablespace mkdir ./testtablespace
./pg_regress --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) ./pg_regress --psqldir=$(PSQLDIR) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
# old interfaces follow... # old interfaces follow...
...@@ -165,7 +168,7 @@ runtest: installcheck ...@@ -165,7 +168,7 @@ runtest: installcheck
runtest-parallel: installcheck-parallel runtest-parallel: installcheck-parallel
bigtest: bigtest:
./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) numeric_big ./pg_regress --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) numeric_big
bigcheck: bigcheck:
./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 ./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
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* pg_regress --- regression test driver * pg_regress --- regression test driver
* *
* This is a C implementation of the previous shell script for running * This is a C implementation of the previous shell script for running
* the regression tests, and should be highly compatible with it. * the regression tests, and should be mostly compatible with it.
* Initial author of C translation: Magnus Hagander * Initial author of C translation: Magnus Hagander
* *
* This code is released under the terms of the PostgreSQL License. * This code is released under the terms of the PostgreSQL License.
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.10 2006/07/20 16:25:30 tgl Exp $ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.11 2006/07/21 00:24:04 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -52,11 +52,11 @@ typedef struct _resultmap ...@@ -52,11 +52,11 @@ typedef struct _resultmap
} _resultmap; } _resultmap;
/* /*
* Values obtained from pg_config_paths.h and Makefile. (It might seem * Values obtained from pg_config_paths.h and Makefile. The PG installation
* tempting to get the paths via get_share_path() and friends, but that's * paths are only used in temp_install mode: we use these strings to find
* not going to work because pg_regress is typically not executed from an * out where "make install" will put stuff under the temp_install directory.
* installed bin directory. In any case, for our purposes the configured * In non-temp_install mode, the only thing we need is the location of psql,
* paths are what we want anyway.) * which we expect to find in psqldir, or in the PATH if psqldir isn't given.
*/ */
static char *bindir = PGBINDIR; static char *bindir = PGBINDIR;
static char *libdir = LIBDIR; static char *libdir = LIBDIR;
...@@ -85,6 +85,7 @@ static char *temp_install = NULL; ...@@ -85,6 +85,7 @@ static char *temp_install = NULL;
static char *top_builddir = NULL; static char *top_builddir = NULL;
static int temp_port = 65432; static int temp_port = 65432;
static bool nolocale = false; static bool nolocale = false;
static char *psqldir = NULL;
static char *hostname = NULL; static char *hostname = NULL;
static int port = -1; static int port = -1;
static char *user = NULL; static char *user = NULL;
...@@ -499,6 +500,9 @@ initialize_environment(void) ...@@ -499,6 +500,9 @@ initialize_environment(void)
sprintf(tmp, "%s/install/%s", temp_install, datadir); sprintf(tmp, "%s/install/%s", temp_install, datadir);
datadir = tmp; datadir = tmp;
/* psql will be installed into temp-install bindir */
psqldir = bindir;
/* /*
* Set up shared library paths to include the temp install. * Set up shared library paths to include the temp install.
* *
...@@ -539,7 +543,8 @@ initialize_environment(void) ...@@ -539,7 +543,8 @@ initialize_environment(void)
/* /*
* On Windows, it seems to be necessary to adjust PATH even in * On Windows, it seems to be necessary to adjust PATH even in
* this case. * this case. (XXX really? If so, what if installation has
* been relocated?)
*/ */
#ifdef WIN32 #ifdef WIN32
add_to_path("PATH", ';', libdir); add_to_path("PATH", ';', libdir);
...@@ -600,8 +605,11 @@ psql_command(const char *database, const char *query, ...) ...@@ -600,8 +605,11 @@ psql_command(const char *database, const char *query, ...)
/* And now we can build and execute the shell command */ /* And now we can build and execute the shell command */
snprintf(psql_cmd, sizeof(psql_cmd), snprintf(psql_cmd, sizeof(psql_cmd),
SYSTEMQUOTE "\"%s/psql\" -X -c \"%s\" \"%s\"" SYSTEMQUOTE, SYSTEMQUOTE "\"%s%spsql\" -X -c \"%s\" \"%s\"" SYSTEMQUOTE,
bindir, query_escaped, database); psqldir ? psqldir : "",
psqldir ? "/" : "",
query_escaped,
database);
if (system(psql_cmd) != 0) if (system(psql_cmd) != 0)
{ {
...@@ -699,8 +707,12 @@ psql_start_test(const char *testname) ...@@ -699,8 +707,12 @@ psql_start_test(const char *testname)
outputdir, testname); outputdir, testname);
snprintf(psql_cmd, sizeof(psql_cmd), snprintf(psql_cmd, sizeof(psql_cmd),
SYSTEMQUOTE "\"%s/psql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE, SYSTEMQUOTE "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
bindir, dbname, infile, outfile); psqldir ? psqldir : "",
psqldir ? "/" : "",
dbname,
infile,
outfile);
pid = spawn_process(psql_cmd); pid = spawn_process(psql_cmd);
...@@ -1267,6 +1279,7 @@ help(void) ...@@ -1267,6 +1279,7 @@ help(void)
printf(_(" --host=HOST use postmaster running on HOST\n")); printf(_(" --host=HOST use postmaster running on HOST\n"));
printf(_(" --port=PORT use postmaster running at PORT\n")); printf(_(" --port=PORT use postmaster running at PORT\n"));
printf(_(" --user=USER connect as USER\n")); printf(_(" --user=USER connect as USER\n"));
printf(_(" --psqldir=DIR use psql in DIR (default: find in PATH)\n"));
printf(_("\n")); printf(_("\n"));
printf(_("The exit status is 0 if all tests passed, 1 if some tests failed, and 2\n")); printf(_("The exit status is 0 if all tests passed, 1 if some tests failed, and 2\n"));
printf(_("if the tests could not be run for some reason.\n")); printf(_("if the tests could not be run for some reason.\n"));
...@@ -1301,6 +1314,7 @@ main(int argc, char *argv[]) ...@@ -1301,6 +1314,7 @@ main(int argc, char *argv[])
{"host", required_argument, NULL, 13}, {"host", required_argument, NULL, 13},
{"port", required_argument, NULL, 14}, {"port", required_argument, NULL, 14},
{"user", required_argument, NULL, 15}, {"user", required_argument, NULL, 15},
{"psqldir", required_argument, NULL, 16},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
...@@ -1388,6 +1402,11 @@ main(int argc, char *argv[]) ...@@ -1388,6 +1402,11 @@ main(int argc, char *argv[])
case 15: case 15:
user = strdup(optarg); user = strdup(optarg);
break; break;
case 16:
/* "--psqldir=" should mean to use PATH */
if (strlen(optarg))
psqldir = strdup(optarg);
break;
default: default:
/* getopt_long already emitted a complaint */ /* getopt_long already emitted a complaint */
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"), fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment