summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2006-07-21 00:24:04 +0000
committerTom Lane2006-07-21 00:24:04 +0000
commitbc660c423731a3b68fb9c1e61a3ab8812dc8d55d (patch)
tree635fde8b69f31637743b6db10fc2a2019af0ac8a /src/test
parent9652b79ae417cd10aa611b3cfdc9c8e6225555cc (diff)
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.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/GNUmakefile11
-rw-r--r--src/test/regress/pg_regress.c43
2 files changed, 38 insertions, 16 deletions
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index cb22a1c55c6..f2319d2a79b 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -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.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
# port number for temp-installation test postmaster
TEMP_PORT = 5$(DEF_PGPORT)
+# where to find psql for testing an existing installation
+PSQLDIR = $(bindir)
+
# default encoding
MULTIBYTE = SQL_ASCII
@@ -150,12 +153,12 @@ check: all
installcheck: all
-rm -rf ./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
-rm -rf ./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...
@@ -165,7 +168,7 @@ runtest: installcheck
runtest-parallel: installcheck-parallel
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:
./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
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index f99231c907a..ebc03114b53 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -3,7 +3,7 @@
* pg_regress --- regression test driver
*
* 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
*
* This code is released under the terms of the PostgreSQL License.
@@ -11,7 +11,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/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
} _resultmap;
/*
- * Values obtained from pg_config_paths.h and Makefile. (It might seem
- * tempting to get the paths via get_share_path() and friends, but that's
- * not going to work because pg_regress is typically not executed from an
- * installed bin directory. In any case, for our purposes the configured
- * paths are what we want anyway.)
+ * Values obtained from pg_config_paths.h and Makefile. The PG installation
+ * paths are only used in temp_install mode: we use these strings to find
+ * out where "make install" will put stuff under the temp_install directory.
+ * In non-temp_install mode, the only thing we need is the location of psql,
+ * which we expect to find in psqldir, or in the PATH if psqldir isn't given.
*/
static char *bindir = PGBINDIR;
static char *libdir = LIBDIR;
@@ -85,6 +85,7 @@ static char *temp_install = NULL;
static char *top_builddir = NULL;
static int temp_port = 65432;
static bool nolocale = false;
+static char *psqldir = NULL;
static char *hostname = NULL;
static int port = -1;
static char *user = NULL;
@@ -499,6 +500,9 @@ initialize_environment(void)
sprintf(tmp, "%s/install/%s", temp_install, datadir);
datadir = tmp;
+ /* psql will be installed into temp-install bindir */
+ psqldir = bindir;
+
/*
* Set up shared library paths to include the temp install.
*
@@ -539,7 +543,8 @@ initialize_environment(void)
/*
* 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
add_to_path("PATH", ';', libdir);
@@ -600,8 +605,11 @@ psql_command(const char *database, const char *query, ...)
/* And now we can build and execute the shell command */
snprintf(psql_cmd, sizeof(psql_cmd),
- SYSTEMQUOTE "\"%s/psql\" -X -c \"%s\" \"%s\"" SYSTEMQUOTE,
- bindir, query_escaped, database);
+ SYSTEMQUOTE "\"%s%spsql\" -X -c \"%s\" \"%s\"" SYSTEMQUOTE,
+ psqldir ? psqldir : "",
+ psqldir ? "/" : "",
+ query_escaped,
+ database);
if (system(psql_cmd) != 0)
{
@@ -699,8 +707,12 @@ psql_start_test(const char *testname)
outputdir, testname);
snprintf(psql_cmd, sizeof(psql_cmd),
- SYSTEMQUOTE "\"%s/psql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
- bindir, dbname, infile, outfile);
+ SYSTEMQUOTE "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
+ psqldir ? psqldir : "",
+ psqldir ? "/" : "",
+ dbname,
+ infile,
+ outfile);
pid = spawn_process(psql_cmd);
@@ -1267,6 +1279,7 @@ help(void)
printf(_(" --host=HOST use postmaster running on HOST\n"));
printf(_(" --port=PORT use postmaster running at PORT\n"));
printf(_(" --user=USER connect as USER\n"));
+ printf(_(" --psqldir=DIR use psql in DIR (default: find in PATH)\n"));
printf(_("\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"));
@@ -1301,6 +1314,7 @@ main(int argc, char *argv[])
{"host", required_argument, NULL, 13},
{"port", required_argument, NULL, 14},
{"user", required_argument, NULL, 15},
+ {"psqldir", required_argument, NULL, 16},
{NULL, 0, NULL, 0}
};
@@ -1388,6 +1402,11 @@ main(int argc, char *argv[])
case 15:
user = strdup(optarg);
break;
+ case 16:
+ /* "--psqldir=" should mean to use PATH */
+ if (strlen(optarg))
+ psqldir = strdup(optarg);
+ break;
default:
/* getopt_long already emitted a complaint */
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),