Fix pg_isolation_regress to work outside its build directory.

This makes it possible to, for example, use the isolation tester to
test a contrib module.

Andres Freund
This commit is contained in:
Robert Haas 2013-11-08 14:40:41 -05:00
parent 07cacba983
commit 9b4d52f209
5 changed files with 21 additions and 6 deletions

View File

@ -12,6 +12,9 @@
#include "pg_regress.h"
char isolation_exec[MAXPGPATH];
#define PG_ISOLATION_VERSIONSTR "isolationtester (PostgreSQL) " PG_VERSION "\n"
/*
* start an isolation tester process for specified file (including
* redirection), and return process ID
@ -58,7 +61,8 @@ isolation_start_test(const char *testname,
"%s ", launcher);
snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
SYSTEMQUOTE "\"./isolationtester\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
SYSTEMQUOTE "\"%s\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
isolation_exec,
dblist->str,
infile,
outfile);
@ -76,8 +80,16 @@ isolation_start_test(const char *testname,
}
static void
isolation_init(void)
isolation_init(int argc, char **argv)
{
/* look for isolationtester binary */
if (find_other_exec(argv[0], "isolationtester",
PG_ISOLATION_VERSIONSTR, isolation_exec) != 0)
{
fprintf(stderr, _("could not find proper isolationtester binary\n"));
exit(2);
}
/* set default regression database name */
add_stringlist_item(&dblist, "isolationtest");
}

View File

@ -85,13 +85,16 @@ main(int argc, char **argv)
PQExpBufferData wait_query;
int opt;
while ((opt = getopt(argc, argv, "n")) != -1)
while ((opt = getopt(argc, argv, "nV")) != -1)
{
switch (opt)
{
case 'n':
dry_run = true;
break;
case 'V':
puts("isolationtester (PostgreSQL) " PG_VERSION);
exit(0);
default:
fprintf(stderr, "Usage: isolationtester [-n] [CONNINFO]\n");
return EXIT_FAILURE;

View File

@ -1955,7 +1955,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
* We call the initialization function here because that way we can set
* default parameters and let them be overwritten by the commandline.
*/
ifunc();
ifunc(argc, argv);
if (getenv("PG_REGRESS_DIFF_OPTS"))
pretty_diff_opts = getenv("PG_REGRESS_DIFF_OPTS");

View File

@ -30,7 +30,7 @@ typedef PID_TYPE(*test_function) (const char *,
_stringlist **,
_stringlist **,
_stringlist **);
typedef void (*init_function) (void);
typedef void (*init_function) (int argc, char **argv);
extern char *bindir;
extern char *libdir;

View File

@ -84,7 +84,7 @@ psql_start_test(const char *testname,
}
static void
psql_init(void)
psql_init(int argc, char **argv)
{
/* set default regression database name */
add_stringlist_item(&dblist, "regression");