Skip to content

Commit 9b4d52f

Browse files
committed
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
1 parent 07cacba commit 9b4d52f

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

src/test/isolation/isolation_main.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
#include "pg_regress.h"
1414

15+
char isolation_exec[MAXPGPATH];
16+
#define PG_ISOLATION_VERSIONSTR "isolationtester (PostgreSQL) " PG_VERSION "\n"
17+
1518
/*
1619
* start an isolation tester process for specified file (including
1720
* redirection), and return process ID
@@ -58,7 +61,8 @@ isolation_start_test(const char *testname,
5861
"%s ", launcher);
5962

6063
snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
61-
SYSTEMQUOTE "\"./isolationtester\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
64+
SYSTEMQUOTE "\"%s\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
65+
isolation_exec,
6266
dblist->str,
6367
infile,
6468
outfile);
@@ -76,8 +80,16 @@ isolation_start_test(const char *testname,
7680
}
7781

7882
static void
79-
isolation_init(void)
83+
isolation_init(int argc, char **argv)
8084
{
85+
/* look for isolationtester binary */
86+
if (find_other_exec(argv[0], "isolationtester",
87+
PG_ISOLATION_VERSIONSTR, isolation_exec) != 0)
88+
{
89+
fprintf(stderr, _("could not find proper isolationtester binary\n"));
90+
exit(2);
91+
}
92+
8193
/* set default regression database name */
8294
add_stringlist_item(&dblist, "isolationtest");
8395
}

src/test/isolation/isolationtester.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ main(int argc, char **argv)
8585
PQExpBufferData wait_query;
8686
int opt;
8787

88-
while ((opt = getopt(argc, argv, "n")) != -1)
88+
while ((opt = getopt(argc, argv, "nV")) != -1)
8989
{
9090
switch (opt)
9191
{
9292
case 'n':
9393
dry_run = true;
9494
break;
95+
case 'V':
96+
puts("isolationtester (PostgreSQL) " PG_VERSION);
97+
exit(0);
9598
default:
9699
fprintf(stderr, "Usage: isolationtester [-n] [CONNINFO]\n");
97100
return EXIT_FAILURE;

src/test/regress/pg_regress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
19551955
* We call the initialization function here because that way we can set
19561956
* default parameters and let them be overwritten by the commandline.
19571957
*/
1958-
ifunc();
1958+
ifunc(argc, argv);
19591959

19601960
if (getenv("PG_REGRESS_DIFF_OPTS"))
19611961
pretty_diff_opts = getenv("PG_REGRESS_DIFF_OPTS");

src/test/regress/pg_regress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef PID_TYPE(*test_function) (const char *,
3030
_stringlist **,
3131
_stringlist **,
3232
_stringlist **);
33-
typedef void (*init_function) (void);
33+
typedef void (*init_function) (int argc, char **argv);
3434

3535
extern char *bindir;
3636
extern char *libdir;

src/test/regress/pg_regress_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ psql_start_test(const char *testname,
8484
}
8585

8686
static void
87-
psql_init(void)
87+
psql_init(int argc, char **argv)
8888
{
8989
/* set default regression database name */
9090
add_stringlist_item(&dblist, "regression");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy