]> granicus.if.org Git - postgresql/commitdiff
Fix pg_isolation_regress to work outside its build directory.
authorRobert Haas <rhaas@postgresql.org>
Fri, 8 Nov 2013 19:40:41 +0000 (14:40 -0500)
committerRobert Haas <rhaas@postgresql.org>
Fri, 8 Nov 2013 19:40:41 +0000 (14:40 -0500)
This makes it possible to, for example, use the isolation tester to
test a contrib module.

Andres Freund

src/test/isolation/isolation_main.c
src/test/isolation/isolationtester.c
src/test/regress/pg_regress.c
src/test/regress/pg_regress.h
src/test/regress/pg_regress_main.c

index 48a0e1235a2370e0b3540a2cc207aa16f0c44fe1..b3a8ff0530b2d214bc9994a25cff1edd6acc7e69 100644 (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");
 }
index 9679e6a6e6b630375d425e9224056661807e33ad..6d0c188217cf73a8c0a6917215254d699cf8dd41 100644 (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;
index 02cb5f4a7962c17832d2fbf19f38e9fa796a71ec..a902e9b8bec17fcc9e357002d4943990ce0b1af5 100644 (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");
index 5eb4d417a2836f87dabb5dabec1fef5dace935bf..a5798c9fff42896ea50fa359da8203199c54dbf7 100644 (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;
index f13e27ff2bc7be9aa1509e186f84cbe20fef9629..147e24c68c8d1f9cde6a3f7c09bd4fe2909a77e6 100644 (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");